db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "V.Narayanan (JIRA)" <j...@apache.org>
Subject [jira] Commented: (DERBY-3454) 'java.lang.NullPointerException' is thrown when starting a master db before a slave one
Date Mon, 25 Feb 2008 19:56:51 GMT

    [ https://issues.apache.org/jira/browse/DERBY-3454?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12572196#action_12572196

V.Narayanan commented on DERBY-3454:

tearDown is called in the startMaster method. The start failure and consequently the tearDown

is caused by the failure to establish a socket connection. Hence in the tearDown method 
trying to send a STOP message through a socket that does not exist results in a 

All the public methods of ReplicationMessageTransmit and ReplicationMessageReceive should
ensure that the socket connection exists (is not null) before performing the respective
operations. If the socket connection does not exist readMessage returns null and the sendMessage
method returns quietly.

Methods in ReplicationMessageTransmit

* tearDown()
* sendMessage()
* readMessage()

Methods in ReplicationMessageReceive

* sendMessage()
* readMessage()

The other methods in these classes must use the sendMessage and the readMessage methods and
call socketConn.writeMessage, socketConn.readMessage on their own. This would ensure that
"socket connection connection exist" checks are restricted to the read and the write methods

Note: The case of active=false on the master and the transmitter being called to send a message
      is a unique case. This happens only when the tearDown is called because of a network(socket)
      connection failure. Hence here it is safe to exit quietly from a send or read attempt
on a
      non-existent socket.

> 'java.lang.NullPointerException' is thrown when starting a master db before a slave one
> ---------------------------------------------------------------------------------------
>                 Key: DERBY-3454
>                 URL: https://issues.apache.org/jira/browse/DERBY-3454
>             Project: Derby
>          Issue Type: Bug
>          Components: Replication
>    Affects Versions:
>            Reporter: Serge Tsv
>            Assignee: V.Narayanan
> The 'java.lang.NullPointerException' exception is thrown when a database is started in
a master mode and is trying to establish a connection to an slave database socket, which is
not available.
> The exception is by the MasterController#startMaster(). First, it tries to setup connection
with a slave database using a transmitter:
>     MasterController#setupConnection
>        -> transmitter = new ReplicationMessageTransmit(); 
>             transmitter.initConnection()
>               -> new InetSocketAddress() -> createSocket() -> connect()
> The connect() method throws a ConnectException, and so fails to create a socketConn instance.
The exception is then wrapped several times an propagated back to the MasterController#startMaster()
method. It's caught there and then a MasterController#teardownNetwork() method is called,
which tries to send a STOP message using the aforementioned transmitter, which hasn't been
able to init a connection. 
> A transmitter simply tries to call socketConn.writeMessage(message), which throws NPE
because socketConn is null.
> Thanks!

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message