activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jim Gomes (JIRA)" <j...@apache.org>
Subject [jira] Created: (AMQNET-53) Marshaling NULL BytesMessage in StompWireFormat throws exception
Date Wed, 05 Sep 2007 18:55:22 GMT
Marshaling NULL BytesMessage in StompWireFormat throws exception
----------------------------------------------------------------

                 Key: AMQNET-53
                 URL: https://issues.apache.org/activemq/browse/AMQNET-53
             Project: ActiveMQ .Net
          Issue Type: Bug
          Components: Stomp
         Environment: Windows XP SP2, .NET 2.0
            Reporter: Jim Gomes
            Assignee: James Strachan


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.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message