vgritsenko 2003/12/12 16:24:14
Modified: java/src/org/apache/xindice/server XindiceServlet.java
Log:
always close input stream
Revision Changes Path
1.24 +13 -9
xml-xindice/java/src/org/apache/xindice/server/XindiceServlet.java
Index: XindiceServlet.java
===================================================================
RCS file:
/home/cvs/xml-xindice/java/src/org/apache/xindice/server/XindiceServlet.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- XindiceServlet.java 19 Aug 2003 21:08:27 -0000 1.23
+++ XindiceServlet.java 13 Dec 2003 00:24:14 -0000 1.24
@@ -260,32 +260,36 @@
/**
* Loads the Xindice configuration file. The file is searched in the
following locations:
* <ul>
- * <li>the
<tt>ServletConfig..getInitParameter(Xindice.PROP_XINDICE_CONFIGURATION)</tt>
variable located in the servlet
+ * <li>the
<tt>ServletConfig.getInitParameter(Xindice.PROP_XINDICE_CONFIGURATION)</tt>
variable located in the servlet
* configuration file</li>
* <li>use the default configuration stored in the <tt>Xindice</tt>
class</li>
* </ul>
* TODO: we should probably try to load from the file system if we can't
load it this way.
*/
public Configuration loadConfiguration(ServletConfig servletConfig) {
-
try {
Document configurationDocument;
String path =
servletConfig.getInitParameter(Xindice.PROP_XINDICE_CONFIGURATION);
if (path != null) {
- log.debug("loading configuration from " + path);
+ log.debug("Loading configuration from " + path);
ServletContext context = servletConfig.getServletContext();
InputStream inputStream = context.getResourceAsStream(path);
- configurationDocument = DOMParser.toDocument(inputStream);
- inputStream.close();
+ try {
+ configurationDocument =
DOMParser.toDocument(inputStream);
+ } finally {
+ try {
+ inputStream.close();
+ } catch (IOException ignored) {
+ }
+ }
} else {
- log.debug("loading the standard configuration");
+ log.debug("Loading the standard configuration");
configurationDocument =
DOMParser.toDocument(Xindice.DEFAULT_CONFIGURATION);
}
return new Configuration(configurationDocument, false);
} catch (Exception e) {
-
throw new ConfigurationException("Failed to load
configuration.", e);
}
}