[ 
https://issues.apache.org/jira/browse/THRIFT-663?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12792862#action_12792862
 ] 

Ben Taitelbaum commented on THRIFT-663:
---------------------------------------

In general, I would agree with adding a new compiler switch so that we don't 
break backwards compatibility, but we're calling something a bean that's not 
technically a bean, which is why I would support breaking backwards 
compatibility in this case.

In terms of using a TXmlProtocol, this is the preferred solution if you're only 
using thrift objects, but in a system where the thrift object is used as just 
another java bean, I would expect that XmlEncoder should work.

> JavaBean code generator produces incorrect setter methods
> ---------------------------------------------------------
>
>                 Key: THRIFT-663
>                 URL: https://issues.apache.org/jira/browse/THRIFT-663
>             Project: Thrift
>          Issue Type: Bug
>          Components: Compiler (Java)
>    Affects Versions: 0.2
>            Reporter: Dave Engberg
>            Priority: Minor
>         Attachments: java-setter.diff
>
>
> The original Thrift JavaBean generator produced set* methods for a property 
> 'foo' that looked like:
> public void setFoo(int foo) {
>   this.foo = foo;
> }
> The more recent code in the 0.2.0 release now returns a value:
> public MyStruct setFoo(int foo) {
>   this.foo = foo;
>   return this;
> }
> I can imagine this was possibly desired by someone to implement a "chaining" 
> style of coding, but this is no longer a correct JavaBean.  The JavaBean spec 
> requires that the return type of set* functions be 'void', and various tools 
> and frameworks enforce this requirement.  For example, the Stripes web UI 
> toolkit thinks that a field is read-only if the set* function doesn't return 
> 'void'.
> I'll attach a trivial patch to restore this to the previous behavior.  If a 
> chaining-style setter is desired by others, I'd recommend making this a 
> separate method on the bean rather than replacing the standard setter.  E.g.:
> public MyStruct setChainFoo(int foo) { ...
> Or something like that.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to