[jboss-cvs] JBoss Messaging SVN: r3463 - in branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting: codec and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Dec 10 12:09:59 EST 2007
Author: jmesnil
Date: 2007-12-10 12:09:58 -0500 (Mon, 10 Dec 2007)
New Revision: 3463
Modified:
branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/Client.java
branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/codec/AbstractPacketCodec.java
Log:
http://jira.jboss.org/jira/browse/JBMESSAGING-544 Replace client-server transport with NIO based transport
* code clean up
Modified: branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/Client.java
===================================================================
--- branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/Client.java 2007-12-10 17:06:00 UTC (rev 3462)
+++ branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/Client.java 2007-12-10 17:09:58 UTC (rev 3463)
@@ -98,6 +98,7 @@
assert packet != null;
checkConnected();
+ // FIXME: must use a real counter for correlation ID
packet.setCorrelationID(System.nanoTime());
try
Modified: branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/codec/AbstractPacketCodec.java
===================================================================
--- branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/codec/AbstractPacketCodec.java 2007-12-10 17:06:00 UTC (rev 3462)
+++ branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/codec/AbstractPacketCodec.java 2007-12-10 17:09:58 UTC (rev 3463)
@@ -8,6 +8,9 @@
import static org.jboss.jms.destination.JBossDestination.readDestination;
import static org.jboss.jms.destination.JBossDestination.writeDestination;
+import static org.jboss.messaging.core.remoting.codec.DecoderStatus.NEED_DATA;
+import static org.jboss.messaging.core.remoting.codec.DecoderStatus.NOT_OK;
+import static org.jboss.messaging.core.remoting.codec.DecoderStatus.OK;
import static org.jboss.messaging.core.remoting.wireformat.AbstractPacket.NO_VERSION_SET;
import java.io.ByteArrayInputStream;
@@ -83,10 +86,15 @@
public DecoderStatus decodable(RemotingBuffer buffer)
{
+ if (buffer.remaining() < 2)
+ {
+ // can not read packet type & version
+ return NEED_DATA;
+ }
byte t = buffer.get();
if (t != type.byteValue())
{
- return DecoderStatus.NOT_OK;
+ return NOT_OK;
}
buffer.get(); // version
if (buffer.remaining() < INT_LENGTH)
@@ -94,14 +102,14 @@
if (log.isDebugEnabled())
log.debug("need more data to read header length");
// can not read next int
- return DecoderStatus.NEED_DATA;
+ return NEED_DATA;
}
int headerLength = buffer.getInt();
if (buffer.remaining() < headerLength)
{
if (log.isDebugEnabled())
log.debug("need more data to read header");
- return DecoderStatus.NEED_DATA;
+ return NEED_DATA;
}
buffer.getLong(); // correlation ID
try
@@ -109,14 +117,14 @@
buffer.getNullableString();
} catch (CharacterCodingException e)
{
- return DecoderStatus.NOT_OK;
+ return NOT_OK;
}
try
{
buffer.getNullableString();
} catch (CharacterCodingException e)
{
- return DecoderStatus.NOT_OK;
+ return NOT_OK;
}
if (buffer.remaining() < INT_LENGTH)
@@ -124,20 +132,20 @@
if (log.isDebugEnabled())
log.debug("need more data to read body length");
// can not read next int
- return DecoderStatus.NEED_DATA;
+ return NEED_DATA;
}
int bodyLength = buffer.getInt();
if (bodyLength == 0)
{
- return DecoderStatus.OK;
+ return OK;
}
if (buffer.remaining() < bodyLength)
{
if (log.isDebugEnabled())
log.debug("need more data to read body");
- return DecoderStatus.NEED_DATA;
+ return NEED_DATA;
}
- return DecoderStatus.OK;
+ return OK;
}
public P decode(RemotingBuffer wrapper) throws Exception
More information about the jboss-cvs-commits
mailing list