mirror of
https://github.com/apache/struts.git
synced 2026-08-07 07:37:20 +00:00
Fix: Resources should be closed
Java 7 introduced the try-with-resources statement, which implicitly closes Closeables. Fixes sonar rule squid:S2095
This commit is contained in:
+9
-6
@@ -104,14 +104,17 @@ public class StrutsSpringObjectFactory extends SpringObjectFactory {
|
||||
//prevent class caching
|
||||
useClassCache = false;
|
||||
|
||||
ClassReloadingXMLWebApplicationContext reloadingContext = (ClassReloadingXMLWebApplicationContext) appContext;
|
||||
reloadingContext.setupReloading(watchList.split(","), acceptClasses, servletContext, "true".equals(reloadConfig));
|
||||
LOG.info("Class reloading is enabled. Make sure this is not used on a production environment!\n{}", watchList);
|
||||
try (ClassReloadingXMLWebApplicationContext reloadingContext = (ClassReloadingXMLWebApplicationContext) appContext) {
|
||||
reloadingContext.setupReloading(watchList.split(","), acceptClasses, servletContext,
|
||||
"true".equals(reloadConfig));
|
||||
LOG.info("Class reloading is enabled. Make sure this is not used on a production environment!\n{}",
|
||||
watchList);
|
||||
|
||||
setClassLoader(reloadingContext.getReloadingClassLoader());
|
||||
setClassLoader(reloadingContext.getReloadingClassLoader());
|
||||
|
||||
//we need to reload the context, so our isntance of the factory is picked up
|
||||
reloadingContext.refresh();
|
||||
// we need to reload the context, so our isntance of the factory is picked up
|
||||
reloadingContext.refresh();
|
||||
}
|
||||
}
|
||||
|
||||
this.setApplicationContext(appContext);
|
||||
|
||||
Reference in New Issue
Block a user