[
https://issues.apache.org/jira/browse/AMQNET-53?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Jim Gomes updated AMQNET-53:
----------------------------
Parent: (was: AMQNET-68)
> Marshaling NULL BytesMessage in StompWireFormat throws exception
> ----------------------------------------------------------------
>
> Key: AMQNET-53
> URL: https://issues.apache.org/jira/browse/AMQNET-53
> Project: ActiveMQ .Net
> Issue Type: Bug
> Components: ActiveMQ
> Environment: Windows XP SP2, .NET 2.0
> Reporter: Jim Gomes
> Assignee: james strachan
> Original Estimate: 0.25h
> Remaining Estimate: 0.25h
>
> When marshalling a BytesMessage that has a NULL message body (only properties
> are set on the message) an exception is thrown within the WriteMessage()
> function. Following is a replacement version that will work correctly. A
> NULL pointer check is added to the content of the message. This only occurs
> with the STOMP protocol. The OpenWire implementation correctly handles the
> NULL message body in a BytesMessage.
> {code:java|title=StompWireFormat.cs Replacement for
> WriteMessage()|borderStyle=solid}
> protected virtual void WriteMessage(ActiveMQMessage command, StompFrameStream
> ss)
> {
> ss.WriteCommand(command, "SEND");
> ss.WriteHeader("destination", StompHelper.ToStomp(command.Destination));
> if (command.ReplyTo != null)
> ss.WriteHeader("reply-to",
> StompHelper.ToStomp(command.ReplyTo));
> if (command.CorrelationId != null )
> ss.WriteHeader("correlation-id", command.CorrelationId);
> if (command.Expiration != 0)
> ss.WriteHeader("expires", command.Expiration);
> if (command.Priority != 4)
> ss.WriteHeader("priority", command.Priority);
> if (command.Type != null)
> ss.WriteHeader("type", command.Type);
> if (command.TransactionId!=null)
> ss.WriteHeader("transaction",
> StompHelper.ToStomp(command.TransactionId));
>
> ss.WriteHeader("persistent", command.Persistent);
>
> // lets force the content to be marshalled
>
> command.BeforeMarshall(null);
> if (command is ActiveMQTextMessage)
> {
> ActiveMQTextMessage textMessage = command as
> ActiveMQTextMessage;
> ss.Content = encoding.GetBytes(textMessage.Text);
> }
> else
> {
> ss.Content = command.Content;
> if (null != command.Content)
> {
> ss.ContentLength = command.Content.Length;
> }
> else
> {
> ss.ContentLength = 0;
> }
> }
>
> IPrimitiveMap map = command.Properties;
> foreach (string key in map.Keys)
> {
> ss.WriteHeader(key, map[key]);
> }
> ss.Flush();
> }
> {code}
--
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira