Skip to content

Commit 1e54ee3

Browse files
committed
HHH-9874 Do not leak the configuration resource stream
1 parent f593a9c commit 1e54ee3

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/InfinispanRegionFactory.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
import org.infinispan.commands.module.ModuleCommandFactory;
4949
import org.infinispan.commons.util.FileLookup;
5050
import org.infinispan.commons.util.FileLookupFactory;
51+
import org.infinispan.commons.util.Util;
5152
import org.infinispan.configuration.cache.CacheMode;
5253
import org.infinispan.configuration.cache.Configuration;
5354
import org.infinispan.configuration.cache.ConfigurationBuilder;
@@ -434,8 +435,8 @@ protected EmbeddedCacheManager createCacheManager(
434435
new ClassLoaderService.Work<EmbeddedCacheManager>() {
435436
@Override
436437
public EmbeddedCacheManager doWork(ClassLoader classLoader) {
438+
InputStream is = null;
437439
try {
438-
InputStream is;
439440
is = fileLookup.lookupFile( configLoc, classLoader );
440441
if ( is == null ) {
441442
// when it's not a user-provided configuration file, it might be a default configuration file,
@@ -463,6 +464,9 @@ public EmbeddedCacheManager doWork(ClassLoader classLoader) {
463464
catch (IOException e) {
464465
throw new CacheException( "Unable to create default cache manager", e );
465466
}
467+
finally {
468+
Util.close( is );
469+
}
466470
}
467471

468472
}

0 commit comments

Comments
 (0)