aboutsummaryrefslogtreecommitdiff
path: root/src/share/classes/javax
diff options
context:
space:
mode:
authorasaha <none@none>2014-10-06 15:51:21 -0700
committerasaha <none@none>2014-10-06 15:51:21 -0700
commitba7a3fd37d34a6abb1aef8cfead2a8cff1d93e11 (patch)
tree6b69a3f7d51febedbe08a1758f3de755e2e0eb8f /src/share/classes/javax
parent9a5074078afe92183a79dac71c45d45edb55ad9e (diff)
parentc4ef010da6a7825f85555478a23e4bb4fbbdff12 (diff)
Merge
Diffstat (limited to 'src/share/classes/javax')
-rw-r--r--src/share/classes/javax/management/remote/rmi/RMIConnector.java108
-rw-r--r--src/share/classes/javax/swing/JComponent.java16
-rw-r--r--src/share/classes/javax/swing/text/FlowView.java24
-rw-r--r--src/share/classes/javax/swing/text/GlyphView.java8
-rw-r--r--src/share/classes/javax/swing/text/View.java7
5 files changed, 106 insertions, 57 deletions
diff --git a/src/share/classes/javax/management/remote/rmi/RMIConnector.java b/src/share/classes/javax/management/remote/rmi/RMIConnector.java
index 9d71ed9e6..d4928bd01 100644
--- a/src/share/classes/javax/management/remote/rmi/RMIConnector.java
+++ b/src/share/classes/javax/management/remote/rmi/RMIConnector.java
@@ -1335,66 +1335,94 @@ public class RMIConnector implements JMXConnector, Serializable, JMXAddressable
int maxNotifications,
long timeout)
throws IOException, ClassNotFoundException {
- IOException org;
+ boolean retried = false;
while (true) { // used for a successful re-connection
+ // or a transient network problem
try {
return connection.fetchNotifications(clientSequenceNumber,
maxNotifications,
- timeout);
+ timeout); // return normally
} catch (IOException ioe) {
- org = ioe;
+ // Examine the chain of exceptions to determine whether this
+ // is a deserialization issue. If so - we propagate the
+ // appropriate exception to the caller, who will then
+ // proceed with fetching notifications one by one
+ rethrowDeserializationException(ioe);
- // inform of IOException
try {
communicatorAdmin.gotIOException(ioe);
-
- // The connection should be re-established.
- continue;
+ // reconnection OK, back to "while" to do again
} catch (IOException ee) {
- // No more fetch, the Exception will be re-thrown.
- break;
- } // never reached
- } // never reached
+ boolean toClose = false;
+
+ synchronized (this) {
+ if (terminated) {
+ // the connection is closed.
+ throw ioe;
+ } else if (retried) {
+ toClose = true;
+ }
+ }
+
+ if (toClose) {
+ // JDK-8049303
+ // We received an IOException - but the communicatorAdmin
+ // did not close the connection - possibly because
+ // the original exception was raised by a transient network
+ // problem?
+ // We already know that this exception is not due to a deserialization
+ // issue as we already took care of that before involving the
+ // communicatorAdmin. Moreover - we already made one retry attempt
+ // at fetching the same batch of notifications - and the
+ // problem persisted.
+ // Since trying again doesn't seem to solve the issue, we will now
+ // close the connection. Doing otherwise might cause the
+ // NotifFetcher thread to die silently.
+ final Notification failedNotif =
+ new JMXConnectionNotification(
+ JMXConnectionNotification.FAILED,
+ this,
+ connectionId,
+ clientNotifSeqNo++,
+ "Failed to communicate with the server: " + ioe.toString(),
+ ioe);
+
+ sendNotification(failedNotif);
+
+ try {
+ close(true);
+ } catch (Exception e) {
+ // OK.
+ // We are closing
+ }
+ throw ioe; // the connection is closed here.
+ } else {
+ // JDK-8049303 possible transient network problem,
+ // let's try one more time
+ retried = true;
+ }
+ }
+ }
}
+ }
+ private void rethrowDeserializationException(IOException ioe)
+ throws ClassNotFoundException, IOException {
// specially treating for an UnmarshalException
- if (org instanceof UnmarshalException) {
- UnmarshalException ume = (UnmarshalException)org;
-
- if (ume.detail instanceof ClassNotFoundException)
- throw (ClassNotFoundException) ume.detail;
-
- /* In Sun's RMI implementation, if a method return
- contains an unserializable object, then we get
- UnmarshalException wrapping WriteAbortedException
- wrapping NotSerializableException. In that case we
- extract the NotSerializableException so that our
- caller can realize it should try to skip past the
- notification that presumably caused it. It's not
- certain that every other RMI implementation will
- generate this exact exception sequence. If not, we
- will not detect that the problem is due to an
- unserializable object, and we will stop trying to
- receive notifications from the server. It's not
- clear we can do much better. */
- if (ume.detail instanceof WriteAbortedException) {
- WriteAbortedException wae =
- (WriteAbortedException) ume.detail;
- if (wae.detail instanceof IOException)
- throw (IOException) wae.detail;
- }
- } else if (org instanceof MarshalException) {
+ if (ioe instanceof UnmarshalException) {
+ throw ioe; // the fix of 6937053 made ClientNotifForwarder.fetchNotifs
+ // fetch one by one with UnmarshalException
+ } else if (ioe instanceof MarshalException) {
// IIOP will throw MarshalException wrapping a NotSerializableException
// when a server fails to serialize a response.
- MarshalException me = (MarshalException)org;
+ MarshalException me = (MarshalException)ioe;
if (me.detail instanceof NotSerializableException) {
throw (NotSerializableException)me.detail;
}
}
- // Not serialization problem, simply re-throw the orginal exception
- throw org;
+ // Not serialization problem, return.
}
protected Integer addListenerForMBeanRemovedNotif()
diff --git a/src/share/classes/javax/swing/JComponent.java b/src/share/classes/javax/swing/JComponent.java
index 55695dbe9..1d24558ae 100644
--- a/src/share/classes/javax/swing/JComponent.java
+++ b/src/share/classes/javax/swing/JComponent.java
@@ -56,6 +56,7 @@ import java.io.ObjectInputStream;
import java.io.IOException;
import java.io.ObjectInputValidation;
import java.io.InvalidObjectException;
+import java.util.concurrent.atomic.AtomicBoolean;
import javax.swing.border.*;
import javax.swing.event.*;
@@ -352,7 +353,8 @@ public abstract class JComponent extends Container implements Serializable,
private static final int AUTOSCROLLS_SET = 25;
private static final int FOCUS_TRAVERSAL_KEYS_FORWARD_SET = 26;
private static final int FOCUS_TRAVERSAL_KEYS_BACKWARD_SET = 27;
- private static final int REVALIDATE_RUNNABLE_SCHEDULED = 28;
+
+ private transient AtomicBoolean revalidateRunnableScheduled = new AtomicBoolean(false);
/**
* Temporary rectangles.
@@ -4859,16 +4861,11 @@ public abstract class JComponent extends Container implements Serializable,
// To avoid a flood of Runnables when constructing GUIs off
// the EDT, a flag is maintained as to whether or not
// a Runnable has been scheduled.
- synchronized(this) {
- if (getFlag(REVALIDATE_RUNNABLE_SCHEDULED)) {
- return;
- }
- setFlag(REVALIDATE_RUNNABLE_SCHEDULED, true);
+ if (revalidateRunnableScheduled.getAndSet(true)) {
+ return;
}
SunToolkit.executeOnEventHandlerThread(this, () -> {
- synchronized(JComponent.this) {
- setFlag(REVALIDATE_RUNNABLE_SCHEDULED, false);
- }
+ revalidateRunnableScheduled.set(false);
revalidate();
});
}
@@ -5508,6 +5505,7 @@ public abstract class JComponent extends Container implements Serializable,
ToolTipManager.sharedInstance().registerComponent(this);
}
setWriteObjCounter(this, (byte)0);
+ revalidateRunnableScheduled = new AtomicBoolean(false);
}
diff --git a/src/share/classes/javax/swing/text/FlowView.java b/src/share/classes/javax/swing/text/FlowView.java
index 53e63e2cf..9c5cf03f7 100644
--- a/src/share/classes/javax/swing/text/FlowView.java
+++ b/src/share/classes/javax/swing/text/FlowView.java
@@ -800,14 +800,22 @@ public abstract class FlowView extends BoxView {
@Override
protected void forwardUpdate(DocumentEvent.ElementChange ec,
DocumentEvent e, Shape a, ViewFactory f) {
- calculateUpdateIndexes(e);
- // Send update event to all views followed by the changed place.
- lastUpdateIndex = Math.max((getViewCount() - 1), 0);
- for (int i = firstUpdateIndex; i <= lastUpdateIndex; i++) {
- View v = getView(i);
- if (v != null) {
- Shape childAlloc = getChildAllocation(i, a);
- forwardUpdateToView(v, e, childAlloc, f);
+ // Update the view responsible for the changed element by invocation of
+ // super method.
+ super.forwardUpdate(ec, e, a, f);
+ // Re-calculate the update indexes and update the views followed by
+ // the changed place. Note: we update the views only when insertion or
+ // removal takes place.
+ DocumentEvent.EventType type = e.getType();
+ if (type == DocumentEvent.EventType.INSERT ||
+ type == DocumentEvent.EventType.REMOVE) {
+ firstUpdateIndex = Math.min((lastUpdateIndex + 1), (getViewCount() - 1));
+ lastUpdateIndex = Math.max((getViewCount() - 1), 0);
+ for (int i = firstUpdateIndex; i <= lastUpdateIndex; i++) {
+ View v = getView(i);
+ if (v != null) {
+ v.updateAfterChange();
+ }
}
}
}
diff --git a/src/share/classes/javax/swing/text/GlyphView.java b/src/share/classes/javax/swing/text/GlyphView.java
index 6aef36823..fd75fa096 100644
--- a/src/share/classes/javax/swing/text/GlyphView.java
+++ b/src/share/classes/javax/swing/text/GlyphView.java
@@ -971,6 +971,14 @@ public class GlyphView extends View implements TabableView, Cloneable {
}
}
+ /** {@inheritDoc} */
+ @Override
+ void updateAfterChange() {
+ // Drop the break spots. They will be re-calculated during
+ // layout. It is necessary for proper line break calculation.
+ breakSpots = null;
+ }
+
/**
* Class to hold data needed to justify this GlyphView in a PargraphView.Row
*/
diff --git a/src/share/classes/javax/swing/text/View.java b/src/share/classes/javax/swing/text/View.java
index 2b49055ab..d1e4e1336 100644
--- a/src/share/classes/javax/swing/text/View.java
+++ b/src/share/classes/javax/swing/text/View.java
@@ -1199,6 +1199,13 @@ public abstract class View implements SwingConstants {
}
/**
+ * Updates the view to reflect the changes.
+ */
+ void updateAfterChange() {
+ // Do nothing by default. Should be overridden in subclasses, if any.
+ }
+
+ /**
* Forwards the <code>DocumentEvent</code> to the give child view. This
* simply messages the view with a call to <code>insertUpdate</code>,
* <code>removeUpdate</code>, or <code>changedUpdate</code> depending