You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Bryan Duxbury (JIRA)" <ji...@apache.org> on 2011/03/15 18:27:29 UTC

[jira] Closed: (THRIFT-1050) Declaring an argument named "manager" to a service method produces code that fails compile due to name conflicts with protected ivars in TAsyncClient

     [ https://issues.apache.org/jira/browse/THRIFT-1050?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bryan Duxbury closed THRIFT-1050.
---------------------------------

    Resolution: Fixed
      Assignee: Bryan Duxbury

I just committed a minimal fix for this.

> Declaring an argument named "manager" to a service method produces code that fails compile due to name conflicts with protected ivars in TAsyncClient
> -----------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: THRIFT-1050
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1050
>             Project: Thrift
>          Issue Type: Bug
>          Components: Java - Compiler, Java - Library
>    Affects Versions: 0.5
>            Reporter: Tony Kinnis
>            Assignee: Bryan Duxbury
>            Priority: Minor
>             Fix For: 0.7
>
>
> The java code that is generated for a service method that has a argument named "manager" fails to compile. The TAsyncClient class declares a protected instance variable named "manager" and the generated code for the async call of that method declares a parameter called manager and also tries to use the instance variable called to dispatch the async call, however it can't since the method argument is shadowing the instance variable.
> Here is an example of the invalid code that is generated.
> {code}
> public void savePerson(Person manager, AsyncMethodCallback<savePerson_call> resultHandler) throws TException {
>   checkReady();
>   savePerson_call method_call = new savePerson_call(manager, resultHandler, this, protocolFactory, transport);
>   manager.call(method_call); // XXXX This is where the compile error occurs
> }
> {code}
> I think having a argument named "manager" could be fairly common.
> There are two potential fixes to this problem.
> 1. rename TAsyncClient's instance variable to something more obscure and less likely to collide, like asyncClientManager
> 2. make the variable private and access it via a method
> I think changes would need to be made in TAsyncClient.java as well as the code generator.
> There are two other member variables with protected access that could also create similar conflicts.
> protocolFactory
> transport

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira