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

2006-11-08 Thread Guillaume Nodet (JIRA)
[ 
https://issues.apache.org/activemq/browse/SM-553?page=comments#action_37385 ] 

Guillaume Nodet commented on SM-553:


If you look at the latest code, this has been fixed:
  
http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-3.0/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/MessageExchangeImpl.java?r1=434130&r2=434178&diff_format=h

> 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
> Assigned To: Guillaume Nodet
> Fix For: 3.0
>
> 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




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

2006-11-08 Thread Robert H. Pollack (JIRA)
[ 
https://issues.apache.org/activemq/browse/SM-553?page=comments#action_37381 ] 

Robert H. Pollack commented on SM-553:
--


   [[ Old comment, sent by email on Wed, 23 Aug 2006 15:47:12 -0400 ]]

Dear M. Nodet,

Thanks for your quick attention to this problem.  I'm flattered that you
thought well enough of my change to keep my logic, even down to the name
of the flag.

I do have one minor quibble, though, that I'd like to call to your
attention.  Your change says

+if (preserveContent) {
+sb.append(getMessage(msg).getContent().getClass());
+} else {
+if (getMessage(msg).getContent() != null) {
+Node node =
st.toDOMNode(getMessage(msg).getContent());
...

I believe that the "if (preserveContent)" test should be AFTER the test
for null message content.  Otherwise, if getContent() returns null, you
will get a NullPointerException when you say "getContent().getClass()".

Thank you again for your quick service.

Bob Pollack
Gestalt, LLC



> 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
> Assigned To: Guillaume Nodet
> Fix For: 3.0
>
> 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




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

2006-08-23 Thread Guillaume Nodet (JIRA)
[ 
https://issues.apache.org/activemq/browse/SM-553?page=comments#action_36834 ] 

Guillaume Nodet commented on SM-553:


Author: gnodet
Date: Wed Aug 23 12:26:29 2006
New Revision: 434130

URL: http://svn.apache.org/viewvc?rev=434130&view=rev
Log:
SM-553: add a system property to preserve jbi message content when calling 
toString() and avoid returning null when an exception is thrown



> 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




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

2006-08-23 Thread Guillaume Nodet (JIRA)
[ 
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