NullPointerException in RemoteDatabaseInterface.ConnectionThread

[email protected] Wed, 8 Mar 2006 11:40:37 -0500
Newsgroups gmane.comp.db.mckoi
Message-ID <6B57DE2D690C194C962C7F41E24043CA0155E3AF@CORPUSMX40A.corp.emc.com>
Hi,

The NPE happens in RemoteDatabaseInterface.ConnectionThread:

java.lang.NullPointerException
        at
com.mckoi.database.jdbc.RemoteDatabaseInterface$ConnectionThread.getCommand(
RemoteDatabaseInterface.java:510)
        at
com.mckoi.database.jdbc.RemoteDatabaseInterface.execQuery(RemoteDatabaseInte
rface.java:196)
        at
com.mckoi.database.jdbc.MConnection.executeQuery(MConnection.java:348)
        at
com.mckoi.database.jdbc.MStatement.executeQuery(MStatement.java:110)
        at
com.mckoi.database.jdbc.MPreparedStatement.executeUpdate(MPreparedStatement.
java:124)

I think the connection thread finishes and set commands_list to null:

    public void run() {
      ...
      finally {
        // Invalidate this object when the thread finishes.
        Object old_commands_list = commands_list;
        synchronized (old_commands_list) {
          commands_list = null;
          old_commands_list.notifyAll();
        }
      }
    }

I suppose that a different thread is waiting in getCommand(), then it awakes
and goes on with its job but commands_list is null now:

ServerCommand getCommand(int timeout, int dispatch_id) throws SQLException {
      final long time_in = System.currentTimeMillis();
      final long time_out_high = time_in + ((long) timeout * 1000);

      synchronized (commands_list) {
        if (commands_list == null) {
          throw new SQLException("Connection to server closed");
        }

        while (true) {

          for (int i = 0; i < commands_list.size(); ++i) {
            ServerCommand command = (ServerCommand)
commands_list.elementAt(i);
            if (command.dispatchID() == dispatch_id) {
              commands_list.removeElementAt(i);
              return command;
            }
          }

          // Return null if we haven't received a response in the timeout
          // period.
          if (timeout != 0 &&
              System.currentTimeMillis() > time_out_high) {
            return null;
          }

          // Wait a second.
          try {
            commands_list.wait(1000);
          }
          catch (InterruptedException e) { /* ignore */ }

        } // while (true)

      } // synchronized

    }

By the way, is there a scheduled next release?

Regards,

Bruno.


---------------------------------------------------------------
Mckoi SQL Database mailing list  http://www.mckoi.com/database/
To unsubscribe, send a message to [email protected]