labs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simo...@apache.org
Subject svn commit: r834448 - /labs/magma/trunk/foundation-website/src/main/java/org/apache/magma/website/templating/Template.java
Date Tue, 10 Nov 2009 12:19:13 GMT
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: commits-unsubscribe@labs.apache.org
For additional commands, e-mail: commits-help@labs.apache.org


Mime
View raw message