Changeset 6000 for branches/4.1


Ignore:
Timestamp:
03/08/10 13:40:18 (10 years ago)
Author:
melissa
Message:

Adjusted XMLTools.parseXML implementations so that a new byte array is not allocated if we call parseXML(RandomAccessInputStream). This should fix the memory issues mentioned here:  https://trac.openmicroscopy.org.uk/omero/ticket/1832.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/4.1/components/common/src/loci/common/XMLTools.java

    r5533 r6000  
    260260    DefaultHandler handler) throws IOException 
    261261  { 
    262     byte[] b = new byte[(int) (stream.length() - stream.getFilePointer())]; 
    263     stream.readFully(b); 
    264     parseXML(b, handler); 
    265     b = null; 
    266   } 
    267  
    268   /** 
    269    * Parses the XML string from the given byte array into 
    270    * a list of key/value pairs using the specified XML handler. 
    271    */ 
    272   public static void parseXML(byte[] xml, DefaultHandler handler) 
    273     throws IOException 
    274   { 
    275262    try { 
    276263      SAXParser parser = SAX_FACTORY.newSAXParser(); 
    277       parser.parse(new ByteArrayInputStream(xml), handler); 
     264      parser.parse(stream, handler); 
    278265    } 
    279266    catch (ParserConfigurationException exc) { 
     
    286273      e.initCause(exc); 
    287274      throw e; 
    288  
    289     } 
     275    } 
     276  } 
     277 
     278  /** 
     279   * Parses the XML string from the given byte array into 
     280   * a list of key/value pairs using the specified XML handler. 
     281   */ 
     282  public static void parseXML(byte[] xml, DefaultHandler handler) 
     283    throws IOException 
     284  { 
     285    parseXML(new RandomAccessInputStream(xml), handler); 
    290286  } 
    291287 
Note: See TracChangeset for help on using the changeset viewer.