[ http://issues.apache.org/jira/browse/AXIS-2084?page=all ]

Brian Husted updated AXIS-2084:
-------------------------------

    Attachment: EchoAttachment.java

Davanum, 

As requested, I have hacked the samples.attachments.EchoAttachments.  I changed 
the main method to use DIME only and changed the echo method to use the 
DynamicContentDataHandler with a chunk size of 1k.   To recreate, you will need 
to invoke the main method passing in a full file path to a local file that is 
larger than 1k.  
Below is the stack trace I am getting.  Let me know if there is anything else I 
can do.  I will try and debug this as well. 

I tested with Axis 1.2.1client and server running jdk1.4.2_05 and Tomcat 5.0 
for server.

Caused by: java.io.IOException: End of physical stream detected when more DIME 
chunks expected.
        at 
org.apache.axis.attachments.DimeDelimitedInputStream._read(DimeDelimitedInputStream.java:268)
        at 
org.apache.axis.attachments.DimeDelimitedInputStream.read(DimeDelimitedInputStream.java:201)
        at 
org.apache.axis.attachments.DimeDelimitedInputStream.read(DimeDelimitedInputStream.java:445)
        at 
org.apache.axis.attachments.ManagedMemoryDataSource.<init>(ManagedMemoryDataSource.java:146)
        at 
org.apache.axis.attachments.MultiPartDimeInputStream.readTillFound(MultiPartDimeInputStream.java:163)
        ... 46 more
        at 
org.apache.axis.encoding.DeserializationContext.getObjectByRef(DeserializationContext.java:619)
        at 
org.apache.axis.encoding.ser.JAFDataHandlerDeserializer.startElement(JAFDataHandlerDeserializer.java:70)
        at 
org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1048)
        at 
org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:165)
        at 
org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:1141)
        at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:236)
        at org.apache.axis.message.RPCElement.getParams(RPCElement.java:384)
        at 
org.apache.axis.providers.java.RPCProvider.processMessage(RPCProvider.java:148)
        at 
org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:323)
        ... 33 more

> Dime attachements: Type_Length of the final record chunk must be zero
> ---------------------------------------------------------------------
>
>          Key: AXIS-2084
>          URL: http://issues.apache.org/jira/browse/AXIS-2084
>      Project: Apache Axis
>         Type: Bug
>   Components: Serialization/Deserialization
>     Versions: 1.2, 1.2.1
>  Environment: Microsoft XP
>     Reporter: Coralia Silvana Popa
>  Attachments: EchoAttachment.java
>
> Large files sent as DIME attachments are not correct serialized. Seems that 
> the 
> When reading a series of chunked records, the parser assumes that the first 
> record without the CF flag is the final record in the chunk; in this case, 
> it's the last record in my sample. The record type is specified only in the 
> first record chunk, and all remaining chunks must have the TYPE_T field and 
> all remaining header fields (except for the DATA_LENGTH field) set to zero.
> Seems that Type_Length (and maybe other header fields) is not set to 0 for 
> the last chunk. The code work correct when there is only one chunck.
> The problem is in class: org.apache.axis.attachments.DimeBodyPart, in method 
> void send(java.io.OutputStream os, byte position, DynamicContentDataHandler 
> dh, final long maxchunk)
> I suggest the following code the fix this problem:
> void send(java.io.OutputStream os, byte position, DynamicContentDataHandler 
> dh,
>             final long maxchunk)
>             throws java.io.IOException {
>       
>               BufferedInputStream in = new 
> BufferedInputStream(dh.getInputStream());
>               
>               final int myChunkSize = dh.getChunkSize();
>               
>               byte[] buffer1 = new byte[myChunkSize]; 
>               byte[] buffer2 = new byte[myChunkSize]; 
>               
>               int bytesRead1 = 0 , bytesRead2 = 0;
>               bytesRead1 = in.read(buffer1);
>               
>               if(bytesRead1 < 0) {
>                 sendHeader(os, position, 0, (byte) 0);
>                 os.write(pad, 0, dimePadding(0));
>                 return;
>               }
>               byte chunknext = 0;
>               do {
>                       bytesRead2 = in.read(buffer2);
>                       
>                       if(bytesRead2 < 0) {
>                               //last record...do not set the chunk bit.
>                               //buffer1 contains the last chunked record!
>                               sendChunk(os, position, buffer1, 0, bytesRead1, 
> chunknext);
>                               break;
>                       }
>                       
>                       sendChunk(os, position, buffer1, 0, bytesRead1,(byte) 
> (CHUNK | chunknext) );
>                       chunknext = CHUNK_NEXT;
>                       //now that we have written out buffer1, copy buffer2 
> into to buffer1
>                       System.arraycopy(buffer2,0,buffer1,0,myChunkSize);
>                       bytesRead1 = bytesRead2;
>                       
>               }while(bytesRead2 > 0);
>     }

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

Reply via email to