mcnamara 2004/08/17 09:34:21
Modified: java/src/org/apache/xalan/extensions ObjectFactory.java
java/src/org/apache/xalan/lib ObjectFactory.java
java/src/org/apache/xalan/lib/sql ObjectFactory.java
java/src/org/apache/xalan/xslt ObjectFactory.java
java/src/org/apache/xalan/xsltc/cmdline ObjectFactory.java
java/src/org/apache/xalan/xsltc/compiler ObjectFactory.java
java/src/org/apache/xalan/xsltc/compiler/util
ObjectFactory.java
java/src/org/apache/xalan/xsltc/dom ObjectFactory.java
java/src/org/apache/xalan/xsltc/runtime ObjectFactory.java
java/src/org/apache/xalan/xsltc/trax ObjectFactory.java
java/src/org/apache/xml/dtm ObjectFactory.java
java/src/org/apache/xml/dtm/ref ObjectFactory.java
java/src/org/apache/xml/serializer ObjectFactory.java
java/src/org/apache/xml/utils ObjectFactory.java
java/src/org/apache/xpath/compiler ObjectFactory.java
java/src/org/apache/xpath/functions ObjectFactory.java
Log:
Fixing a potential memory leak. The reader used to read the service provider
is never closed if an IOException is thrown while reading from it. Adding a
finally block so that the reader will always be closed. Patch reviewed by
Christine Li.
Revision Changes Path
1.4 +41 -16
xml-xalan/java/src/org/apache/xalan/extensions/ObjectFactory.java
Index: ObjectFactory.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/extensions/ObjectFactory.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ObjectFactory.java 11 Mar 2004 21:02:11 -0000 1.3
+++ ObjectFactory.java 17 Aug 2004 16:34:19 -0000 1.4
@@ -291,6 +291,7 @@
synchronized (ObjectFactory.class) {
boolean loadProperties = false;
+ FileInputStream fis = null;
try {
// file existed last time
if(fLastModified >= 0) {
@@ -315,35 +316,52 @@
// must never have attempted to read xalan.properties
// before (or it's outdeated)
fXalanProperties = new Properties();
- FileInputStream fis =
-
ss.getFileInputStream(propertiesFile);
+ fis = ss.getFileInputStream(propertiesFile);
fXalanProperties.load(fis);
- fis.close();
}
- } catch (Exception x) {
- fXalanProperties = null;
- fLastModified = -1;
- // assert(x instanceof FileNotFoundException
- // || x instanceof SecurityException)
- // In both cases, ignore and continue w/ next location
- }
+ } catch (Exception x) {
+ fXalanProperties = null;
+ fLastModified = -1;
+ // assert(x instanceof FileNotFoundException
+ // || x instanceof SecurityException)
+ // In both cases, ignore and continue w/ next location
+ }
+ finally {
+ // try to close the input stream if one was opened.
+ if (fis != null) {
+ try {
+ fis.close();
+ }
+ // Ignore the exception.
+ catch (IOException exc) {}
+ }
+ }
}
if(fXalanProperties != null) {
factoryClassName = fXalanProperties.getProperty(factoryId);
}
} else {
+ FileInputStream fis = null;
try {
- FileInputStream fis =
- ss.getFileInputStream(new
File(propertiesFilename));
+ fis = ss.getFileInputStream(new File(propertiesFilename));
Properties props = new Properties();
props.load(fis);
- fis.close();
factoryClassName = props.getProperty(factoryId);
} catch (Exception x) {
// assert(x instanceof FileNotFoundException
// || x instanceof SecurityException)
// In both cases, ignore and continue w/ next location
}
+ finally {
+ // try to close the input stream if one was opened.
+ if (fis != null) {
+ try {
+ fis.close();
+ }
+ // Ignore the exception.
+ catch (IOException exc) {}
+ }
+ }
}
if (factoryClassName != null) {
debugPrintln("found in " + propertiesFilename + ", value="
@@ -568,11 +586,18 @@
// XXX Does not handle all possible input as specified by the
// Jar Service Provider specification
factoryClassName = rd.readLine();
- rd.close();
} catch (IOException x) {
// No provider found
return null;
}
+ finally {
+ try {
+ // try to close the reader.
+ rd.close();
+ }
+ // Ignore the exception.
+ catch (IOException exc) {}
+ }
if (factoryClassName != null &&
! "".equals(factoryClassName)) {
1.4 +42 -17
xml-xalan/java/src/org/apache/xalan/lib/ObjectFactory.java
Index: ObjectFactory.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/lib/ObjectFactory.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ObjectFactory.java 11 Mar 2004 21:02:12 -0000 1.3
+++ ObjectFactory.java 17 Aug 2004 16:34:19 -0000 1.4
@@ -291,6 +291,7 @@
synchronized (ObjectFactory.class) {
boolean loadProperties = false;
+ FileInputStream fis = null;
try {
// file existed last time
if(fLastModified >= 0) {
@@ -315,35 +316,52 @@
// must never have attempted to read xalan.properties
// before (or it's outdeated)
fXalanProperties = new Properties();
- FileInputStream fis =
-
ss.getFileInputStream(propertiesFile);
+ fis = ss.getFileInputStream(propertiesFile);
fXalanProperties.load(fis);
- fis.close();
}
- } catch (Exception x) {
- fXalanProperties = null;
- fLastModified = -1;
- // assert(x instanceof FileNotFoundException
- // || x instanceof SecurityException)
- // In both cases, ignore and continue w/ next location
- }
+ } catch (Exception x) {
+ fXalanProperties = null;
+ fLastModified = -1;
+ // assert(x instanceof FileNotFoundException
+ // || x instanceof SecurityException)
+ // In both cases, ignore and continue w/ next location
+ }
+ finally {
+ // try to close the input stream if one was opened.
+ if (fis != null) {
+ try {
+ fis.close();
+ }
+ // Ignore the exception.
+ catch (IOException exc) {}
+ }
+ }
}
if(fXalanProperties != null) {
factoryClassName = fXalanProperties.getProperty(factoryId);
}
} else {
+ FileInputStream fis = null;
try {
- FileInputStream fis =
- ss.getFileInputStream(new
File(propertiesFilename));
+ fis = ss.getFileInputStream(new File(propertiesFilename));
Properties props = new Properties();
props.load(fis);
- fis.close();
factoryClassName = props.getProperty(factoryId);
} catch (Exception x) {
// assert(x instanceof FileNotFoundException
// || x instanceof SecurityException)
// In both cases, ignore and continue w/ next location
}
+ finally {
+ // try to close the input stream if one was opened.
+ if (fis != null) {
+ try {
+ fis.close();
+ }
+ // Ignore the exception.
+ catch (IOException exc) {}
+ }
+ }
}
if (factoryClassName != null) {
debugPrintln("found in " + propertiesFilename + ", value="
@@ -466,7 +484,7 @@
String packageName = className;
if (lastDot != -1) packageName = className.substring(0,
lastDot);
security.checkPackageAccess(packageName);
- }
+ }
}catch(SecurityException e){
throw e;
}
@@ -568,11 +586,18 @@
// XXX Does not handle all possible input as specified by the
// Jar Service Provider specification
factoryClassName = rd.readLine();
- rd.close();
} catch (IOException x) {
// No provider found
return null;
}
+ finally {
+ try {
+ // try to close the reader.
+ rd.close();
+ }
+ // Ignore the exception.
+ catch (IOException exc) {}
+ }
if (factoryClassName != null &&
! "".equals(factoryClassName)) {
1.4 +41 -16
xml-xalan/java/src/org/apache/xalan/lib/sql/ObjectFactory.java
Index: ObjectFactory.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/lib/sql/ObjectFactory.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ObjectFactory.java 11 Mar 2004 21:02:12 -0000 1.3
+++ ObjectFactory.java 17 Aug 2004 16:34:19 -0000 1.4
@@ -291,6 +291,7 @@
synchronized (ObjectFactory.class) {
boolean loadProperties = false;
+ FileInputStream fis = null;
try {
// file existed last time
if(fLastModified >= 0) {
@@ -315,35 +316,52 @@
// must never have attempted to read xalan.properties
// before (or it's outdeated)
fXalanProperties = new Properties();
- FileInputStream fis =
-
ss.getFileInputStream(propertiesFile);
+ fis = ss.getFileInputStream(propertiesFile);
fXalanProperties.load(fis);
- fis.close();
}
- } catch (Exception x) {
- fXalanProperties = null;
- fLastModified = -1;
- // assert(x instanceof FileNotFoundException
- // || x instanceof SecurityException)
- // In both cases, ignore and continue w/ next location
- }
+ } catch (Exception x) {
+ fXalanProperties = null;
+ fLastModified = -1;
+ // assert(x instanceof FileNotFoundException
+ // || x instanceof SecurityException)
+ // In both cases, ignore and continue w/ next location
+ }
+ finally {
+ // try to close the input stream if one was opened.
+ if (fis != null) {
+ try {
+ fis.close();
+ }
+ // Ignore the exception.
+ catch (IOException exc) {}
+ }
+ }
}
if(fXalanProperties != null) {
factoryClassName = fXalanProperties.getProperty(factoryId);
}
} else {
+ FileInputStream fis = null;
try {
- FileInputStream fis =
- ss.getFileInputStream(new
File(propertiesFilename));
+ fis = ss.getFileInputStream(new File(propertiesFilename));
Properties props = new Properties();
props.load(fis);
- fis.close();
factoryClassName = props.getProperty(factoryId);
} catch (Exception x) {
// assert(x instanceof FileNotFoundException
// || x instanceof SecurityException)
// In both cases, ignore and continue w/ next location
}
+ finally {
+ // try to close the input stream if one was opened.
+ if (fis != null) {
+ try {
+ fis.close();
+ }
+ // Ignore the exception.
+ catch (IOException exc) {}
+ }
+ }
}
if (factoryClassName != null) {
debugPrintln("found in " + propertiesFilename + ", value="
@@ -568,11 +586,18 @@
// XXX Does not handle all possible input as specified by the
// Jar Service Provider specification
factoryClassName = rd.readLine();
- rd.close();
} catch (IOException x) {
// No provider found
return null;
}
+ finally {
+ try {
+ // try to close the reader.
+ rd.close();
+ }
+ // Ignore the exception.
+ catch (IOException exc) {}
+ }
if (factoryClassName != null &&
! "".equals(factoryClassName)) {
1.4 +42 -17
xml-xalan/java/src/org/apache/xalan/xslt/ObjectFactory.java
Index: ObjectFactory.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xslt/ObjectFactory.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ObjectFactory.java 11 Mar 2004 21:02:12 -0000 1.3
+++ ObjectFactory.java 17 Aug 2004 16:34:19 -0000 1.4
@@ -291,6 +291,7 @@
synchronized (ObjectFactory.class) {
boolean loadProperties = false;
+ FileInputStream fis = null;
try {
// file existed last time
if(fLastModified >= 0) {
@@ -315,35 +316,52 @@
// must never have attempted to read xalan.properties
// before (or it's outdeated)
fXalanProperties = new Properties();
- FileInputStream fis =
-
ss.getFileInputStream(propertiesFile);
+ fis = ss.getFileInputStream(propertiesFile);
fXalanProperties.load(fis);
- fis.close();
}
- } catch (Exception x) {
- fXalanProperties = null;
- fLastModified = -1;
- // assert(x instanceof FileNotFoundException
- // || x instanceof SecurityException)
- // In both cases, ignore and continue w/ next location
- }
+ } catch (Exception x) {
+ fXalanProperties = null;
+ fLastModified = -1;
+ // assert(x instanceof FileNotFoundException
+ // || x instanceof SecurityException)
+ // In both cases, ignore and continue w/ next location
+ }
+ finally {
+ // try to close the input stream if one was opened.
+ if (fis != null) {
+ try {
+ fis.close();
+ }
+ // Ignore the exception.
+ catch (IOException exc) {}
+ }
+ }
}
if(fXalanProperties != null) {
factoryClassName = fXalanProperties.getProperty(factoryId);
}
} else {
+ FileInputStream fis = null;
try {
- FileInputStream fis =
- ss.getFileInputStream(new
File(propertiesFilename));
+ fis = ss.getFileInputStream(new File(propertiesFilename));
Properties props = new Properties();
props.load(fis);
- fis.close();
factoryClassName = props.getProperty(factoryId);
} catch (Exception x) {
// assert(x instanceof FileNotFoundException
// || x instanceof SecurityException)
// In both cases, ignore and continue w/ next location
}
+ finally {
+ // try to close the input stream if one was opened.
+ if (fis != null) {
+ try {
+ fis.close();
+ }
+ // Ignore the exception.
+ catch (IOException exc) {}
+ }
+ }
}
if (factoryClassName != null) {
debugPrintln("found in " + propertiesFilename + ", value="
@@ -466,7 +484,7 @@
String packageName = className;
if (lastDot != -1) packageName = className.substring(0,
lastDot);
security.checkPackageAccess(packageName);
- }
+ }
}catch(SecurityException e){
throw e;
}
@@ -568,11 +586,18 @@
// XXX Does not handle all possible input as specified by the
// Jar Service Provider specification
factoryClassName = rd.readLine();
- rd.close();
} catch (IOException x) {
// No provider found
return null;
}
+ finally {
+ try {
+ // try to close the reader.
+ rd.close();
+ }
+ // Ignore the exception.
+ catch (IOException exc) {}
+ }
if (factoryClassName != null &&
! "".equals(factoryClassName)) {
1.4 +41 -16
xml-xalan/java/src/org/apache/xalan/xsltc/cmdline/ObjectFactory.java
Index: ObjectFactory.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/cmdline/ObjectFactory.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ObjectFactory.java 11 Mar 2004 21:02:12 -0000 1.3
+++ ObjectFactory.java 17 Aug 2004 16:34:19 -0000 1.4
@@ -291,6 +291,7 @@
synchronized (ObjectFactory.class) {
boolean loadProperties = false;
+ FileInputStream fis = null;
try {
// file existed last time
if(fLastModified >= 0) {
@@ -315,35 +316,52 @@
// must never have attempted to read xalan.properties
// before (or it's outdeated)
fXalanProperties = new Properties();
- FileInputStream fis =
-
ss.getFileInputStream(propertiesFile);
+ fis = ss.getFileInputStream(propertiesFile);
fXalanProperties.load(fis);
- fis.close();
}
- } catch (Exception x) {
- fXalanProperties = null;
- fLastModified = -1;
- // assert(x instanceof FileNotFoundException
- // || x instanceof SecurityException)
- // In both cases, ignore and continue w/ next location
- }
+ } catch (Exception x) {
+ fXalanProperties = null;
+ fLastModified = -1;
+ // assert(x instanceof FileNotFoundException
+ // || x instanceof SecurityException)
+ // In both cases, ignore and continue w/ next location
+ }
+ finally {
+ // try to close the input stream if one was opened.
+ if (fis != null) {
+ try {
+ fis.close();
+ }
+ // Ignore the exception.
+ catch (IOException exc) {}
+ }
+ }
}
if(fXalanProperties != null) {
factoryClassName = fXalanProperties.getProperty(factoryId);
}
} else {
+ FileInputStream fis = null;
try {
- FileInputStream fis =
- ss.getFileInputStream(new
File(propertiesFilename));
+ fis = ss.getFileInputStream(new File(propertiesFilename));
Properties props = new Properties();
props.load(fis);
- fis.close();
factoryClassName = props.getProperty(factoryId);
} catch (Exception x) {
// assert(x instanceof FileNotFoundException
// || x instanceof SecurityException)
// In both cases, ignore and continue w/ next location
}
+ finally {
+ // try to close the input stream if one was opened.
+ if (fis != null) {
+ try {
+ fis.close();
+ }
+ // Ignore the exception.
+ catch (IOException exc) {}
+ }
+ }
}
if (factoryClassName != null) {
debugPrintln("found in " + propertiesFilename + ", value="
@@ -568,11 +586,18 @@
// XXX Does not handle all possible input as specified by the
// Jar Service Provider specification
factoryClassName = rd.readLine();
- rd.close();
} catch (IOException x) {
// No provider found
return null;
}
+ finally {
+ try {
+ // try to close the reader.
+ rd.close();
+ }
+ // Ignore the exception.
+ catch (IOException exc) {}
+ }
if (factoryClassName != null &&
! "".equals(factoryClassName)) {
1.4 +42 -17
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/ObjectFactory.java
Index: ObjectFactory.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/ObjectFactory.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ObjectFactory.java 11 Mar 2004 21:02:12 -0000 1.3
+++ ObjectFactory.java 17 Aug 2004 16:34:19 -0000 1.4
@@ -291,6 +291,7 @@
synchronized (ObjectFactory.class) {
boolean loadProperties = false;
+ FileInputStream fis = null;
try {
// file existed last time
if(fLastModified >= 0) {
@@ -315,35 +316,52 @@
// must never have attempted to read xalan.properties
// before (or it's outdeated)
fXalanProperties = new Properties();
- FileInputStream fis =
-
ss.getFileInputStream(propertiesFile);
+ fis = ss.getFileInputStream(propertiesFile);
fXalanProperties.load(fis);
- fis.close();
}
- } catch (Exception x) {
- fXalanProperties = null;
- fLastModified = -1;
- // assert(x instanceof FileNotFoundException
- // || x instanceof SecurityException)
- // In both cases, ignore and continue w/ next location
- }
+ } catch (Exception x) {
+ fXalanProperties = null;
+ fLastModified = -1;
+ // assert(x instanceof FileNotFoundException
+ // || x instanceof SecurityException)
+ // In both cases, ignore and continue w/ next location
+ }
+ finally {
+ // try to close the input stream if one was opened.
+ if (fis != null) {
+ try {
+ fis.close();
+ }
+ // Ignore the exception.
+ catch (IOException exc) {}
+ }
+ }
}
if(fXalanProperties != null) {
factoryClassName = fXalanProperties.getProperty(factoryId);
}
} else {
+ FileInputStream fis = null;
try {
- FileInputStream fis =
- ss.getFileInputStream(new
File(propertiesFilename));
+ fis = ss.getFileInputStream(new File(propertiesFilename));
Properties props = new Properties();
props.load(fis);
- fis.close();
factoryClassName = props.getProperty(factoryId);
} catch (Exception x) {
// assert(x instanceof FileNotFoundException
// || x instanceof SecurityException)
// In both cases, ignore and continue w/ next location
}
+ finally {
+ // try to close the input stream if one was opened.
+ if (fis != null) {
+ try {
+ fis.close();
+ }
+ // Ignore the exception.
+ catch (IOException exc) {}
+ }
+ }
}
if (factoryClassName != null) {
debugPrintln("found in " + propertiesFilename + ", value="
@@ -466,7 +484,7 @@
String packageName = className;
if (lastDot != -1) packageName = className.substring(0,
lastDot);
security.checkPackageAccess(packageName);
- }
+ }
}catch(SecurityException e){
throw e;
}
@@ -568,11 +586,18 @@
// XXX Does not handle all possible input as specified by the
// Jar Service Provider specification
factoryClassName = rd.readLine();
- rd.close();
} catch (IOException x) {
// No provider found
return null;
}
+ finally {
+ try {
+ // try to close the reader.
+ rd.close();
+ }
+ // Ignore the exception.
+ catch (IOException exc) {}
+ }
if (factoryClassName != null &&
! "".equals(factoryClassName)) {
1.4 +41 -16
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/ObjectFactory.java
Index: ObjectFactory.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/ObjectFactory.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ObjectFactory.java 11 Mar 2004 21:02:12 -0000 1.3
+++ ObjectFactory.java 17 Aug 2004 16:34:19 -0000 1.4
@@ -291,6 +291,7 @@
synchronized (ObjectFactory.class) {
boolean loadProperties = false;
+ FileInputStream fis = null;
try {
// file existed last time
if(fLastModified >= 0) {
@@ -315,35 +316,52 @@
// must never have attempted to read xalan.properties
// before (or it's outdeated)
fXalanProperties = new Properties();
- FileInputStream fis =
-
ss.getFileInputStream(propertiesFile);
+ fis = ss.getFileInputStream(propertiesFile);
fXalanProperties.load(fis);
- fis.close();
}
- } catch (Exception x) {
- fXalanProperties = null;
- fLastModified = -1;
- // assert(x instanceof FileNotFoundException
- // || x instanceof SecurityException)
- // In both cases, ignore and continue w/ next location
- }
+ } catch (Exception x) {
+ fXalanProperties = null;
+ fLastModified = -1;
+ // assert(x instanceof FileNotFoundException
+ // || x instanceof SecurityException)
+ // In both cases, ignore and continue w/ next location
+ }
+ finally {
+ // try to close the input stream if one was opened.
+ if (fis != null) {
+ try {
+ fis.close();
+ }
+ // Ignore the exception.
+ catch (IOException exc) {}
+ }
+ }
}
if(fXalanProperties != null) {
factoryClassName = fXalanProperties.getProperty(factoryId);
}
} else {
+ FileInputStream fis = null;
try {
- FileInputStream fis =
- ss.getFileInputStream(new
File(propertiesFilename));
+ fis = ss.getFileInputStream(new File(propertiesFilename));
Properties props = new Properties();
props.load(fis);
- fis.close();
factoryClassName = props.getProperty(factoryId);
} catch (Exception x) {
// assert(x instanceof FileNotFoundException
// || x instanceof SecurityException)
// In both cases, ignore and continue w/ next location
}
+ finally {
+ // try to close the input stream if one was opened.
+ if (fis != null) {
+ try {
+ fis.close();
+ }
+ // Ignore the exception.
+ catch (IOException exc) {}
+ }
+ }
}
if (factoryClassName != null) {
debugPrintln("found in " + propertiesFilename + ", value="
@@ -568,11 +586,18 @@
// XXX Does not handle all possible input as specified by the
// Jar Service Provider specification
factoryClassName = rd.readLine();
- rd.close();
} catch (IOException x) {
// No provider found
return null;
}
+ finally {
+ try {
+ // try to close the reader.
+ rd.close();
+ }
+ // Ignore the exception.
+ catch (IOException exc) {}
+ }
if (factoryClassName != null &&
! "".equals(factoryClassName)) {
1.4 +42 -17
xml-xalan/java/src/org/apache/xalan/xsltc/dom/ObjectFactory.java
Index: ObjectFactory.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/ObjectFactory.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ObjectFactory.java 11 Mar 2004 21:02:12 -0000 1.3
+++ ObjectFactory.java 17 Aug 2004 16:34:20 -0000 1.4
@@ -291,6 +291,7 @@
synchronized (ObjectFactory.class) {
boolean loadProperties = false;
+ FileInputStream fis = null;
try {
// file existed last time
if(fLastModified >= 0) {
@@ -315,35 +316,52 @@
// must never have attempted to read xalan.properties
// before (or it's outdeated)
fXalanProperties = new Properties();
- FileInputStream fis =
-
ss.getFileInputStream(propertiesFile);
+ fis = ss.getFileInputStream(propertiesFile);
fXalanProperties.load(fis);
- fis.close();
}
- } catch (Exception x) {
- fXalanProperties = null;
- fLastModified = -1;
- // assert(x instanceof FileNotFoundException
- // || x instanceof SecurityException)
- // In both cases, ignore and continue w/ next location
- }
+ } catch (Exception x) {
+ fXalanProperties = null;
+ fLastModified = -1;
+ // assert(x instanceof FileNotFoundException
+ // || x instanceof SecurityException)
+ // In both cases, ignore and continue w/ next location
+ }
+ finally {
+ // try to close the input stream if one was opened.
+ if (fis != null) {
+ try {
+ fis.close();
+ }
+ // Ignore the exception.
+ catch (IOException exc) {}
+ }
+ }
}
if(fXalanProperties != null) {
factoryClassName = fXalanProperties.getProperty(factoryId);
}
} else {
+ FileInputStream fis = null;
try {
- FileInputStream fis =
- ss.getFileInputStream(new
File(propertiesFilename));
+ fis = ss.getFileInputStream(new File(propertiesFilename));
Properties props = new Properties();
props.load(fis);
- fis.close();
factoryClassName = props.getProperty(factoryId);
} catch (Exception x) {
// assert(x instanceof FileNotFoundException
// || x instanceof SecurityException)
// In both cases, ignore and continue w/ next location
}
+ finally {
+ // try to close the input stream if one was opened.
+ if (fis != null) {
+ try {
+ fis.close();
+ }
+ // Ignore the exception.
+ catch (IOException exc) {}
+ }
+ }
}
if (factoryClassName != null) {
debugPrintln("found in " + propertiesFilename + ", value="
@@ -466,7 +484,7 @@
String packageName = className;
if (lastDot != -1) packageName = className.substring(0,
lastDot);
security.checkPackageAccess(packageName);
- }
+ }
}catch(SecurityException e){
throw e;
}
@@ -568,11 +586,18 @@
// XXX Does not handle all possible input as specified by the
// Jar Service Provider specification
factoryClassName = rd.readLine();
- rd.close();
} catch (IOException x) {
// No provider found
return null;
}
+ finally {
+ try {
+ // try to close the reader.
+ rd.close();
+ }
+ // Ignore the exception.
+ catch (IOException exc) {}
+ }
if (factoryClassName != null &&
! "".equals(factoryClassName)) {
1.3 +41 -16
xml-xalan/java/src/org/apache/xalan/xsltc/runtime/ObjectFactory.java
Index: ObjectFactory.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/runtime/ObjectFactory.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ObjectFactory.java 11 Mar 2004 21:02:12 -0000 1.2
+++ ObjectFactory.java 17 Aug 2004 16:34:20 -0000 1.3
@@ -291,6 +291,7 @@
synchronized (ObjectFactory.class) {
boolean loadProperties = false;
+ FileInputStream fis = null;
try {
// file existed last time
if(fLastModified >= 0) {
@@ -315,35 +316,52 @@
// must never have attempted to read xalan.properties
// before (or it's outdeated)
fXalanProperties = new Properties();
- FileInputStream fis =
-
ss.getFileInputStream(propertiesFile);
+ fis = ss.getFileInputStream(propertiesFile);
fXalanProperties.load(fis);
- fis.close();
}
- } catch (Exception x) {
- fXalanProperties = null;
- fLastModified = -1;
- // assert(x instanceof FileNotFoundException
- // || x instanceof SecurityException)
- // In both cases, ignore and continue w/ next location
- }
+ } catch (Exception x) {
+ fXalanProperties = null;
+ fLastModified = -1;
+ // assert(x instanceof FileNotFoundException
+ // || x instanceof SecurityException)
+ // In both cases, ignore and continue w/ next location
+ }
+ finally {
+ // try to close the input stream if one was opened.
+ if (fis != null) {
+ try {
+ fis.close();
+ }
+ // Ignore the exception.
+ catch (IOException exc) {}
+ }
+ }
}
if(fXalanProperties != null) {
factoryClassName = fXalanProperties.getProperty(factoryId);
}
} else {
+ FileInputStream fis = null;
try {
- FileInputStream fis =
- ss.getFileInputStream(new
File(propertiesFilename));
+ fis = ss.getFileInputStream(new File(propertiesFilename));
Properties props = new Properties();
props.load(fis);
- fis.close();
factoryClassName = props.getProperty(factoryId);
} catch (Exception x) {
// assert(x instanceof FileNotFoundException
// || x instanceof SecurityException)
// In both cases, ignore and continue w/ next location
}
+ finally {
+ // try to close the input stream if one was opened.
+ if (fis != null) {
+ try {
+ fis.close();
+ }
+ // Ignore the exception.
+ catch (IOException exc) {}
+ }
+ }
}
if (factoryClassName != null) {
debugPrintln("found in " + propertiesFilename + ", value="
@@ -568,11 +586,18 @@
// XXX Does not handle all possible input as specified by the
// Jar Service Provider specification
factoryClassName = rd.readLine();
- rd.close();
} catch (IOException x) {
// No provider found
return null;
}
+ finally {
+ try {
+ // try to close the reader.
+ rd.close();
+ }
+ // Ignore the exception.
+ catch (IOException exc) {}
+ }
if (factoryClassName != null &&
! "".equals(factoryClassName)) {
1.4 +42 -17
xml-xalan/java/src/org/apache/xalan/xsltc/trax/ObjectFactory.java
Index: ObjectFactory.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/trax/ObjectFactory.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ObjectFactory.java 11 Mar 2004 21:02:12 -0000 1.3
+++ ObjectFactory.java 17 Aug 2004 16:34:20 -0000 1.4
@@ -291,6 +291,7 @@
synchronized (ObjectFactory.class) {
boolean loadProperties = false;
+ FileInputStream fis = null;
try {
// file existed last time
if(fLastModified >= 0) {
@@ -315,35 +316,52 @@
// must never have attempted to read xalan.properties
// before (or it's outdeated)
fXalanProperties = new Properties();
- FileInputStream fis =
-
ss.getFileInputStream(propertiesFile);
+ fis = ss.getFileInputStream(propertiesFile);
fXalanProperties.load(fis);
- fis.close();
}
- } catch (Exception x) {
- fXalanProperties = null;
- fLastModified = -1;
- // assert(x instanceof FileNotFoundException
- // || x instanceof SecurityException)
- // In both cases, ignore and continue w/ next location
- }
+ } catch (Exception x) {
+ fXalanProperties = null;
+ fLastModified = -1;
+ // assert(x instanceof FileNotFoundException
+ // || x instanceof SecurityException)
+ // In both cases, ignore and continue w/ next location
+ }
+ finally {
+ // try to close the input stream if one was opened.
+ if (fis != null) {
+ try {
+ fis.close();
+ }
+ // Ignore the exception.
+ catch (IOException exc) {}
+ }
+ }
}
if(fXalanProperties != null) {
factoryClassName = fXalanProperties.getProperty(factoryId);
}
} else {
+ FileInputStream fis = null;
try {
- FileInputStream fis =
- ss.getFileInputStream(new
File(propertiesFilename));
+ fis = ss.getFileInputStream(new File(propertiesFilename));
Properties props = new Properties();
props.load(fis);
- fis.close();
factoryClassName = props.getProperty(factoryId);
} catch (Exception x) {
// assert(x instanceof FileNotFoundException
// || x instanceof SecurityException)
// In both cases, ignore and continue w/ next location
}
+ finally {
+ // try to close the input stream if one was opened.
+ if (fis != null) {
+ try {
+ fis.close();
+ }
+ // Ignore the exception.
+ catch (IOException exc) {}
+ }
+ }
}
if (factoryClassName != null) {
debugPrintln("found in " + propertiesFilename + ", value="
@@ -466,7 +484,7 @@
String packageName = className;
if (lastDot != -1) packageName = className.substring(0,
lastDot);
security.checkPackageAccess(packageName);
- }
+ }
}catch(SecurityException e){
throw e;
}
@@ -568,11 +586,18 @@
// XXX Does not handle all possible input as specified by the
// Jar Service Provider specification
factoryClassName = rd.readLine();
- rd.close();
} catch (IOException x) {
// No provider found
return null;
}
+ finally {
+ try {
+ // try to close the reader.
+ rd.close();
+ }
+ // Ignore the exception.
+ catch (IOException exc) {}
+ }
if (factoryClassName != null &&
! "".equals(factoryClassName)) {
1.4 +41 -16 xml-xalan/java/src/org/apache/xml/dtm/ObjectFactory.java
Index: ObjectFactory.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ObjectFactory.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ObjectFactory.java 11 Mar 2004 21:02:13 -0000 1.3
+++ ObjectFactory.java 17 Aug 2004 16:34:20 -0000 1.4
@@ -291,6 +291,7 @@
synchronized (ObjectFactory.class) {
boolean loadProperties = false;
+ FileInputStream fis = null;
try {
// file existed last time
if(fLastModified >= 0) {
@@ -315,35 +316,52 @@
// must never have attempted to read xalan.properties
// before (or it's outdeated)
fXalanProperties = new Properties();
- FileInputStream fis =
-
ss.getFileInputStream(propertiesFile);
+ fis = ss.getFileInputStream(propertiesFile);
fXalanProperties.load(fis);
- fis.close();
}
- } catch (Exception x) {
- fXalanProperties = null;
- fLastModified = -1;
- // assert(x instanceof FileNotFoundException
- // || x instanceof SecurityException)
- // In both cases, ignore and continue w/ next location
- }
+ } catch (Exception x) {
+ fXalanProperties = null;
+ fLastModified = -1;
+ // assert(x instanceof FileNotFoundException
+ // || x instanceof SecurityException)
+ // In both cases, ignore and continue w/ next location
+ }
+ finally {
+ // try to close the input stream if one was opened.
+ if (fis != null) {
+ try {
+ fis.close();
+ }
+ // Ignore the exception.
+ catch (IOException exc) {}
+ }
+ }
}
if(fXalanProperties != null) {
factoryClassName = fXalanProperties.getProperty(factoryId);
}
} else {
+ FileInputStream fis = null;
try {
- FileInputStream fis =
- ss.getFileInputStream(new
File(propertiesFilename));
+ fis = ss.getFileInputStream(new File(propertiesFilename));
Properties props = new Properties();
props.load(fis);
- fis.close();
factoryClassName = props.getProperty(factoryId);
} catch (Exception x) {
// assert(x instanceof FileNotFoundException
// || x instanceof SecurityException)
// In both cases, ignore and continue w/ next location
}
+ finally {
+ // try to close the input stream if one was opened.
+ if (fis != null) {
+ try {
+ fis.close();
+ }
+ // Ignore the exception.
+ catch (IOException exc) {}
+ }
+ }
}
if (factoryClassName != null) {
debugPrintln("found in " + propertiesFilename + ", value="
@@ -568,11 +586,18 @@
// XXX Does not handle all possible input as specified by the
// Jar Service Provider specification
factoryClassName = rd.readLine();
- rd.close();
} catch (IOException x) {
// No provider found
return null;
}
+ finally {
+ try {
+ // try to close the reader.
+ rd.close();
+ }
+ // Ignore the exception.
+ catch (IOException exc) {}
+ }
if (factoryClassName != null &&
! "".equals(factoryClassName)) {
1.4 +41 -16
xml-xalan/java/src/org/apache/xml/dtm/ref/ObjectFactory.java
Index: ObjectFactory.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/ObjectFactory.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ObjectFactory.java 11 Mar 2004 21:02:13 -0000 1.3
+++ ObjectFactory.java 17 Aug 2004 16:34:20 -0000 1.4
@@ -291,6 +291,7 @@
synchronized (ObjectFactory.class) {
boolean loadProperties = false;
+ FileInputStream fis = null;
try {
// file existed last time
if(fLastModified >= 0) {
@@ -315,35 +316,52 @@
// must never have attempted to read xalan.properties
// before (or it's outdeated)
fXalanProperties = new Properties();
- FileInputStream fis =
-
ss.getFileInputStream(propertiesFile);
+ fis = ss.getFileInputStream(propertiesFile);
fXalanProperties.load(fis);
- fis.close();
}
- } catch (Exception x) {
- fXalanProperties = null;
- fLastModified = -1;
- // assert(x instanceof FileNotFoundException
- // || x instanceof SecurityException)
- // In both cases, ignore and continue w/ next location
- }
+ } catch (Exception x) {
+ fXalanProperties = null;
+ fLastModified = -1;
+ // assert(x instanceof FileNotFoundException
+ // || x instanceof SecurityException)
+ // In both cases, ignore and continue w/ next location
+ }
+ finally {
+ // try to close the input stream if one was opened.
+ if (fis != null) {
+ try {
+ fis.close();
+ }
+ // Ignore the exception.
+ catch (IOException exc) {}
+ }
+ }
}
if(fXalanProperties != null) {
factoryClassName = fXalanProperties.getProperty(factoryId);
}
} else {
+ FileInputStream fis = null;
try {
- FileInputStream fis =
- ss.getFileInputStream(new
File(propertiesFilename));
+ fis = ss.getFileInputStream(new File(propertiesFilename));
Properties props = new Properties();
props.load(fis);
- fis.close();
factoryClassName = props.getProperty(factoryId);
} catch (Exception x) {
// assert(x instanceof FileNotFoundException
// || x instanceof SecurityException)
// In both cases, ignore and continue w/ next location
}
+ finally {
+ // try to close the input stream if one was opened.
+ if (fis != null) {
+ try {
+ fis.close();
+ }
+ // Ignore the exception.
+ catch (IOException exc) {}
+ }
+ }
}
if (factoryClassName != null) {
debugPrintln("found in " + propertiesFilename + ", value="
@@ -568,11 +586,18 @@
// XXX Does not handle all possible input as specified by the
// Jar Service Provider specification
factoryClassName = rd.readLine();
- rd.close();
} catch (IOException x) {
// No provider found
return null;
}
+ finally {
+ try {
+ // try to close the reader.
+ rd.close();
+ }
+ // Ignore the exception.
+ catch (IOException exc) {}
+ }
if (factoryClassName != null &&
! "".equals(factoryClassName)) {
1.5 +42 -17
xml-xalan/java/src/org/apache/xml/serializer/ObjectFactory.java
Index: ObjectFactory.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xml/serializer/ObjectFactory.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ObjectFactory.java 1 Apr 2004 18:45:30 -0000 1.4
+++ ObjectFactory.java 17 Aug 2004 16:34:20 -0000 1.5
@@ -290,6 +290,7 @@
synchronized (ObjectFactory.class) {
boolean loadProperties = false;
+ FileInputStream fis = null;
try {
// file existed last time
if(fLastModified >= 0) {
@@ -314,35 +315,52 @@
// must never have attempted to read xalan.properties
// before (or it's outdeated)
fXalanProperties = new Properties();
- FileInputStream fis =
-
ss.getFileInputStream(propertiesFile);
+ fis = ss.getFileInputStream(propertiesFile);
fXalanProperties.load(fis);
- fis.close();
}
- } catch (Exception x) {
- fXalanProperties = null;
- fLastModified = -1;
- // assert(x instanceof FileNotFoundException
- // || x instanceof SecurityException)
- // In both cases, ignore and continue w/ next location
- }
+ } catch (Exception x) {
+ fXalanProperties = null;
+ fLastModified = -1;
+ // assert(x instanceof FileNotFoundException
+ // || x instanceof SecurityException)
+ // In both cases, ignore and continue w/ next location
+ }
+ finally {
+ // try to close the input stream if one was opened.
+ if (fis != null) {
+ try {
+ fis.close();
+ }
+ // Ignore the exception.
+ catch (IOException exc) {}
+ }
+ }
}
if(fXalanProperties != null) {
factoryClassName = fXalanProperties.getProperty(factoryId);
}
} else {
+ FileInputStream fis = null;
try {
- FileInputStream fis =
- ss.getFileInputStream(new
File(propertiesFilename));
+ fis = ss.getFileInputStream(new File(propertiesFilename));
Properties props = new Properties();
props.load(fis);
- fis.close();
factoryClassName = props.getProperty(factoryId);
} catch (Exception x) {
// assert(x instanceof FileNotFoundException
// || x instanceof SecurityException)
// In both cases, ignore and continue w/ next location
}
+ finally {
+ // try to close the input stream if one was opened.
+ if (fis != null) {
+ try {
+ fis.close();
+ }
+ // Ignore the exception.
+ catch (IOException exc) {}
+ }
+ }
}
if (factoryClassName != null) {
debugPrintln("found in " + propertiesFilename + ", value="
@@ -465,7 +483,7 @@
String packageName = className;
if (lastDot != -1) packageName = className.substring(0,
lastDot);
security.checkPackageAccess(packageName);
- }
+ }
}catch(SecurityException e){
throw e;
}
@@ -567,11 +585,18 @@
// XXX Does not handle all possible input as specified by the
// Jar Service Provider specification
factoryClassName = rd.readLine();
- rd.close();
} catch (IOException x) {
// No provider found
return null;
}
+ finally {
+ try {
+ // try to close the reader.
+ rd.close();
+ }
+ // Ignore the exception.
+ catch (IOException exc) {}
+ }
if (factoryClassName != null &&
! "".equals(factoryClassName)) {
1.8 +39 -14
xml-xalan/java/src/org/apache/xml/utils/ObjectFactory.java
Index: ObjectFactory.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xml/utils/ObjectFactory.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- ObjectFactory.java 11 Mar 2004 21:02:13 -0000 1.7
+++ ObjectFactory.java 17 Aug 2004 16:34:20 -0000 1.8
@@ -291,6 +291,7 @@
synchronized (ObjectFactory.class) {
boolean loadProperties = false;
+ FileInputStream fis = null;
try {
// file existed last time
if(fLastModified >= 0) {
@@ -315,35 +316,52 @@
// must never have attempted to read xalan.properties
// before (or it's outdeated)
fXalanProperties = new Properties();
- FileInputStream fis =
-
ss.getFileInputStream(propertiesFile);
+ fis = ss.getFileInputStream(propertiesFile);
fXalanProperties.load(fis);
- fis.close();
}
- } catch (Exception x) {
- fXalanProperties = null;
- fLastModified = -1;
- // assert(x instanceof FileNotFoundException
- // || x instanceof SecurityException)
- // In both cases, ignore and continue w/ next location
- }
+ } catch (Exception x) {
+ fXalanProperties = null;
+ fLastModified = -1;
+ // assert(x instanceof FileNotFoundException
+ // || x instanceof SecurityException)
+ // In both cases, ignore and continue w/ next location
+ }
+ finally {
+ // try to close the input stream if one was opened.
+ if (fis != null) {
+ try {
+ fis.close();
+ }
+ // Ignore the exception.
+ catch (IOException exc) {}
+ }
+ }
}
if(fXalanProperties != null) {
factoryClassName = fXalanProperties.getProperty(factoryId);
}
} else {
+ FileInputStream fis = null;
try {
- FileInputStream fis =
- ss.getFileInputStream(new
File(propertiesFilename));
+ fis = ss.getFileInputStream(new File(propertiesFilename));
Properties props = new Properties();
props.load(fis);
- fis.close();
factoryClassName = props.getProperty(factoryId);
} catch (Exception x) {
// assert(x instanceof FileNotFoundException
// || x instanceof SecurityException)
// In both cases, ignore and continue w/ next location
}
+ finally {
+ // try to close the input stream if one was opened.
+ if (fis != null) {
+ try {
+ fis.close();
+ }
+ // Ignore the exception.
+ catch (IOException exc) {}
+ }
+ }
}
if (factoryClassName != null) {
debugPrintln("found in " + propertiesFilename + ", value="
@@ -568,11 +586,18 @@
// XXX Does not handle all possible input as specified by the
// Jar Service Provider specification
factoryClassName = rd.readLine();
- rd.close();
} catch (IOException x) {
// No provider found
return null;
}
+ finally {
+ try {
+ // try to close the reader.
+ rd.close();
+ }
+ // Ignore the exception.
+ catch (IOException exc) {}
+ }
if (factoryClassName != null &&
! "".equals(factoryClassName)) {
1.4 +42 -17
xml-xalan/java/src/org/apache/xpath/compiler/ObjectFactory.java
Index: ObjectFactory.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xpath/compiler/ObjectFactory.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ObjectFactory.java 11 Mar 2004 21:02:13 -0000 1.3
+++ ObjectFactory.java 17 Aug 2004 16:34:20 -0000 1.4
@@ -291,6 +291,7 @@
synchronized (ObjectFactory.class) {
boolean loadProperties = false;
+ FileInputStream fis = null;
try {
// file existed last time
if(fLastModified >= 0) {
@@ -315,35 +316,52 @@
// must never have attempted to read xalan.properties
// before (or it's outdeated)
fXalanProperties = new Properties();
- FileInputStream fis =
-
ss.getFileInputStream(propertiesFile);
+ fis = ss.getFileInputStream(propertiesFile);
fXalanProperties.load(fis);
- fis.close();
}
- } catch (Exception x) {
- fXalanProperties = null;
- fLastModified = -1;
- // assert(x instanceof FileNotFoundException
- // || x instanceof SecurityException)
- // In both cases, ignore and continue w/ next location
- }
+ } catch (Exception x) {
+ fXalanProperties = null;
+ fLastModified = -1;
+ // assert(x instanceof FileNotFoundException
+ // || x instanceof SecurityException)
+ // In both cases, ignore and continue w/ next location
+ }
+ finally {
+ // try to close the input stream if one was opened.
+ if (fis != null) {
+ try {
+ fis.close();
+ }
+ // Ignore the exception.
+ catch (IOException exc) {}
+ }
+ }
}
if(fXalanProperties != null) {
factoryClassName = fXalanProperties.getProperty(factoryId);
}
} else {
+ FileInputStream fis = null;
try {
- FileInputStream fis =
- ss.getFileInputStream(new
File(propertiesFilename));
+ fis = ss.getFileInputStream(new File(propertiesFilename));
Properties props = new Properties();
props.load(fis);
- fis.close();
factoryClassName = props.getProperty(factoryId);
} catch (Exception x) {
// assert(x instanceof FileNotFoundException
// || x instanceof SecurityException)
// In both cases, ignore and continue w/ next location
}
+ finally {
+ // try to close the input stream if one was opened.
+ if (fis != null) {
+ try {
+ fis.close();
+ }
+ // Ignore the exception.
+ catch (IOException exc) {}
+ }
+ }
}
if (factoryClassName != null) {
debugPrintln("found in " + propertiesFilename + ", value="
@@ -466,7 +484,7 @@
String packageName = className;
if (lastDot != -1) packageName = className.substring(0,
lastDot);
security.checkPackageAccess(packageName);
- }
+ }
}catch(SecurityException e){
throw e;
}
@@ -568,11 +586,18 @@
// XXX Does not handle all possible input as specified by the
// Jar Service Provider specification
factoryClassName = rd.readLine();
- rd.close();
} catch (IOException x) {
// No provider found
return null;
}
+ finally {
+ try {
+ // try to close the reader.
+ rd.close();
+ }
+ // Ignore the exception.
+ catch (IOException exc) {}
+ }
if (factoryClassName != null &&
! "".equals(factoryClassName)) {
1.4 +41 -16
xml-xalan/java/src/org/apache/xpath/functions/ObjectFactory.java
Index: ObjectFactory.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xpath/functions/ObjectFactory.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ObjectFactory.java 11 Mar 2004 21:02:13 -0000 1.3
+++ ObjectFactory.java 17 Aug 2004 16:34:20 -0000 1.4
@@ -291,6 +291,7 @@
synchronized (ObjectFactory.class) {
boolean loadProperties = false;
+ FileInputStream fis = null;
try {
// file existed last time
if(fLastModified >= 0) {
@@ -315,35 +316,52 @@
// must never have attempted to read xalan.properties
// before (or it's outdeated)
fXalanProperties = new Properties();
- FileInputStream fis =
-
ss.getFileInputStream(propertiesFile);
+ fis = ss.getFileInputStream(propertiesFile);
fXalanProperties.load(fis);
- fis.close();
}
- } catch (Exception x) {
- fXalanProperties = null;
- fLastModified = -1;
- // assert(x instanceof FileNotFoundException
- // || x instanceof SecurityException)
- // In both cases, ignore and continue w/ next location
- }
+ } catch (Exception x) {
+ fXalanProperties = null;
+ fLastModified = -1;
+ // assert(x instanceof FileNotFoundException
+ // || x instanceof SecurityException)
+ // In both cases, ignore and continue w/ next location
+ }
+ finally {
+ // try to close the input stream if one was opened.
+ if (fis != null) {
+ try {
+ fis.close();
+ }
+ // Ignore the exception.
+ catch (IOException exc) {}
+ }
+ }
}
if(fXalanProperties != null) {
factoryClassName = fXalanProperties.getProperty(factoryId);
}
} else {
+ FileInputStream fis = null;
try {
- FileInputStream fis =
- ss.getFileInputStream(new
File(propertiesFilename));
+ fis = ss.getFileInputStream(new File(propertiesFilename));
Properties props = new Properties();
props.load(fis);
- fis.close();
factoryClassName = props.getProperty(factoryId);
} catch (Exception x) {
// assert(x instanceof FileNotFoundException
// || x instanceof SecurityException)
// In both cases, ignore and continue w/ next location
}
+ finally {
+ // try to close the input stream if one was opened.
+ if (fis != null) {
+ try {
+ fis.close();
+ }
+ // Ignore the exception.
+ catch (IOException exc) {}
+ }
+ }
}
if (factoryClassName != null) {
debugPrintln("found in " + propertiesFilename + ", value="
@@ -568,11 +586,18 @@
// XXX Does not handle all possible input as specified by the
// Jar Service Provider specification
factoryClassName = rd.readLine();
- rd.close();
} catch (IOException x) {
// No provider found
return null;
}
+ finally {
+ try {
+ // try to close the reader.
+ rd.close();
+ }
+ // Ignore the exception.
+ catch (IOException exc) {}
+ }
if (factoryClassName != null &&
! "".equals(factoryClassName)) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]