Uploaded image for project: 'Thrift'
  1. Thrift
  2. 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

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 0.5
    • 0.7
    • None

    Description

      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

      Attachments

        Activity

          People

            bryanduxbury Bryan Duxbury
            tkinnis Tony Kinnis
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: