thrift-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Marcus Herou" <marcus.he...@tailsweep.com>
Subject Re: Null ret val
Date Sun, 08 Jun 2008 12:34:45 GMT
OK... Then my app just ignores the TException and returns null itself then
:) Or on the server side I return a zero length byte[]

/M


On Sun, Jun 8, 2008 at 2:27 PM, Mark Slee <mcslee@facebook.com> wrote:

> Re: Null ret valThe issue with this (and reason it has not been done) is
> that it is not compatible with other programming languages. It's fine in an
> all-Java world, but would break if you have a C++ client calling your Java
> service. Since a thrift definition like this:
> StructType myMethod()
>
> Turns into a C++ definition of:
> void myMethod(StructType& ret)
>
> (or direct return for primitive types)
>
> Since there is no way to assign null to an object in C++, we decided
> against implementing nulls for Thrift objects.
>
> Two Thrift-compatible ways of doing this are:
> 1/ Make a wrapper object, or add a field to struct to signify null/non-null
> status (kind of ugly)
> 2/ Define an exception and throw it to signify the null result (also works
> in C++)
>
> Cheers,
> Mark
>
>  ----- Original Message -----
>  From: Johan Stuyts
>  To: thrift-user@incubator.apache.org
>  Sent: Sunday, June 08, 2008 4:20 AM
>  Subject: Re: Null ret val
>
>
>   > How do I handle null ret vals ? I just get
>  > com.facebook.thrift.TApplicationException: get failed: unknown result
>  > when
>  > returning null which I need to do sometimes.
>
>  This is not supported at the moment. The generated (Java) code checks if a
>  result value has been returned. In case of 'null' it obviously has not
>  been. Although this is required for Java primitive types because 'null'
>  cannot be returned in this case, for strings, containers and structs
>  'null' could be returned.
>
>  The changes required to return 'null' instead of throwing an exception are
>  trivial. I can create an issue and add a patch for the Java compiler to it
>  if nobody objects.
>
>  --
>  Kind regards,
>
>  Johan Stuyts
>
>


-- 
Marcus Herou CTO and co-founder Tailsweep AB
+46702561312
marcus.herou@tailsweep.com
http://www.tailsweep.com/
http://blogg.tailsweep.com/

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message