ARTEMIS-4133 msg w/null prop value can't be consumed via STOMP
This commit is contained in:
parent
e68034518d
commit
8a974fe89c
|
@ -16,6 +16,7 @@
|
|||
*/
|
||||
package org.apache.activemq.artemis.core.protocol.stomp;
|
||||
|
||||
import org.apache.activemq.artemis.api.core.ICoreMessage;
|
||||
import org.apache.activemq.artemis.logs.annotation.LogBundle;
|
||||
import org.apache.activemq.artemis.logs.annotation.LogMessage;
|
||||
import org.apache.activemq.artemis.logs.BundleFactory;
|
||||
|
@ -36,4 +37,7 @@ public interface ActiveMQStompProtocolLogger {
|
|||
|
||||
@LogMessage(id = 332070, value = "Unable to send frame {}", level = LogMessage.Level.ERROR)
|
||||
void errorSendingFrame(StompFrame frame, Exception e);
|
||||
|
||||
@LogMessage(id = 332071, value = "Unable to send message to client: {}", level = LogMessage.Level.WARN)
|
||||
void unableToSendMessageToClient(ICoreMessage message, Exception e);
|
||||
}
|
||||
|
|
|
@ -198,8 +198,7 @@ public class StompSession implements SessionCallback {
|
|||
|
||||
return length;
|
||||
} catch (Exception e) {
|
||||
logger.debug("exception in sendMessage", e);
|
||||
|
||||
ActiveMQStompProtocolLogger.LOGGER.unableToSendMessageToClient(coreMessage, e);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -103,7 +103,7 @@ public class StompUtils {
|
|||
|
||||
public static void copyStandardHeadersFromMessageToFrame(Message message,
|
||||
StompFrame command,
|
||||
int deliveryCount) throws Exception {
|
||||
int deliveryCount) {
|
||||
command.addHeader(Stomp.Headers.Message.MESSAGE_ID, String.valueOf(message.getMessageID()));
|
||||
SimpleString prefix = message.getSimpleStringProperty(Message.HDR_PREFIX);
|
||||
command.addHeader(Stomp.Headers.Message.DESTINATION, (prefix == null ? "" : prefix) + message.getAddress());
|
||||
|
@ -150,9 +150,12 @@ public class StompUtils {
|
|||
continue;
|
||||
}
|
||||
|
||||
command.addHeader(name.toString(), message.getObjectProperty(name).toString());
|
||||
Object value = message.getObjectProperty(name);
|
||||
if (value != null) {
|
||||
command.addHeader(name.toString(), value.toString());
|
||||
} else {
|
||||
command.addHeader(name.toString(), "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -707,6 +707,23 @@ public class StompTest extends StompTestBase {
|
|||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNullPropertyValue() throws Exception {
|
||||
conn.connect(defUser, defPass);
|
||||
|
||||
subscribe(conn, null, Stomp.Headers.Subscribe.AckModeValues.AUTO);
|
||||
|
||||
sendJmsMessage(getName(), "foo", null);
|
||||
|
||||
ClientStompFrame frame = conn.receiveFrame(2000);
|
||||
Assert.assertEquals(Stomp.Responses.MESSAGE, frame.getCommand());
|
||||
Assert.assertEquals(getQueuePrefix() + getQueueName(), frame.getHeader(Stomp.Headers.Send.DESTINATION));
|
||||
Assert.assertEquals(getName(), frame.getBody());
|
||||
Assert.assertEquals("", frame.getHeader("foo"));
|
||||
|
||||
conn.disconnect();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTransactedSessionLeak() throws Exception {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
|
|
|
@ -62,7 +62,17 @@ public class StompFrameFactoryV10 implements StompFrameFactory {
|
|||
|
||||
@Override
|
||||
public String[] handleHeaders(String header) {
|
||||
return header.split(":");
|
||||
String[] result = header.split(":");
|
||||
|
||||
// handle headers with empty value
|
||||
if (result.length == 1) {
|
||||
String[] tmp = new String[2];
|
||||
tmp[0] = result[0];
|
||||
tmp[1] = "";
|
||||
result = tmp;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue