summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-05-14 23:04:42 (EDT)
committerEike Stepper2007-05-14 23:04:42 (EDT)
commit88b6af3a9a9a226bdc2e56baf2b2e23120111280 (patch)
treeced865573805b7d31f8a2e1479c9567607055830
parentb007a146914bd6d853c2aa2fe44e02b07893a170 (diff)
downloadcdo-88b6af3a9a9a226bdc2e56baf2b2e23120111280.zip
cdo-88b6af3a9a9a226bdc2e56baf2b2e23120111280.tar.gz
cdo-88b6af3a9a9a226bdc2e56baf2b2e23120111280.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/Connector.java51
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/lifecycle/LifecycleUtil.java18
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/stream/ExtendedDataInputStream.java11
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/stream/ExtendedDataOutputStream.java11
4 files changed, 51 insertions, 40 deletions
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/Connector.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/Connector.java
index ccb2d8f..14faebf 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/Connector.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/Connector.java
@@ -65,15 +65,12 @@ public abstract class Connector extends Lifecycle implements IConnector
/**
* An optional executor to be used by the {@link IChannel}s to process their
- * {@link Channel#receiveQueue} instead of the current thread. If not
- * <code>null</code> the sender and the receiver peers become decoupled.
+ * {@link Channel#receiveQueue} instead of the current thread. If not <code>null</code> the
+ * sender and the receiver peers become decoupled.
* <p>
*/
private ExecutorService receiveExecutor;
- /**
- * TODO synchronize on channels?
- */
private List<Channel> channels = new ArrayList(0);
private ConnectorState connectorState = ConnectorState.DISCONNECTED;
@@ -291,10 +288,10 @@ public abstract class Connector extends Lifecycle implements IConnector
public IChannel[] getChannels()
{
- final List<IChannel> result = new ArrayList(channels.size());
+ List<IChannel> result = new ArrayList(channels.size());
synchronized (channels)
{
- for (final Channel channel : channels)
+ for (Channel channel : channels)
{
if (channel != null)
{
@@ -444,32 +441,38 @@ public abstract class Connector extends Lifecycle implements IConnector
protected void addChannel(Channel channel)
{
- short channelIndex = channel.getChannelIndex();
- while (channelIndex >= channels.size())
+ synchronized (channels)
{
- channels.add(null);
- }
+ short channelIndex = channel.getChannelIndex();
+ while (channelIndex >= channels.size())
+ {
+ channels.add(null);
+ }
- channels.set(channelIndex, channel);
+ channels.set(channelIndex, channel);
+ }
}
protected boolean removeChannel(Channel channel)
{
- int channelIndex = channel.getChannelIndex();
- if (channels.get(channelIndex) == channel)
+ synchronized (channels)
{
- channel.removeListener(channelListener);
- if (TRACER.isEnabled())
+ int channelIndex = channel.getChannelIndex();
+ if (channels.get(channelIndex) == channel)
{
- TRACER.trace("Removing channel " + channelIndex); //$NON-NLS-1$
- }
+ channel.removeListener(channelListener);
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace("Removing channel " + channelIndex); //$NON-NLS-1$
+ }
- channels.set(channelIndex, null);
- return true;
- }
- else
- {
- return false;
+ channels.set(channelIndex, null);
+ return true;
+ }
+ else
+ {
+ return false;
+ }
}
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/lifecycle/LifecycleUtil.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/lifecycle/LifecycleUtil.java
index 172d0d0..2d28461 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/lifecycle/LifecycleUtil.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/lifecycle/LifecycleUtil.java
@@ -43,17 +43,15 @@ public final class LifecycleUtil
return true;
}
- public static void activate(Object object)
+ public static void activate(Object object) throws LifecycleException
{
activate(object, false);
}
/**
- * @throws Exception
- * TODO
* @see Activator
*/
- public static void activate(Object object, boolean useAnnotation)
+ public static void activate(Object object, boolean useAnnotation) throws LifecycleException
{
if (object instanceof ILifecycle)
{
@@ -119,17 +117,21 @@ public final class LifecycleUtil
return null;
}
- public static void deactivateNoisy(Object object) throws Exception
+ public static void deactivateNoisy(Object object) throws LifecycleException
{
deactivateNoisy(object, false);
}
- public static void deactivateNoisy(Object object, boolean useAnnotation) throws Exception
+ public static void deactivateNoisy(Object object, boolean useAnnotation) throws LifecycleException
{
Exception ex = deactivate(object, useAnnotation);
- if (ex != null)
+ if (ex instanceof RuntimeException)
{
- throw ex;
+ throw (RuntimeException)ex;
+ }
+ else if (ex != null)
+ {
+ throw new LifecycleException(ex);
}
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/stream/ExtendedDataInputStream.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/stream/ExtendedDataInputStream.java
index 46a700d..d758d7a 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/stream/ExtendedDataInputStream.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/stream/ExtendedDataInputStream.java
@@ -30,7 +30,7 @@ public class ExtendedDataInputStream extends DataInputStream implements Extended
int length = readInt();
if (length < 0)
{
- throw new IndexOutOfBoundsException();
+ return null;
}
byte[] b;
@@ -54,14 +54,13 @@ public class ExtendedDataInputStream extends DataInputStream implements Extended
public String readString() throws IOException
{
- try
- {
- return new String(readByteArray());
- }
- catch (IndexOutOfBoundsException ex)
+ byte[] bytes = readByteArray();
+ if (bytes == null)
{
return null;
}
+
+ return new String(bytes);
}
public Object readObject() throws IOException, ClassNotFoundException
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/stream/ExtendedDataOutputStream.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/stream/ExtendedDataOutputStream.java
index 762193d..b8b3926 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/stream/ExtendedDataOutputStream.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/stream/ExtendedDataOutputStream.java
@@ -27,8 +27,15 @@ public class ExtendedDataOutputStream extends DataOutputStream implements Extend
public void writeByteArray(byte[] b) throws IOException
{
- writeInt(b.length);
- write(b);
+ if (b != null)
+ {
+ writeInt(b.length);
+ write(b);
+ }
+ else
+ {
+ writeInt(-1);
+ }
}
public void writeString(String str) throws IOException