You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by an...@locus.apache.org on 2000/01/26 01:26:44 UTC

cvs commit: xml-xerces/java/src/org/apache/xerces/utils ChunkyByteArray.java

andyc       00/01/25 16:26:44

  Modified:    java/src/org/apache/xerces/utils ChunkyByteArray.java
  Log:
  Fixed bug in ChunkyByteArray that was being manifested by
  parsing large UTF-16 files. The ChunkyByteArray holds
  character data for the readers. This data is stored in an
  array of chunks. No checks were in the code to resize the
  array of chunks when needed. Therefore, large files would
  expose this bug -- files larger than 64 * 16K.
  
  REVISIT: So this brings up the question about whether we
  need to hold onto *all* of the chunks in the byte array.
  It may be possible to reuse only one chunk. This should
  be looked at again after the upcoming release.
  
  Revision  Changes    Path
  1.2       +7 -0      xml-xerces/java/src/org/apache/xerces/utils/ChunkyByteArray.java
  
  Index: ChunkyByteArray.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/utils/ChunkyByteArray.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ChunkyByteArray.java	1999/11/09 01:12:14	1.1
  +++ ChunkyByteArray.java	2000/01/26 00:26:43	1.2
  @@ -169,6 +169,13 @@
               return fData[chunk][index];
           }
           catch (NullPointerException ex) {
  +            // ignore -- let fill create new chunk
  +        }
  +        catch (ArrayIndexOutOfBoundsException e) {
  +            // current chunk array is not big enough; resize
  +            byte newdata[][] = new byte[fData.length * 2][];
  +            System.arraycopy(fData, 0, newdata, 0, fData.length);
  +            fData = newdata;
           }
           if (index == 0) {
               fill();