Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-744

xstream produces empty body

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 1.4.0
    • 1.5.0
    • camel-stream
    • None
    • Windows Server 2003; jdk1.6.0_06

    Description

      1. Set -Dfile.encoding=Cp1252

      2. Set tracing ON.

      3. Run the code:
      ====================================================
      from("timer://kickoff?period=10000").
      process(new Processor() {
      public void process(Exchange exchange) throws Exception

      { ArrayList<HashMap<String, Object>> rows = new ArrayList<HashMap<String, Object>>(); HashMap<String, Object> row = new HashMap<String, Object>(); row.put("column1", "Value 1"); rows.add(row); exchange.getOut().setBody(rows); }

      }).
      marshal().xstream().
      to("mock:result");
      ====================================================

      3. Observe output:
      ====================================================
      Jul 22, 2008 11:35:28 AM org.apache.camel.processor.Logger process
      INFO: ID-vchekan/4855-1216751728436/1-0 -> interceptor1 Interceptor[Delegate(Pipeline[DeadLetterChannel[Delegate(TraceInterceptor[Processor[enviance.org.test.MessageBrokerPackage$1@13e0aba]]), RecipientList[log:org.apache.camel.DeadLetterChannel?level=error], RedeliveryPolicy[maximumRedeliveries=6]], DeadLetterChannel[Delegate(TraceInterceptor[Marshal[org.apache.camel.model.dataformat.XStreamDataFormat@3257b8]]), RecipientList[log:org.apache.camel.DeadLetterChannel?level=error], RedeliveryPolicy[maximumRedeliveries=6]], DeadLetterChannel[Delegate(TraceInterceptor[To[mock:result]]), RecipientList[log:org.apache.camel.DeadLetterChannel?level=error], RedeliveryPolicy[maximumRedeliveries=6]]])] InOnly Properties:

      {org.apache.camel.timer.time=null, org.apache.camel.timer.period=10000, org.apache.camel.timer.name=kickoff} Headers:{} BodyType:null Body:Message: null
      Jul 22, 2008 11:35:28 AM org.apache.camel.processor.Logger process
      INFO: ID-vchekan/4855-1216751728436/1-0 -> processor1 Processor[enviance.org.test.MessageBrokerPackage$1@13e0aba] InOnly Properties:{org.apache.camel.timer.time=null, org.apache.camel.timer.period=10000, CamelCauseException=null, org.apache.camel.timer.name=kickoff} Headers:{} BodyType:null Body:Message: null
      Jul 22, 2008 11:35:28 AM org.apache.camel.processor.Logger process
      INFO: ID-vchekan/4855-1216751728436/1-0 -> marshal1 Marshal[org.apache.camel.model.dataformat.XStreamDataFormat@3257b8] InOnly Properties:{org.apache.camel.timer.time=null, org.apache.camel.timer.period=10000, CamelCauseException=null, org.apache.camel.timer.name=kickoff} Headers:{} BodyType:java.util.ArrayList Body:[{column1=Value 1}]
      Jul 22, 2008 11:35:29 AM org.apache.camel.processor.Logger process
      INFO: ID-vchekan/4855-1216751728436/1-0 -> to1 To[mock:result] InOnly Properties:{org.apache.camel.timer.time=null, org.apache.camel.timer.period=10000, CamelCauseException=null, org.apache.camel.timer.name=kickoff} Headers:{} BodyType:[B Body:
      ====================================================

      As you see xstream returms an empty array (the end of the last line).

      4. Change encoding in step 1 to -Dfile.encoding=UTF-8 and re-run the application.
      ====================================================
      Jul 22, 2008 11:40:18 AM org.apache.camel.processor.Logger process
      INFO: ID-vchekan/4875-1216752017927/1-0 -> interceptor1 Interceptor[Delegate(Pipeline[DeadLetterChannel[Delegate(TraceInterceptor[Processor[enviance.org.test.MessageBrokerPackage$1@13e0aba]]), RecipientList[log:org.apache.camel.DeadLetterChannel?level=error], RedeliveryPolicy[maximumRedeliveries=6]], DeadLetterChannel[Delegate(TraceInterceptor[Marshal[org.apache.camel.model.dataformat.XStreamDataFormat@3257b8]]), RecipientList[log:org.apache.camel.DeadLetterChannel?level=error], RedeliveryPolicy[maximumRedeliveries=6]], DeadLetterChannel[Delegate(TraceInterceptor[To[mock:result]]), RecipientList[log:org.apache.camel.DeadLetterChannel?level=error], RedeliveryPolicy[maximumRedeliveries=6]]])] InOnly Properties:{org.apache.camel.timer.time=null, org.apache.camel.timer.period=10000, org.apache.camel.timer.name=kickoff}

      Headers:{} BodyType:null Body:Message: null
      Jul 22, 2008 11:40:18 AM org.apache.camel.processor.Logger process
      INFO: ID-vchekan/4875-1216752017927/1-0 -> processor1 Processor[enviance.org.test.MessageBrokerPackage$1@13e0aba] InOnly Properties:

      {org.apache.camel.timer.time=null, org.apache.camel.timer.period=10000, CamelCauseException=null, org.apache.camel.timer.name=kickoff} Headers:{} BodyType:null Body:Message: null
      Jul 22, 2008 11:40:18 AM org.apache.camel.processor.Logger process
      INFO: ID-vchekan/4875-1216752017927/1-0 -> marshal1 Marshal[org.apache.camel.model.dataformat.XStreamDataFormat@3257b8] InOnly Properties:{org.apache.camel.timer.time=null, org.apache.camel.timer.period=10000, CamelCauseException=null, org.apache.camel.timer.name=kickoff}

      Headers:{} BodyType:java.util.ArrayList Body:[

      {column1=Value 1}

      ]
      Jul 22, 2008 11:40:18 AM org.apache.camel.processor.Logger process
      INFO: ID-vchekan/4875-1216752017927/1-0 -> to1 To[mock:result] InOnly Properties:

      {org.apache.camel.timer.time=null, org.apache.camel.timer.period=10000, CamelCauseException=null, org.apache.camel.timer.name=kickoff}

      Headers:{} BodyType:[B Body:<?xml version="1.0" ?><list><map><entry><string>column1</string><string>Value 1</string></entry></map></list>
      ====================================================

      You see xml now.

      I think it is a bug when xstream component silently refuses to work by producing empty output. It should either take into account configured encoding when producing output or explicitly refuse to work if encoding is "wrong" (throw an exception explaining the reasons of error).

      Fixing this error is important because it affects at least 2 windows environments: Eclipse and ActiveMQ.
      By default Eclipse on Windows has Cp1252 encoding set.
      I do not know what encoding is set in ActiveMQ for Windows but it does not work unless activemq.bat is edited and encoding is explicitly set there.

      Attachments

        Activity

          People

            Unassigned Unassigned
            vchekan Vadim Chekan
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: