Author: jmesnil
Date: 2010-04-15 05:45:07 -0400 (Thu, 15 Apr 2010)
New Revision: 9121
Modified:
trunk/src/main/org/hornetq/core/protocol/stomp/StompFrameDecoder.java
trunk/tests/src/org/hornetq/tests/integration/stomp/StompTest.java
Log:
fix Stomp decoder
* make sure the buffer is readable before attempting to read a byte from it
* increased receive timeout in StompTest.testSendMessageWithContentLength()
Modified: trunk/src/main/org/hornetq/core/protocol/stomp/StompFrameDecoder.java
===================================================================
--- trunk/src/main/org/hornetq/core/protocol/stomp/StompFrameDecoder.java 2010-04-15
09:27:44 UTC (rev 9120)
+++ trunk/src/main/org/hornetq/core/protocol/stomp/StompFrameDecoder.java 2010-04-15
09:45:07 UTC (rev 9121)
@@ -124,6 +124,10 @@
data = new byte[length];
buffer.readBytes(data);
+ if (!buffer.readable())
+ {
+ return null;
+ }
if (buffer.readByte() != 0)
{
throw new StompException(Stomp.Headers.CONTENT_LENGTH + " bytes were
read and " +
Modified: trunk/tests/src/org/hornetq/tests/integration/stomp/StompTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/stomp/StompTest.java 2010-04-15 09:27:44
UTC (rev 9120)
+++ trunk/tests/src/org/hornetq/tests/integration/stomp/StompTest.java 2010-04-15 09:45:07
UTC (rev 9121)
@@ -64,6 +64,7 @@
import org.hornetq.jms.server.config.impl.TopicConfigurationImpl;
import org.hornetq.jms.server.impl.JMSServerManagerImpl;
import org.hornetq.spi.core.protocol.ProtocolType;
+import org.hornetq.tests.unit.util.InVMContext;
import org.hornetq.tests.util.UnitTestCase;
public class StompTest extends UnitTestCase
@@ -260,7 +261,7 @@
baos.write('\0');
sendFrame(baos.toByteArray());
- BytesMessage message = (BytesMessage)consumer.receive(1000);
+ BytesMessage message = (BytesMessage)consumer.receive(10000);
Assert.assertNotNull(message);
assertEquals(data.length, message.getBodyLength());
assertEquals(data[0], message.readByte());
@@ -1290,7 +1291,7 @@
.add(new JMSQueueConfigurationImpl(getQueueName(), null, false,
getQueueName()));
jmsConfig.getTopicConfigurations().add(new TopicConfigurationImpl(getTopicName(),
getTopicName()));
server = new JMSServerManagerImpl(hornetQServer, jmsConfig);
- server.setContext(null);
+ server.setContext(new InVMContext());
return server;
}
Show replies by date