changeset 11565:dd67910c07f4

8073148: "The server has decided to close this client connection" repeated continuously Reviewed-by: jbachorik
author sjiang
date Thu, 05 Mar 2015 14:54:07 +0100
parents f493132a7e7e
children 85b61f4eee66
files src/java.management/share/classes/com/sun/jmx/remote/internal/ClientNotifForwarder.java src/java.management/share/classes/javax/management/remote/rmi/RMIConnectionImpl.java
diffstat 2 files changed, 14 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.management/share/classes/com/sun/jmx/remote/internal/ClientNotifForwarder.java	Thu Mar 05 05:06:00 2015 -0800
+++ b/src/java.management/share/classes/com/sun/jmx/remote/internal/ClientNotifForwarder.java	Thu Mar 05 14:54:07 2015 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -538,6 +538,13 @@
                 currentFetchThread = null;
             }
 
+            if (nr == null) {
+                if (logger.traceOn()) {
+                    logger.trace("NotifFetcher-run",
+                            "Recieved null object as notifs, stops fetching because the "
+                                    + "notification server is terminated.");
+                }
+            }
             if (nr == null || shouldStop()) {
                 // tell that the thread is REALLY stopped
                 setState(STOPPED);
@@ -657,7 +664,7 @@
                     return null;
                 }
 
-                if (shouldStop())
+                if (shouldStop() || nr == null)
                     return null;
 
                 startSequenceNumber = nr.getNextSequenceNumber();
--- a/src/java.management/share/classes/javax/management/remote/rmi/RMIConnectionImpl.java	Thu Mar 05 05:06:00 2015 -0800
+++ b/src/java.management/share/classes/javax/management/remote/rmi/RMIConnectionImpl.java	Thu Mar 05 14:54:07 2015 +0100
@@ -1254,10 +1254,11 @@
             if (serverTerminated) {
                 // we must not call fetchNotifs() if the server is
                 // terminated (timeout elapsed).
-                //
-                return new NotificationResult(0L, 0L,
-                                              new TargetedNotification[0]);
-
+                // returns null to force the client to stop fetching
+                if (logger.debugOn()) logger.debug("fetchNotifications",
+                               "The notification server has been closed, "
+                                       + "returns null to force the client to stop fetching");
+                return null;
             }
             final long csn = clientSequenceNumber;
             final int mn = maxNotifications;