You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Tony Kinnis (JIRA)" <ji...@apache.org> on 2011/01/28 04:22:43 UTC

[jira] Updated: (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 ]

Tony Kinnis updated THRIFT-1050:
--------------------------------

    Summary: Declaring an argument named "manager" to a service method produces code that fails compile due to name conflicts with protected ivars in TAsyncClient  (was: Declaring an argument to a service method named "manager" produces code that fails compile due to name conflicts with protected ivars in TAsyncClient)

> 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
>            Priority: Minor
>
> 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.
>     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
>     }
> 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.
-
You can reply to this email to add a comment to the issue online.