Return-Path: Delivered-To: apmail-activemq-dev-archive@www.apache.org Received: (qmail 77415 invoked from network); 6 Sep 2007 00:21:47 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 6 Sep 2007 00:21:47 -0000 Received: (qmail 74709 invoked by uid 500); 6 Sep 2007 00:21:41 -0000 Delivered-To: apmail-activemq-dev-archive@activemq.apache.org Received: (qmail 74664 invoked by uid 500); 6 Sep 2007 00:21:41 -0000 Mailing-List: contact dev-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list dev@activemq.apache.org Received: (qmail 74652 invoked by uid 99); 6 Sep 2007 00:21:41 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 05 Sep 2007 17:21:41 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO brutus.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Sep 2007 00:23:03 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 2DF6F714163 for ; Wed, 5 Sep 2007 17:21:23 -0700 (PDT) Message-ID: <10036043.1189038083185.JavaMail.jira@brutus> Date: Wed, 5 Sep 2007 17:21:23 -0700 (PDT) From: "Jim Gomes (JIRA)" To: dev@activemq.apache.org Subject: [jira] Commented: (AMQNET-53) Marshaling NULL BytesMessage in StompWireFormat throws exception In-Reply-To: <8787318.1189018522970.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/activemq/browse/AMQNET-53?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_40080 ] Jim Gomes commented on AMQNET-53: --------------------------------- A correlating change must be made in order to get empty BytesMessages to work correctly in the STOMP protocol implementation. The StompFrameStream.Flush() method in StompFrameStream.cs file should be changed to the following. The check for zero content length should be a less-than or equal comparison, not just a less-than comparison. {code:java|title=StompFrameStream.cs|borderStyle=solid} public void Flush() { builder.Append(NEWLINE); ds.Write(encoding.GetBytes(builder.ToString())); if (content != null) { ds.Write(content); } // if no content length then lets write a null if (contentLength <= 0) { ds.Write(NULL); } } {code} > 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 > Original Estimate: 15 minutes > Remaining Estimate: 15 minutes > > 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.