aboutsummaryrefslogtreecommitdiff
path: root/src/share/classes/com/sun/jmx/remote/internal/ClientNotifForwarder.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/share/classes/com/sun/jmx/remote/internal/ClientNotifForwarder.java')
-rw-r--r--src/share/classes/com/sun/jmx/remote/internal/ClientNotifForwarder.java59
1 files changed, 29 insertions, 30 deletions
diff --git a/src/share/classes/com/sun/jmx/remote/internal/ClientNotifForwarder.java b/src/share/classes/com/sun/jmx/remote/internal/ClientNotifForwarder.java
index b2ceb2fc1..ab6bd60ca 100644
--- a/src/share/classes/com/sun/jmx/remote/internal/ClientNotifForwarder.java
+++ b/src/share/classes/com/sun/jmx/remote/internal/ClientNotifForwarder.java
@@ -290,28 +290,6 @@ public abstract class ClientNotifForwarder {
infoList.clear();
- if (currentFetchThread == Thread.currentThread()) {
- /* we do not need to stop the fetching thread, because this thread is
- used to do restarting and it will not be used to do fetching during
- the re-registering the listeners.*/
- return tmp;
- }
-
- while (state == STARTING) {
- try {
- wait();
- } catch (InterruptedException ire) {
- IOException ioe = new IOException(ire.toString());
- EnvHelp.initCause(ioe, ire);
-
- throw ioe;
- }
- }
-
- if (state == STARTED) {
- setState(STOPPING);
- }
-
return tmp;
}
@@ -353,8 +331,9 @@ public abstract class ClientNotifForwarder {
beingReconnected = false;
notifyAll();
- if (currentFetchThread == Thread.currentThread()) {
- // no need to init, simply get the id
+ if (currentFetchThread == Thread.currentThread() ||
+ state == STARTING || state == STARTED) { // doing or waiting reconnection
+ // only update mbeanRemovedNotifID
try {
mbeanRemovedNotifID = addListenerForMBeanRemovedNotif();
} catch (Exception e) {
@@ -366,12 +345,23 @@ public abstract class ClientNotifForwarder {
logger.trace("init", msg, e);
}
}
- } else if (listenerInfos.length > 0) { // old listeners re-registered
- init(true);
- } else if (infoList.size() > 0) {
- // but new listeners registered during reconnection
- init(false);
- }
+ } else {
+ while (state == STOPPING) {
+ try {
+ wait();
+ } catch (InterruptedException ire) {
+ IOException ioe = new IOException(ire.toString());
+ EnvHelp.initCause(ioe, ire);
+ throw ioe;
+ }
+ }
+
+ if (listenerInfos.length > 0) { // old listeners are re-added
+ init(true); // not update clientSequenceNumber
+ } else if (infoList.size() > 0) { // only new listeners added during reconnection
+ init(false); // need update clientSequenceNumber
+ }
+ }
}
public synchronized void terminate() {
@@ -486,6 +476,15 @@ public abstract class ClientNotifForwarder {
if (nr == null || shouldStop()) {
// tell that the thread is REALLY stopped
setState(STOPPED);
+
+ try {
+ removeListenerForMBeanRemovedNotif(mbeanRemovedNotifID);
+ } catch (Exception e) {
+ if (logger.traceOn()) {
+ logger.trace("NotifFetcher-run",
+ "removeListenerForMBeanRemovedNotif", e);
+ }
+ }
} else {
executor.execute(this);
}