[ 
https://issues.apache.org/jira/browse/DERBY-4304?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12735102#action_12735102
 ] 

Mamta A. Satoor commented on DERBY-4304:
----------------------------------------

Tiago noticed (
[ 
https://issues.apache.org/jira/browse/DERBY-4306?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12731644#action_12731644
 ]) following NPE with my checkin 796316 (which has been rolled back)
       at 
org.apache.derby.impl.drda.NetworkServerControlImpl.isMsgProperty(NetworkServerControlImpl.java:3460)
       at 
org.apache.derby.impl.drda.NetworkServerControlImpl.localizeMessage(NetworkServerControlImpl.java:3397)
       at 
org.apache.derby.impl.drda.NetworkServerControlImpl.consolePropertyMessageWork(NetworkServerControlImpl.java:3195)
       at 
org.apache.derby.impl.drda.NetworkServerControlImpl.consolePropertyMessage(NetworkServerControlImpl.java:1888)
       at 
org.apache.derby.impl.drda.NetworkServerControlImpl.blockingStart(NetworkServerControlImpl.java:895)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

       at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:597)
       at 
org.apache.derby.iapi.jdbc.DRDAServerStarter.run(DRDAServerStarter.java:236)
       at java.lang.Thread.run(Thread.java:619)

I debugged the NPE and found that my try catch block below was getting NPE from 
mgmtService.unregisterMBean(versionMBean);
            try {
                mgmtService.unregisterMBean(versionMBean);
                mgmtService.unregisterMBean(networkServerMBean);
            } catch (Exception exception) {
                        consolePropertyMessage("DRDA_UnexpectedException.S", 
                                        exception.getMessage()); 
                        consoleExceptionPrintTrace(exception);
            }
This NPE from mgmtService.unregisterMBean(versionMBean); is caught by the catch 
clause above. The problem though is that exception.getMessage() for this NPE 
returns null and our existing code for consolePropertyMessage is not written to 
handle a null 2nd parameter. But the work that is being done by 
consolePropertyMessage on exception.getMessage() is also done by the next line 
of code in try catch block which is consoleExceptionPrintTrace(exception); In 
fact, consoleExceptionPrintTrace handles the null exception.getMessage() fine. 
Because of that I am suggesting that I replace the call 
consolePropertyMessage("DRDA_UnexpectedException.S", exception.getMessage()); 
with consolePropertyMessage("DRDA_UnexpectedException.S", true);

So, the new try catch will look as follows
            try {
                mgmtService.unregisterMBean(versionMBean);
                mgmtService.unregisterMBean(networkServerMBean);
            } catch (Exception exception) {
                        consolePropertyMessage("DRDA_UnexpectedException.S", 
true);
                        consoleExceptionPrintTrace(exception);
            }

In fact, I am changing all the try catches introduced for different steps of 
shutdown to look like above. I am running the junit tests right now. Once 
derbyall and junit finish, I will go ahead and commit these changes. Any 
feedback greatly appreciated.

> Network Server shutdown should handle exceptions and finish the server 
> shutdown completely
> ------------------------------------------------------------------------------------------
>
>                 Key: DERBY-4304
>                 URL: https://issues.apache.org/jira/browse/DERBY-4304
>             Project: Derby
>          Issue Type: Improvement
>          Components: Network Server
>    Affects Versions: 10.6.0.0
>            Reporter: Mamta A. Satoor
>            Assignee: Mamta A. Satoor
>         Attachments: DERBY4304_handleExceptions_patch1_diff.txt
>
>
> While working on DERBY-4053, found that an exception from Connection.close 
> was not handled properly by the server shutdown code which caused a new 
> instance server startup to hang. Resolved the problem with Connection close 
> but in general, we should
> 1) Make sure an exception during shutdown processing does not prevent the 
> remaining shutdown tasks, like closing the server socket from occurring. 
> 2) Make sure any exceptions that occur in shutdown processing are reported to 
> the console. 

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

Reply via email to