Issue Details (XML | Word | Printable)

Key: MULE-2804
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Critical Critical
Assignee: Holger Hoffstaette
Reporter: Adriaan Wisse
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Mule

returnClass of GZipUncompressTransformer will default be set to java.lang.Object so it is not possible to uncompress files

Created: 13/Dec/07 09:50 AM   Updated: 14/Dec/07 06:12 PM
Component/s: Core: Transformers
Affects Version/s: 1.4.3
Fix Version/s: 1.4.4

Time Tracking:
Not Specified

Issue Links:
Duplicate
 

Labels:
User impact: High
Configuration:
<?xml version="1.0"?>
<!DOCTYPE mule-configuration PUBLIC "-//SymphonySoft //DTD mule-configuration XML V1.0//EN"
"mule-configuration.dtd">
<mule-configuration version="1.0" id="test-unzip">

<transformers>
<transformer name="GZIPUncompressTransformer" className="org.mule.transformers.compression.GZipUncompressTransformer" />
</transformers>

<model name="testmodel">
<!--
This mule part takes a zipped file out of the directory, unzip it and output it to another directory. The originalefilename
is kept. The mule bridge componente takes the input from one endpoint and passes it directly to the outbound router
-->
<mule-descriptor name="iakVecozoDeclaratieRetourZipFileListener" implementation="org.mule.components.simple.BridgeComponent">
<inbound-router>
<endpoint address="file://test/zip/in" transformers="GZIPUncompressTransformer" >
<filter pattern="*.zip" className="org.mule.providers.file.filters.FilenameWildcardFilter"/>
</endpoint>
</inbound-router>
<outbound-router>
<router className="org.mule.routing.outbound.FilteringOutboundRouter">
<endpoint address="file://test/unzip/out">
<properties>
<property name="outputPattern" value="$[ORIGINALNAME]"/>
</properties>
</endpoint>
</router>
</outbound-router>
</mule-descriptor>
</model>

</mule-configuration>

Log Output:
15:40:39,982 connector.file.0.receiver.1 DEBUG org.mule.providers.file.transformers.FileToByteArray - Applying transformer FileToByteArray (org.mule.providers.file.transformers.FileToByteArray)
15:40:39,982 connector.file.0.receiver.1 DEBUG org.mule.providers.file.transformers.FileToByteArray - Object before transform: /home/nl27523/workspace/openchain/iak-vecozo/work/iak/edp/retourdeclaratie/zip/in/R_EDP_200710300841_17084512.dat.zip
15:40:39,983 connector.file.0.receiver.1 DEBUG org.mule.providers.file.transformers.FileToByteArray - Object after transform: {31,-117,8,8,-53,-72,96,71,0,3,49,48,49,57,53,51,53,55,57,0,-51,-113,-79,13,-128,48,12,4,-5,72,-39,33,35,-4,-37,-60,-63,61,44,16,-119,-3,87,-127,0,73,69,-115,114,-78 [..]}
15:40:39,983 connector.file.0.receiver.1 DEBUG org.mule.providers.file.transformers.FileToByteArray - The transformed object is of expected type. Type is: byte[]
15:40:39,989 connector.file.0.receiver.1 DEBUG org.mule.providers.file.FileMessageReceiver - Message Received from: file://work/iak/edp/retourdeclaratie/zip/in
15:40:39,997 connector.file.0.receiver.1 DEBUG org.mule.impl.MuleSession - There is no session id on the request using key: ID. Generating new session id: c1bc5782-a991-11dc-bad2-9f636cb917ab
15:40:40,001 connector.file.0.receiver.1 DEBUG org.mule.routing.inbound.ForwardingConsumer - Attempting to route event: c1bc5783-a991-11dc-bad2-9f636cb917ab
15:40:40,001 connector.file.0.receiver.1 DEBUG org.mule.routing.inbound.ForwardingConsumer - Attempting to route event: c1bc5783-a991-11dc-bad2-9f636cb917ab
15:40:40,002 connector.file.0.receiver.1 DEBUG org.mule.transformers.compression.GZipUncompressTransformer - Applying transformer GZIPUncompressTransformer (org.mule.transformers.compression.GZipUncompressTransformer)
15:40:40,002 connector.file.0.receiver.1 DEBUG org.mule.transformers.compression.GZipUncompressTransformer - Object before transform: {31,-117,8,8,-53,-72,96,71,0,3,49,48,49,57,53,51,53,55,57,0,-51,-113,-79,13,-128,48,12,4,-5,72,-39,33,35,-4,-37,-60,-63,61,44,16,-119,-3,87,-127,0,73,69,-115,114,-78 [..]}
15:40:40,002 connector.file.0.receiver.1 DEBUG org.mule.util.compression.GZipCompression - Uncompressing message of size: 114
15:40:40,005 connector.file.0.receiver.1 DEBUG org.mule.util.compression.GZipCompression - Uncompressed message to size: 504
15:40:40,021 connector.file.0.receiver.1 DEBUG org.mule.config.i18n.MessageFactory - Loading resource bundle: META-INF.services.org.mule.i18n.file-messages for locale en_US
15:40:40,027 connector.file.0.receiver.1 DEBUG org.mule.config.i18n.MessageFactory - Loading resource bundle: META-INF.services.org.mule.i18n.core-messages for locale en_US
15:40:40,028 connector.file.0.receiver.1 DEBUG org.mule.config.i18n.MessageFactory - Loading resource bundle: META-INF.services.org.mule.i18n.core-messages for locale en_US
15:40:40,030 connector.file.0.receiver.1 DEBUG org.mule.config.i18n.MessageFactory - Loading resource bundle: META-INF.services.org.mule.i18n.core-messages for locale en_US
15:40:40,031 connector.file.0.receiver.1 DEBUG org.mule.config.i18n.MessageFactory - Loading resource bundle: META-INF.services.org.mule.i18n.core-messages for locale en_US
15:40:40,032 connector.file.0.receiver.1 ERROR org.mule.impl.DefaultExceptionStrategy -
********************************************************************************
Message : Exception while processing "R_EDP_200710300841_17084512.dat.zip" Result of rollback of move was unsuccessful. Failed to route event via endpoint: MuleEndpoint{endpointUri=file://work/iak/edp/retourdeclaratie/zip/in, connector=FileConnector{this=4be2cc, started=true, initialised=true, name='connector.file.0', disposed=false, numberOfConcurrentTransactedReceivers=4, createMultipleTransactedReceivers=true, connected=true, supportedProtocols=[file], serviceOverrides=null}, transformer=GZipUncompressTransformer{this=11ef443, name='GZIPUncompressTransformer', ignoreBadInput=false, returnClass=class java.lang.Object, sourceTypes=[interface java.io.Serializable, class [B]}, name='endpoint.file.work.iak.edp.retourdeclaratie.zip.in', type='receiver', properties={pollingFrequency=5000}, transactionConfig=Transaction{factory=null, action=NONE, timeout=30000}, filter=org.mule.providers.file.filters.FilenameWildcardFilter@1367e28, deleteUnacceptedMessages=false, initialised=true, securityFilter=null, synchronous=null, initialState=started, createConnector=0, remoteSync=false, remoteSyncTimeout=null, endpointEncoding=null}. Message payload is of type: byte[]
Type : org.mule.umo.routing.RoutingException
Code : MULE_ERROR-39999
Payload : [B@94af2f
JavaDoc : http://mule.mulesource.org/docs/apidocs/org/mule/umo/routing/RoutingException.html
********************************************************************************
Exception stack is:
1. invalid stream header: 31203130 (java.io.StreamCorruptedException)
  java.io.ObjectInputStream:783 (null)
2. java.io.StreamCorruptedException: invalid stream header: 31203130 (org.apache.commons.lang.SerializationException)
  org.apache.commons.lang.SerializationUtils:166 (null)
3. Exception while processing "R_EDP_200710300841_17084512.dat.zip" Result of rollback of move was unsuccessful. Failed to route event via endpoint: MuleEndpoint{endpointUri=file://work/iak/edp/retourdeclaratie/zip/in, connector=FileConnector{this=4be2cc, started=true, initialised=true, name='connector.file.0', disposed=false, numberOfConcurrentTransactedReceivers=4, createMultipleTransactedReceivers=true, connected=true, supportedProtocols=[file], serviceOverrides=null}, transformer=GZipUncompressTransformer{this=11ef443, name='GZIPUncompressTransformer', ignoreBadInput=false, returnClass=class java.lang.Object, sourceTypes=[interface java.io.Serializable, class [B]}, name='endpoint.file.work.iak.edp.retourdeclaratie.zip.in', type='receiver', properties={pollingFrequency=5000}, transactionConfig=Transaction{factory=null, action=NONE, timeout=30000}, filter=org.mule.providers.file.filters.FilenameWildcardFilter@1367e28, deleteUnacceptedMessages=false, initialised=true, securityFilter=null, synchronous=null, initialState=started, createConnector=0, remoteSync=false, remoteSyncTimeout=null, endpointEncoding=null}. Message payload is of type: byte[] (org.mule.umo.routing.RoutingException)
  org.mule.providers.file.FileMessageReceiver:262 (http://mule.mulesource.org/docs/apidocs/org/mule/umo/routing/RoutingException.html)
********************************************************************************
Root Exception stack trace:
java.io.StreamCorruptedException: invalid stream header: 31203130
at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:783)
at java.io.ObjectInputStream.<init>(ObjectInputStream.java:280)
at org.apache.commons.lang.SerializationUtils.deserialize(SerializationUtils.java:160)
at org.apache.commons.lang.SerializationUtils.deserialize(SerializationUtils.java:191)
at org.mule.transformers.compression.GZipUncompressTransformer.doTransform(GZipUncompressTransformer.java:48)
at org.mule.transformers.AbstractTransformer.transform(AbstractTransformer.java:250)
at org.mule.impl.MuleEvent.getTransformedMessage(MuleEvent.java:342)
at org.mule.routing.inbound.ForwardingConsumer.process(ForwardingConsumer.java:49)
at org.mule.routing.inbound.InboundRouterCollection.route(InboundRouterCollection.java:86)
at org.mule.providers.AbstractMessageReceiver$DefaultInternalMessageListener.onMessage(AbstractMessageReceiver.java:581)
at org.mule.providers.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:322)
at org.mule.providers.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:251)
at org.mule.providers.file.FileMessageReceiver.processFile(FileMessageReceiver.java:228)
at org.mule.providers.file.FileMessageReceiver.poll(FileMessageReceiver.java:117)
at org.mule.providers.PollingReceiverWorker.run(PollingReceiverWorker.java:47)
at org.mule.impl.work.WorkerContext.run(WorkerContext.java:310)
at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:643)
at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:668)
at java.lang.Thread.run(Thread.java:619)

********************************************************************************


 Description  « Hide
When using the GZipUncompressTransformer as in the configuration specified below to uncompress gzipped files it will throw a RoutingException with the following rootcause:

Exception stack is:
1. invalid stream header: 31203130 (java.io.StreamCorruptedException)

complaining about the fact that this stream cannot be deserialized. Reason is the fact that the returnClass of the GZipUncompressTransformer will default to java.lang.Object although specified otherwise in the GZipCompressTransformer constructor. So the following code in the GZipUncompressTransformer transform method will break because the returnClass is "java.lang.Object"

if (!getReturnClass().equals(byte[].class))

{ return SerializationUtils.deserialize(buffer); }

The reason why this returnClass defaults to java.lang.object is the fact that the mule-configuration.dtd specifies the following:

<!--
The returnClass attribute represents the full qualified class name
of the expected return Object of the Transformer implementation. if none is
specified java.lang.Object is used by default. However, by suppling a returnClass
the transformer can validate that the returnObject is of expected type before return
to the callee.
-->
<!ATTLIST transformer returnClass CDATA "java.lang.Object">

So the digester parses this one and overrides the original value.

changing this last line to

<!ATTLIST transformer returnClass CDATA #IMPLIED>

and putting this dtd earlier on the classpath than the one in mule-core fixed my problem.

The other way to do this should be by specifying the returnClass on the transformer, but I don't know how to set it to byte[]



 All   Comments   Work Log   Change History   Transitions   FishEye      Sort Order: Ascending order - Click to sort in descending order
Adriaan Wisse added a comment - 13/Dec/07 09:51 AM
This issue can be linked to MULE-1668 which complains about the same fact but isn't resolved because somebody didn't reply.

Holger Hoffstaette added a comment - 13/Dec/07 10:10 AM
While you were posting this I was commenting on MULE-1668
I had the same idea as you wrt. the #IMPLIED and gave it a quick try; it seems to do the trick and the transformer's own default value is not bungled, as tracing setReturnClass() showed. We still need to make sure this does not break anything else (run regression tests etc.) but changing the attribute in the DTD looks good so far.

Daniel Feist added a comment - 13/Dec/07 10:48 AM
No defaults in 2.0 schema at the moment:
<xsd:complexType name="abstractTransformerType">
    <xsd:attribute name="name" type="xsd:string"/>
    <xsd:attribute name="returnClass" type="substitutableClass"/>
    <xsd:attribute name="ignoreBadInput" type="substitutableBoolean"/>
</xsd:complexType>

If we did put defaults in, which we might do during documentation, it shouldn't be a problem because as each transformer has it's own xml element we have the flexibility to use different types and defaults for each one. But anyhow having said that this is a case where it's best not to have a default set in schema it would seem.


Holger Hoffstaette added a comment - 13/Dec/07 11:02 AM
Thanks DanF - looks like I can safely set the affects/fix-version to 1.4 only.

Holger Hoffstaette added a comment - 14/Dec/07 03:49 AM
Just setting the attribute to #IMPLIED and using a returnClass default in code causes failures, specifically with WireTap and the LoanBroker.

Adriaan Wisse added a comment - 14/Dec/07 04:32 AM
I first posted a comment on MULE-1668 but decided to open a new issue.
As you can see: It's always good to have regression tests! Good luck!


Holger Hoffstaette added a comment - 14/Dec/07 06:12 PM