gdamour 2004/06/24 16:43:29
Modified: sandbox/messaging/src/java/org/apache/geronimo/messaging/remotenode/network ProtocolOutInterceptor.java ProtocolInDispatcher.java Log: ProtocolInDispatcher and ProtocolOutInterceptor were not thread-safe. Revision Changes Path 1.3 +15 -11 incubator-geronimo/sandbox/messaging/src/java/org/apache/geronimo/messaging/remotenode/network/ProtocolOutInterceptor.java Index: ProtocolOutInterceptor.java =================================================================== RCS file: /home/cvs/incubator-geronimo/sandbox/messaging/src/java/org/apache/geronimo/messaging/remotenode/network/ProtocolOutInterceptor.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ProtocolOutInterceptor.java 10 Jun 2004 23:12:25 -0000 1.2 +++ ProtocolOutInterceptor.java 24 Jun 2004 23:43:29 -0000 1.3 @@ -102,20 +102,25 @@ } public void push(Msg aMsg) { + byte[] marshalled; try { - Object opaque = - pushSynchronization.beforePush(streamOutputStream, aMsg); - streamOutputStream.writeObject(aMsg); - pushSynchronization.afterPush(streamOutputStream, aMsg, opaque); - streamOutputStream.reset(); - streamOutputStream.flush(); + synchronized(streamOutputStream) { + Object opaque = + pushSynchronization.beforePush(streamOutputStream, aMsg); + streamOutputStream.writeObject(aMsg); + pushSynchronization.afterPush(streamOutputStream, aMsg, opaque); + streamOutputStream.reset(); + streamOutputStream.flush(); + marshalled = memOut.toByteArray(); + memOut.reset(); + } } catch (IOException e) { log.error(e); throw new CommunicationException(e); } PlainDownPacket downPacket = new PlainDownPacket(); - ByteBuffer buffer = ByteBuffer.allocate(memOut.size()); - buffer.put(memOut.toByteArray()); + ByteBuffer buffer = ByteBuffer.allocate(marshalled.length); + buffer.put(marshalled); buffer.flip(); downPacket.setBuffers(Collections.singleton(buffer)); synchronized(protocol) { @@ -123,10 +128,9 @@ protocol.sendDown(downPacket); } catch (ProtocolException e) { log.error(e); - throw new RuntimeException(e); + throw new CommunicationException(e); } } - memOut.reset(); } } 1.2 +2 -2 incubator-geronimo/sandbox/messaging/src/java/org/apache/geronimo/messaging/remotenode/network/ProtocolInDispatcher.java Index: ProtocolInDispatcher.java =================================================================== RCS file: /home/cvs/incubator-geronimo/sandbox/messaging/src/java/org/apache/geronimo/messaging/remotenode/network/ProtocolInDispatcher.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- ProtocolInDispatcher.java 11 May 2004 12:06:42 -0000 1.1 +++ ProtocolInDispatcher.java 24 Jun 2004 23:43:29 -0000 1.2 @@ -104,7 +104,7 @@ private void dispatch() throws ProtocolException { Msg msg; try { - synchronized (protocol) { + synchronized (in) { Object opaque = popSynchronization.beforePop(streamInputStream); msg = (Msg) streamInputStream.readObject(); popSynchronization.afterPop(streamInputStream, msg, opaque);