Author: wglass Date: Thu Nov 10 15:59:03 2005 New Revision: 332399 URL: http://svn.apache.org/viewcvs?rev=332399&view=rev Log: since ExtendedProperties.load doesn't close the stream, close it on the Velocity side. VELOCITY-418
Modified: jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/RuntimeInstance.java Modified: jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/RuntimeInstance.java URL: http://svn.apache.org/viewcvs/jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/RuntimeInstance.java?rev=332399&r1=332398&r2=332399&view=diff ============================================================================== --- jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/RuntimeInstance.java (original) +++ jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/RuntimeInstance.java Thu Nov 10 15:59:03 2005 @@ -254,7 +254,7 @@ { return initialized; } - + /** * Gets the classname for the Uberspect introspection package and * instantiates an instance. @@ -323,19 +323,36 @@ */ private void setDefaultProperties() { + InputStream inputStream = null; try { - InputStream inputStream = getClass() + inputStream = getClass() .getResourceAsStream('/' + DEFAULT_RUNTIME_PROPERTIES); configuration.load( inputStream ); info ("Default Properties File: " + new File(DEFAULT_RUNTIME_PROPERTIES).getPath()); + + } catch (IOException ioe) { - System.err.println("Cannot get Velocity Runtime default properties!"); + log.error("Cannot get Velocity Runtime default properties!"); + } + finally + { + try + { + if (inputStream != null) + { + inputStream.close(); + } + } + catch (IOException ioe) + { + log.error("Cannot close Velocity Runtime default properties!" + ioe); + } } } @@ -686,19 +703,43 @@ * that we should initialize. */ - InputStream inputStream = - getClass().getResourceAsStream('/' + DEFAULT_RUNTIME_DIRECTIVES); + InputStream inputStream = null; + + try + { + inputStream = getClass().getResourceAsStream('/' + DEFAULT_RUNTIME_DIRECTIVES); + + if (inputStream == null) + { + throw new Exception("Error loading directive.properties! " + + "Something is very wrong if these properties " + + "aren't being located. Either your Velocity " + + "distribution is incomplete or your Velocity " + + "jar file is corrupted!"); + } + + directiveProperties.load(inputStream); - if (inputStream == null) + } + catch (IOException ioe) { - throw new Exception("Error loading directive.properties! " + - "Something is very wrong if these properties " + - "aren't being located. Either your Velocity " + - "distribution is incomplete or your Velocity " + - "jar file is corrupted!"); + log.error("Error while loading directive properties!",ioe); + } + finally + { + try + { + if (inputStream != null) + { + inputStream.close(); + } + } + catch (IOException ioe) + { + log.error("Cannot close directive properties!", ioe); + } } - directiveProperties.load(inputStream); /* * Grab all the values of the properties. These --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]