rineholt 02/03/24 10:51:29 Modified: java/src/org/apache/axis SOAPPart.java java/src/org/apache/axis/attachments BoundaryDelimitedStream.java MultiPartRelatedInputStream.java java/src/org/apache/axis/utils resources.properties java/test/encoding AttributeBean.java TestAttributes.java Log: Hopefully fixed a problem with BoundaryDelmited stream that only happens on rare occasions. Also did some cleanup. Moved AttributeBean into package test.encoding I was getting a duplicate class error. Revision Changes Path 1.17 +2 -2 xml-axis/java/src/org/apache/axis/SOAPPart.java Index: SOAPPart.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/SOAPPart.java,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- SOAPPart.java 15 Mar 2002 01:14:09 -0000 1.16 +++ SOAPPart.java 24 Mar 2002 18:51:28 -0000 1.17 @@ -124,7 +124,7 @@ * The original message. Again, may be String, byte[], InputStream, * or SOAPEnvelope. */ - private Object originalMessage ; + // private Object originalMessage ; //free up reference this is not in use. /** * Do not call this directly! Should only be called by Message. @@ -134,7 +134,7 @@ public SOAPPart(Message parent, Object initialContents, boolean isBodyStream) { super(); msgObject=parent; - originalMessage = initialContents; + // originalMessage = initialContents; int form = FORM_STRING; if (initialContents instanceof SOAPEnvelope) { form = FORM_SOAPENVELOPE; 1.10 +89 -10 xml-axis/java/src/org/apache/axis/attachments/BoundaryDelimitedStream.java Index: BoundaryDelimitedStream.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/attachments/BoundaryDelimitedStream.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- BoundaryDelimitedStream.java 22 Mar 2002 15:29:51 -0000 1.9 +++ BoundaryDelimitedStream.java 24 Mar 2002 18:51:28 -0000 1.10 @@ -54,6 +54,8 @@ */ package org.apache.axis.attachments; +import java.lang.ref.WeakReference; + import org.apache.axis.utils.JavaUtils; @@ -123,7 +125,7 @@ */ protected BoundaryDelimitedStream(BoundaryDelimitedStream prev, int readbufsz ) { - super (prev.is); + super (null); streamNo= newStreamNo(); @@ -140,7 +142,7 @@ readBufPos = prev.readBufPos + boundaryBufLen; readBufEnd = prev.readBufEnd; //find the new boundary. - boundaryPos = boundaryPosition( readbuf, readBufPos, readBufEnd-1); + boundaryPos = boundaryPosition( readbuf, readBufPos, readBufEnd); prev.theEnd = theEnd; //The stream. } @@ -152,11 +154,12 @@ */ BoundaryDelimitedStream( java.io.InputStream is, byte[] boundary, int readbufsz) throws org.apache.axis.AxisFault { - super (is); + // super (is); + super(null); //we handle everything so this is not necessary, don't won't to hang on to a reference. isDebugEnabled= log.isDebugEnabled(); streamNo= newStreamNo(); closed = false; - this.is = is; + this.is = is; //Copy the boundary array to make certain it is never altered. this.boundary= new byte[boundary.length]; System.arraycopy(boundary,0,this.boundary,0, boundary.length); @@ -166,6 +169,22 @@ //Most mime boundaries are 40 bytes or so. this.readbufsz = Math.max( (boundaryBufLen) * 2, readbufsz); } + + private final int readFromStream( final byte[] b) throws java.io.IOException{ + return readFromStream(b, 0, b.length); + } + private final int readFromStream( final byte[] b, final int start, final int length) throws java.io.IOException{ + int minRead= Math.min(boundaryBufLen *2, length); + int br= 0; + int brTotal=0; + do + { + br= is.read(b, brTotal + start, length - brTotal); + if(br > 0) brTotal+= br; + }while(br > -1 && brTotal < minRead); + + return brTotal != 0? brTotal : br; + } /** * Read from the boundary delimited stream. @@ -185,8 +204,11 @@ if (readbuf == null) { //Allocate the buffer. readbuf = new byte[Math.max(len, readbufsz ) ]; - readBufEnd = is.read(readbuf); + readBufEnd = readFromStream(readbuf); if( readBufEnd < 0) { + readbuf= null; + closed= true; + theEnd = true; throw new java.io.IOException( JavaUtils.getMessage("eosBeforeMarker")); } @@ -221,9 +243,12 @@ //copy what was left over. System.arraycopy(readbuf, readBufPos, dstbuf, 0, movecnt); //Read in the new data. - int readcnt = is.read(dstbuf, movecnt, dstbuf.length - movecnt); + int readcnt = readFromStream(dstbuf, movecnt, dstbuf.length - movecnt); if( readcnt < 0) { + readbuf= null; + closed= true; + theEnd = true; throw new java.io.IOException( JavaUtils.getMessage("eosBeforeMarker")); } @@ -234,7 +259,7 @@ //just move the boundary by what we moved if (BOUNDARY_NOT_FOUND != boundaryPos ) boundaryPos -= movecnt; else boundaryPos = boundaryPosition( readbuf, readBufPos, - readBufEnd-1); //See if the boundary is now there. + readBufEnd); //See if the boundary is now there. } } @@ -250,6 +275,7 @@ {"" + bwritten, "" + streamNo, new String(tb)})); } } + if(eos && theEnd)readbuf= null; //dealloc even in Java. return bwritten; } @@ -296,13 +322,44 @@ } } + /** + * mark the stream. + * This is not supported. + */ + public void mark( int readlimit){ + //do nothing + } + + /** + * reset the stream. + * This is not supported. + */ + public void reset() throws java.io.IOException{ + throw new java.io.IOException(JavaUtils.getMessage("attach.bounday.mns")); + } + + /** + * markSupported + * return false; + */ + public boolean markSupported(){ + return false; + } + + public int available() throws java.io.IOException{ + int bcopy = readBufEnd - readBufPos - boundaryBufLen; + //never go past the boundary. + bcopy = Math.min(bcopy, boundaryPos - readBufPos); + return Math.max(0,bcopy); + } + /** * Read from the boundary delimited stream. * @return The position of the boundary. Detects the end of the source stream. * */ - int boundaryPosition( byte[] searchbuf, int start, int end) { + protected int boundaryPosition( byte[] searchbuf, int start, int end) { int foundAt = boundarySearch(searchbuf, start, end); //First find the boundary marker @@ -330,7 +387,8 @@ private int boundarySearch(final byte[]text,final int start, final int end ) { //log.debug(">>>>" + start + "," + end); - int i, j, k; + int i=0, j=0, k=0; + if(boundaryLen > (end - start)) return BOUNDARY_NOT_FOUND; if(null == skip){ skip= new int[256]; @@ -339,10 +397,31 @@ } - for( k=start + boundaryLen-1; k <=end; k += skip[text[k] & (0xff)] ) { + for( k=start + boundaryLen-1; k <end; k += skip[text[k] & (0xff)] ) { // log.debug(">>>>" + k); //printarry(text, k-boundaryLen+1, end); + try{ for( j=boundaryLen-1, i=k; j>=0 && text[i] == boundary[j]; j-- ) i--; + }catch(ArrayIndexOutOfBoundsException e){ + System. + err.println(">>>" +e); //rr temporary till a boundary issue is resolved. + System. + err.println("start=" +start); + System. + err.println("k=" +k); + System. + err.println("text.length=" + text.length ); + System. + err.println("i=" + i ); + System. + err.println("boundary.length=" + boundary.length ); + System. + err.println("j=" + j ); + System. + err.println("end=" + end ); + throw e; + + } if( j == (-1) ) return i+1; } 1.12 +3 -3 xml-axis/java/src/org/apache/axis/attachments/MultiPartRelatedInputStream.java Index: MultiPartRelatedInputStream.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/attachments/MultiPartRelatedInputStream.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- MultiPartRelatedInputStream.java 15 Mar 2002 01:14:10 -0000 1.11 +++ MultiPartRelatedInputStream.java 24 Mar 2002 18:51:28 -0000 1.12 @@ -83,7 +83,7 @@ protected int rootPartLength = 0; protected boolean closed = false; //If true the stream has been closed. protected boolean eos = false; //This is set once the SOAP packet has reached the end of stream. - protected java.io.InputStream is = null; //The orginal multipart/related stream. + // protected java.io.InputStream is = null; //The orginal multipart/related stream. //This stream controls and manages the boundary. protected org.apache.axis.attachments.BoundaryDelimitedStream boundaryDelimitedStream = null; protected java.io.InputStream soapStream = null; //Set the soap stream once found. @@ -100,9 +100,8 @@ * @param is the true input stream from where the source. */ public MultiPartRelatedInputStream ( String contentType, java.io.InputStream is) throws org.apache.axis.AxisFault { - super (is); + super (null); //don't cache this stream. try { - this.is = is; //First find the start and boundary parameters. There are real weird rules regard what // can be in real headers what needs to be escaped etc let mail parse it. javax.mail.internet.ContentType ct = new javax.mail.internet.ContentType(contentType); @@ -305,6 +304,7 @@ } //Now start searching for the data. + if(null!= boundaryDelimitedStream ) do { String contentType = null; String contentId = null; 1.84 +2 -0 xml-axis/java/src/org/apache/axis/utils/resources.properties Index: resources.properties =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/resources.properties,v retrieving revision 1.83 retrieving revision 1.84 diff -u -r1.83 -r1.84 --- resources.properties 22 Mar 2002 17:21:25 -0000 1.83 +++ resources.properties 24 Mar 2002 18:51:29 -0000 1.84 @@ -791,3 +791,5 @@ optionFactory00=name of the JavaWriterFactory class for extending Java generation functions optionHelper00=emits separate Helper classes for meta data + +attach.bounday.mns=Marking streams not supported. 1.3 +2 -0 xml-axis/java/test/encoding/AttributeBean.java Index: AttributeBean.java =================================================================== RCS file: /home/cvs/xml-axis/java/test/encoding/AttributeBean.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- AttributeBean.java 8 Mar 2002 05:04:54 -0000 1.2 +++ AttributeBean.java 24 Mar 2002 18:51:29 -0000 1.3 @@ -53,6 +53,8 @@ * <http://www.apache.org/>. */ +package test.encoding; + import org.apache.axis.description.AttributeDesc; import org.apache.axis.description.ElementDesc; import org.apache.axis.description.FieldDesc; 1.3 +0 -1 xml-axis/java/test/encoding/TestAttributes.java Index: TestAttributes.java =================================================================== RCS file: /home/cvs/xml-axis/java/test/encoding/TestAttributes.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- TestAttributes.java 8 Mar 2002 05:04:54 -0000 1.2 +++ TestAttributes.java 24 Mar 2002 18:51:29 -0000 1.3 @@ -35,7 +35,6 @@ import java.io.Writer; import java.util.Vector; -import AttributeBean; /** * Test the serialization of a bean with attributes