From derby-dev-return-56393-apmail-db-derby-dev-archive=db.apache.org@db.apache.org Tue Mar 04 03:24:04 2008 Return-Path: Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: (qmail 25372 invoked from network); 4 Mar 2008 03:24:02 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 4 Mar 2008 03:24:02 -0000 Received: (qmail 48841 invoked by uid 500); 4 Mar 2008 03:23:57 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 48628 invoked by uid 500); 4 Mar 2008 03:23:57 -0000 Mailing-List: contact derby-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: Delivered-To: mailing list derby-dev@db.apache.org Received: (qmail 48381 invoked by uid 99); 4 Mar 2008 03:23:57 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 03 Mar 2008 19:23:56 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Mar 2008 03:23:17 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 7CF54234C08E for ; Mon, 3 Mar 2008 19:22:50 -0800 (PST) Message-ID: <1123100257.1204600970510.JavaMail.jira@brutus> Date: Mon, 3 Mar 2008 19:22:50 -0800 (PST) From: "V.Narayanan (JIRA)" To: derby-dev@db.apache.org Subject: [jira] Commented: (DERBY-3454) 'java.lang.NullPointerException' is thrown when starting a master db before a slave one In-Reply-To: <515858619.1203765439969.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/DERBY-3454?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12574826#action_12574826 ] V.Narayanan commented on DERBY-3454: ------------------------------------ Thank you for the comments Serge :) >For the flow above: > * If (3) is executed before (2), then I guess this would be a programmatic error > and a RE should be called (like IllegalStateException) I would try to correct the case when (3) is called before (2) (fix the programming error) than throw an IllegalStateException > * If (2) fails, I do also consider executing (3) after that as a programmatic error, > because in this case a transmitter/receiver hasn't been properly initialized. > And there's an attempt to use a transmitter/receiver which has turned up to > be in an illegal state. >You're right that the transmitter/receiver is an abstraction above the connection. >But I'm just trying to say that it might be wrong (from a programmatic point of view) >to try to use them in an illegal state. And might be better to properly process a (2) >failure and make it so sendMessage/readMessage methods won't be called >afterwards, instead of relying on an IOException been reported to a user. * If there is a programmatic error causing an Unchecked Exception to be thrown (like an NPE) I would not correct it by throwing another Unchecked Exception (IllegalStateException) * If there is a programmatic error that causes an Unchecked Exception to be thrown,like, (3) before (2) I would correct the programmatic error than throw an unchecked exception * I do not agree that Properly processing a (2) failure = throwing an unchecked exception. * I am properly processing (2) when I try to ensure that the underlying connection is valid before attempting a send or a receive. * Now that all transmitter methods verify that the underlying connection is not invalid using the checkSocketConnection() method the there would be no danger of attempting (3) with a invalid connection. > '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: 10.4.0.0 > 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.