Hi Samir,

With thrift 0.6.1  the following command does work:

Seems as it it the other way round. With the older Thrift version you probably just aren't getting the warning. That does not necessarily make it correct.

using thrift 0.9
WARNING: [...] Duplicate typename Problem found [...]

The warning is correct, as you do exactly that, which may be a problem. So I assume it is correct as it is now.

For background info: The checks and warnings have been added to the code base at 2013-07-15, the JIRA ticket is "THRIFT-2089 Compiler ignores duplicate typenames".

Have fun,
JensG



-----Ursprüngliche Nachricht----- From: Samir Faci
Sent: Wednesday, May 28, 2014 5:16 AM
To: [email protected]
Subject: Re: Thrift Best Practices / Problems with typdefs

Hi JensG and everyone else,

 I pushed some dummy thrift files that create the same behavior I tried to
explain in the previous email.

The thrift files I'm working with are available here:
https://github.com/WizeCommerce/medusa/tree/broken/thrift/business-objects

The one I'm looking at in particular is:

https://raw.githubusercontent.com/WizeCommerce/medusa/broken/thrift/business-objects/wizecommerce.bizobj.another_example.thrift

With thrift 0.6.1  the following command does work:

thrift -I thrift/business-objects -I thrift/services  --gen
java:private-members,hashcode
thrift/business-objects/wizecommerce.bizobj.another_example.thrift'

same command with the same definition files using thrift 0.9.


[WARNING:/home/sfaci/wize_work/thrift/definitions/thrift/business-objects/wizecommerce.bizobj.another_example.thrift:10]
Duplicate typename Problem found in
wizecommerce.bizobj.another_example,java,com.wizecommerce.service.common
and wizecommerce.bizobj.problemchild,java,com.wizecommerce.service.common
[file,scope,ns]
[WARNING:/home/sfaci/wize_work/thrift/definitions/thrift/business-objects/wizecommerce.bizobj.another_example.thrift:10]
Duplicate typename Problem found in
wizecommerce.bizobj.another_example,java,com.wizecommerce.service.common
and wizecommerce.bizobj.problemchild,java,com.wizecommerce.service.common
[file,scope,ns]
[ERROR:/home/sfaci/wize_work/thrift/definitions/thrift/business-objects/wizecommerce.bizobj.another_example.thrift:10]
(last token was 'struct')
Type "Problem" is already defined.

One fix is to just address the variable via the FQN.  That works fine.  I
just wasn't sure if I'm using typedef in an expected way or if there
are certain best practices i'm not following.





On Sun, May 25, 2014 at 10:36 AM, Jens Geyer <[email protected]> wrote:

Hi Samir,

could you put together a small, complete, self-containing example? Does
not need to be the "real" code, just something that is easier to discuss
about.

Thanks,
JensG


-----Ursprüngliche Nachricht----- From: Samir Faci
Sent: Saturday, May 24, 2014 1:26 AM
To: [email protected]
Subject: Thrift Best Practices / Problems with typdefs


Hi all,

 We (ie. @ work ) are in the process of migrating from thrift 0.6.1 to
thrift 0.9.1 and i'm having some issues with some files that used to
compile under the older version but don't seem to compile with the new
updated version.

As far as I can tell the errors seem to related to how thrift treats
typedefs.

Usually we define each struct/enum/exception in its own .thrift file and
include it wherever it's being used.

If multiple files have the typedef it seems to break, but if I use the FQN
(fully qualified name) of the struct then I have no problems with it.

Before I was able to fix it, I also saw errors such as:

"Type "User" is already defined."

A clear case of the behavior with be something like

user.thrift  ##  defines struct User
twitter_user.thrift  ## (or whatever specialized user you want) typedefs
the struct from user.thrift and includes user.thrift

user_service.thrift  ## includes user.thrift and twitter_user.thrift and
typedefs struct from both thrift files.

Basically since the file is typedef in twitter_user.thrift it errors out
when its typdef again in user_service.thrift.

I was wondering if something like C's #ifndef / #endif construct existed.

Or if anyone had any suggestions on how to handle such use cases.

Right now the only solution that comes to mind is limiting typdef use to
services.thrift files only.
(Or the highest level tier which can get get a bit difficult to determine
if you use service based inheritance)


Oh also.. to complicate things that much more.  We're currently generating
artifacts for both thrift 0.6.1 and thrift 0.9.1 (or trying to) so the
thrfit IDL
needs to compile with both versions.


Any suggestions/ guidance would be appreciated.




--
Samir Faci
*insert title*
fortune | cowsay -f /usr/share/cows/tux.cow

Sent from my non-iphone laptop.

Reply via email to