diff --git a/java/external/src/org/xml/sax/helpers/XMLReaderFactory.java b/java/external/src/org/xml/sax/helpers/XMLReaderFactory.java index b3b75de..f297611 100644 --- a/java/external/src/org/xml/sax/helpers/XMLReaderFactory.java +++ b/java/external/src/org/xml/sax/helpers/XMLReaderFactory.java @@ -7,6 +7,7 @@ package org.xml.sax.helpers; import java.io.BufferedReader; +import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import org.xml.sax.XMLReader; @@ -59,6 +60,11 @@ final public class XMLReaderFactory private static final String property = "org.xml.sax.driver"; + /** + * Default columns per line. + */ + private static final int DEFAULT_LINE_LENGTH = 80; + /** * Attempt to create an XMLReader from system defaults. * In environments which can support it, the name of the XMLReader @@ -155,19 +161,27 @@ final public class XMLReaderFactory // jkesselm] BufferedReader rd; try { - rd = new BufferedReader(new InputStreamReader(is, "UTF-8")); + rd = new BufferedReader(new InputStreamReader(is, "UTF-8"), DEFAULT_LINE_LENGTH); } catch (java.io.UnsupportedEncodingException e) { - rd = new BufferedReader(new InputStreamReader(is)); + rd = new BufferedReader(new InputStreamReader(is), DEFAULT_LINE_LENGTH); } try { // XXX Does not handle all possible input as specified by the // Jar Service Provider specification className = rd.readLine(); - rd.close(); - } catch (Exception x) { + } + catch (Exception x) { // No provider found } + finally { + try { + // try to close the reader. + rd.close(); + } + // Ignore the exception. + catch (IOException exc) {} + } } }