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 Sat, 01 Mar 2008 11:52:51 GMT

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

V.Narayanan commented on DERBY-3454:

Thank you for trying out the patch Serge :)

>Could it be considered to throw a runtime exception
>(like an IllegalStateException) other then an IOException 
>in the case when we try to use a connection which hasn't 
>been established (except for a tearDown method)?

I do not think it is advisable to throw unchecked exceptions
unless in cases where an alternate checked exception is not

>I think the receiver/transmitter shouldn't be accessed at all 
>after an exception is thrown during an initialization, which is 
>a case when socket couldn't be established.

A receiver or an transmitter is an abstraction above the underlying
connection. Why do you think accessing the transmitter or receiver is

I do agree that attempting a send from the transmitter seems illogical
when the connection does not exist, but then the transmitter is an
abstraction above the connection and is insulated from the conenction
details. Only when it tries to access the underlying connection does
it know that the connection is no longer valid and gets an exception.

>The XRE04 error will still be reported in this case. And if the 
>runtime exception is used, then an introduction of a new error 
>message won't be required I guess. 

If this had been true the NPE (which is also a RuntimeException)
would have resulted in a XRE04 :). I do not think we will get a
XRE04 if a RuntimeException is thrown.

> '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
>         Attachments: Derby3454.diff, Derby3454.stat
> 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