Author: simoneg
Date: Tue Nov 10 12:19:13 2009
New Revision: 834448

URL: http://svn.apache.org/viewvc?rev=834448&view=rev
Log:
Force closing the template input stream

Modified:
    
labs/magma/trunk/foundation-website/src/main/java/org/apache/magma/website/templating/Template.java

Modified: 
labs/magma/trunk/foundation-website/src/main/java/org/apache/magma/website/templating/Template.java
URL: 
http://svn.apache.org/viewvc/labs/magma/trunk/foundation-website/src/main/java/org/apache/magma/website/templating/Template.java?rev=834448&r1=834447&r2=834448&view=diff
==============================================================================
--- 
labs/magma/trunk/foundation-website/src/main/java/org/apache/magma/website/templating/Template.java
 (original)
+++ 
labs/magma/trunk/foundation-website/src/main/java/org/apache/magma/website/templating/Template.java
 Tue Nov 10 12:19:13 2009
@@ -216,9 +216,21 @@
                // We can ignore the FindBugs error here, it refers to the 
opposite situation, where
                // a resource is relative to this class. In our case, the 
behavior is the correct one,
                // because the resource is relative to the subclass.
-               InputStream inputStream = 
getClass().getResourceAsStream(fileName);
-               InputStreamReader reader = new InputStreamReader(inputStream, 
Charset.forName("UTF-8"));
-               return new TemplateData(reader); 
+               try {
+                       InputStream inputStream = 
getClass().getResourceAsStream(fileName);
+                       try {
+                               InputStreamReader reader = new 
InputStreamReader(inputStream, Charset.forName("UTF-8"));
+                               return new TemplateData(reader);
+                       } finally {
+                               try {
+                                       inputStream.close();
+                               } catch (Exception e) {
+                                       // Ignore the close exception
+                               }
+                       }
+               } catch (Exception e) {
+                       throw new MagmaException(e, "Error reading template");
+               }
        }
 
 



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to