Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-11-07 11:04:08 +0000
committerEike Stepper2007-11-07 11:04:08 +0000
commitffd31784f53135d2749ef253e5d13741228c0f44 (patch)
treebf94b5582d2205c14d97ce3e7ab3dce3d69fd989
parente87d1530b54082e7fa4b70620d86fe5da0316eb1 (diff)
downloadcdo-ffd31784f53135d2749ef253e5d13741228c0f44.tar.gz
cdo-ffd31784f53135d2749ef253e5d13741228c0f44.tar.xz
cdo-ffd31784f53135d2749ef253e5d13741228c0f44.zip
[208999] NPE on registration timeout in ControlChannel
https://bugs.eclipse.org/bugs/show_bug.cgi?id=208999
-rw-r--r--plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/ControlChannel.java11
-rw-r--r--plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/TCPConnector.java2
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/TimeoutRuntimeException.java38
3 files changed, 48 insertions, 3 deletions
diff --git a/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/ControlChannel.java b/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/ControlChannel.java
index 9562331594..86c5c93543 100644
--- a/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/ControlChannel.java
+++ b/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/ControlChannel.java
@@ -17,6 +17,7 @@ import org.eclipse.net4j.internal.util.concurrent.SynchronizingCorrelator;
import org.eclipse.net4j.internal.util.om.trace.ContextTracer;
import org.eclipse.net4j.util.concurrent.ConcurrencyUtil;
import org.eclipse.net4j.util.concurrent.ISynchronizer;
+import org.eclipse.net4j.util.concurrent.TimeoutRuntimeException;
import org.eclipse.net4j.util.security.INegotiationContext;
import org.eclipse.net4j.util.security.INegotiationContext.Receiver;
@@ -32,7 +33,7 @@ public final class ControlChannel extends Channel
{
public static final short CONTROL_CHANNEL_INDEX = -1;
- public static final long REGISTRATION_TIMEOUT = 500000;
+ public static final long REGISTRATION_TIMEOUT = 5000;
public static final byte OPCODE_NEGOTIATION = 1;
@@ -87,7 +88,13 @@ public final class ControlChannel extends Channel
BufferUtil.putUTF8(byteBuffer, protocol == null ? null : protocol.getType());
handleBuffer(buffer);
- return registration.get(REGISTRATION_TIMEOUT);
+ Boolean acknowledged = registration.get(REGISTRATION_TIMEOUT);
+ if (acknowledged == null)
+ {
+ throw new TimeoutRuntimeException("Registration timeout after " + REGISTRATION_TIMEOUT + " milliseconds");
+ }
+
+ return acknowledged;
}
public void deregisterChannel(int channelID, short channelIndex)
diff --git a/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/TCPConnector.java b/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/TCPConnector.java
index 05004e91af..f617cd36a7 100644
--- a/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/TCPConnector.java
+++ b/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/TCPConnector.java
@@ -266,7 +266,7 @@ public abstract class TCPConnector extends Connector implements ITCPConnector, I
throw new ConnectorException("Failed to register channel with peer"); //$NON-NLS-1$
}
}
- catch (ConnectorException ex)
+ catch (RuntimeException ex)
{
throw ex;
}
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/TimeoutRuntimeException.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/TimeoutRuntimeException.java
new file mode 100644
index 0000000000..aad72d6522
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/TimeoutRuntimeException.java
@@ -0,0 +1,38 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2007 Eike Stepper, Germany.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ **************************************************************************/
+package org.eclipse.net4j.util.concurrent;
+
+/**
+ * @author Eike Stepper
+ */
+public class TimeoutRuntimeException extends RuntimeException
+{
+ private static final long serialVersionUID = 1L;
+
+ public TimeoutRuntimeException()
+ {
+ }
+
+ public TimeoutRuntimeException(String message)
+ {
+ super(message);
+ }
+
+ public TimeoutRuntimeException(Throwable cause)
+ {
+ super(cause);
+ }
+
+ public TimeoutRuntimeException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+}

Back to the top