Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6360330

NullPointerException from a generated stub: no state check or synchronization protection

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: P3 P3
    • 7
    • 6
    • other-libs
    • None
    • sparc
    • solaris_9

      We call "rmic -iiop" to generate a Tie class for our JMX IIOP connector, and we get a NullPointerException time to time from the Tie class when running our unit tests.

      After having a look at the generated Tie class _RMIConnectionImpl_Tie.java (attached), we find the problem is from the variable "target". This variable can be changed by the methods "setTargetsetTarget" and "deactivate()", and be used directly by the method "_invoke" for a client request.

      The problem occurs when a thread disconnecting the client calls "setTargetsetTarget" and "deactivate()" to set null to the target, one another thread calling "_invoke" for a client request gets NullPointerException because of null "target". In fact no any synchronization protection for the variable "target".

      One possible solution is to add a new private method:
      private Remote returnTarget() throws IOException {
      final Remote t = target;
      if (t == null) {
      // closed?
      throw new IOException(...);
      }
      return t;
      }
      and the method "_invoke" gets a "target" instance by calling this method.

      The same problem appears to jdk1.4 and jdk1.5

            kcavanauorcl Ken Cavanaugh (Inactive)
            sjiang Shanliang Jiang (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: