You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@servicemix.apache.org by "Guillaume Nodet (JIRA)" <ji...@apache.org> on 2006/08/23 21:01:23 UTC

[jira] Commented: (SM-553) MessageExchangeImpl.toString() converts message content to DOMSource

    [ https://issues.apache.org/activemq/browse/SM-553?page=comments#action_36833 ] 
            
Guillaume Nodet commented on SM-553:
------------------------------------

Thanks for the feedback.

While I acknowledge the problems for the DEBUG level and returning null,
you should note that for components to be good citizens, they should not expect
any specific source type, nor try to send non-xml payload inside a Source implementation.
I will add a system property to put logging off easily.

> MessageExchangeImpl.toString() converts message content to DOMSource
> --------------------------------------------------------------------
>
>                 Key: SM-553
>                 URL: https://issues.apache.org/activemq/browse/SM-553
>             Project: ServiceMix
>          Issue Type: Bug
>          Components: servicemix-core
>    Affects Versions: 3.0-M2
>            Reporter: Robert H. Pollack
>         Attachments: patches.zip
>
>
> The toString() method of MessageExchangeImpl, in an attempt to show the in, out, and fault messages of the exchange, converts their content to DOM.  If this conversion succeeds, the user may be surprised, because the message has changed from a stream source to a DOM source; this originally caused some ClassCastExceptions in our code.
> If the conversion fails, the situation is even worse.  Now the message content remains a stream source, but the stream has been consumed in the attempted conversion, so the message is now empty.
> The reason that this toString method is getting called, almost no matter what you do, is that ServiceMix is distributed with log levels set to DEBUG (oddly, you don't see any debug messages, probably because the log4j.xml file does not specify an appender for these messages).  This setting causes many invocations of the form
>     log.debug ("Now I'm doing something to " + myMessageExchange);
> which causes the toString method to be invoked whether or not anything is actually printed.
> This toString method also turns out to have another problem.  If it does get an exception, it returns null.  It turns out that an object's toString method should never do this, because it can cause NullPointerExceptions if the object is printed.
> I've created an alternate version of MessageExchangeImpl which corrects these problems.  To use it, unzip the enclosed file into your SERVICEMIX_HOME directory and run ant in the directory it creates.  This will create a new class and insert it into a place that will cause ServiceMix 3.0 to use it in preference to the original.  Be sure that you unzip this file into the right place, though, because the ant script contains specific references to "..".
> A bit more detail is in the comments in the enclosed code.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/activemq/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira