|
6 | 6 | */
|
7 | 7 | package org.hibernate.cache.infinispan;
|
8 | 8 |
|
9 |
| -import java.io.FileNotFoundException; |
10 | 9 | import java.io.IOException;
|
11 | 10 | import java.io.InputStream;
|
12 | 11 | import java.util.ArrayList;
|
|
47 | 46 |
|
48 | 47 | import org.infinispan.AdvancedCache;
|
49 | 48 | import org.infinispan.commands.module.ModuleCommandFactory;
|
| 49 | +import org.infinispan.commons.util.FileLookup; |
50 | 50 | import org.infinispan.commons.util.FileLookupFactory;
|
51 | 51 | import org.infinispan.configuration.cache.CacheMode;
|
52 | 52 | import org.infinispan.configuration.cache.Configuration;
|
@@ -426,20 +426,20 @@ protected EmbeddedCacheManager createCacheManager(
|
426 | 426 | properties,
|
427 | 427 | DEF_INFINISPAN_CONFIG_RESOURCE
|
428 | 428 | );
|
| 429 | + final FileLookup fileLookup = FileLookupFactory.newInstance(); |
429 | 430 |
|
430 | 431 | return serviceRegistry.getService( ClassLoaderService.class ).workWithClassLoader(
|
431 | 432 | new ClassLoaderService.Work<EmbeddedCacheManager>() {
|
432 | 433 | @Override
|
433 | 434 | public EmbeddedCacheManager doWork(ClassLoader classLoader) {
|
434 | 435 | try {
|
435 | 436 | InputStream is;
|
436 |
| - try { |
437 |
| - is = FileLookupFactory.newInstance().lookupFileStrict( configLoc, classLoader ); |
438 |
| - } |
439 |
| - catch (FileNotFoundException e) { |
440 |
| - // In some environments (ex: OSGi), hibernate-infinispan may not |
441 |
| - // be in the app CL. It's important to also try this CL. |
| 437 | + is = fileLookup.lookupFile( configLoc, classLoader ); |
| 438 | + if ( is == null ) { |
| 439 | + // when it's not a user-provided configuration file, it might be a default configuration file, |
| 440 | + // and if that's included in [this] module might not be visible to the ClassLoaderService: |
442 | 441 | classLoader = this.getClass().getClassLoader();
|
| 442 | + // This time use lookupFile*Strict* so to provide an exception if we can't find it yet: |
443 | 443 | is = FileLookupFactory.newInstance().lookupFileStrict( configLoc, classLoader );
|
444 | 444 | }
|
445 | 445 | final ParserRegistry parserRegistry = new ParserRegistry( classLoader );
|
|
0 commit comments