Author: julien_viet
Date: 2009-12-02 11:24:28 -0500 (Wed, 02 Dec 2009)
New Revision: 911
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/resource/SkinConfigDeployer.java
Log:
better impl of InputStream close in a finally close
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/resource/SkinConfigDeployer.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/resource/SkinConfigDeployer.java 2009-12-02
15:09:56 UTC (rev 910)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/resource/SkinConfigDeployer.java 2009-12-02
16:24:28 UTC (rev 911)
@@ -22,6 +22,7 @@
import groovy.lang.Binding;
import groovy.lang.GroovyShell;
+import org.exoplatform.commons.utils.Safe;
import org.exoplatform.container.PortalContainer;
import org.exoplatform.container.RootContainer.PortalContainerPostInitTask;
import org.exoplatform.services.log.ExoLogger;
@@ -69,20 +70,11 @@
if (waEvent.getType() == WebAppLifeCycleEvent.ADDED)
{
ServletContext scontext = null;
+ InputStream is = null;
try
{
scontext = event.getWebApp().getServletContext();
- InputStream is =
scontext.getResourceAsStream("/WEB-INF/conf/script/groovy/SkinConfigScript.groovy");
- if (is == null)
- return;
- try
- {
- is.close();
- }
- catch (Exception ex)
- {
- // ignore me
- }
+ is =
scontext.getResourceAsStream("/WEB-INF/conf/script/groovy/SkinConfigScript.groovy");
final PortalContainerPostInitTask task = new
PortalContainerPostInitTask()
{
@@ -98,6 +90,10 @@
LOG.error("An error occurs while registering
'SkinConfigScript.groovy' from the context '"
+ (scontext == null ? "unknown" :
scontext.getServletContextName()) + "'", ex);
}
+ finally
+ {
+ Safe.close(is);
+ }
}
}
}
Show replies by date