]
Sammy Chu commented on ISPN-8935:
---------------------------------
Suspected the fix is not correct, considering uri
`jar:file:/path/to/my/jar.jar!/infinispan.xml`,
[
extracted `insideJarFilePath = "/infinispan.xml"`. As
`getAsInputStreamFromClassLoader(...)` implementation use
`ClassLoader.getResourceAsStream(...)` to lookup the resource, any resource starting with
"/" actually will always return null.
AbstractFileLookup.lookupFileStrict does not work for jar scheme
----------------------------------------------------------------
Key: ISPN-8935
URL:
https://issues.redhat.com/browse/ISPN-8935
Project: Infinispan
Issue Type: Bug
Components: Configuration, JCache
Affects Versions: 9.1.6.Final, 9.2.0.Final
Environment: Spring Boot 1.5.10, Infinispan 9.1.6
Reporter: Damir Murat
Assignee: Tristan Tarrant
Priority: Major
Fix For: 9.2.1.Final
As documented
[
here|https://docs.oracle.com/javase/7/docs/api/java/net/JarURLConnection....], JAR URL
has following syntax {{jar:<url>!/\{entry\}}}. Current implementation of
{{AbstractFileLookup.lookupFileStrict}} does not rely on this syntax, and fails when
correctly specified JAR URI comes in.
I'm using Infinispan JCache implementation from Spring Boot. This works when run from
gradle/maven/ide since in these cases {{file}} scheme is used. However, I'm targeting
running Spring Boot app inside of Docker container where natural way for using Spring Boot
apps is to deploy them as boot packaged fat jar. In that case, Spring Boot passes correct
JAR URI into {{AbstractFileLookup.lookupFileStrict}}, which unfortunately fails silently
and JCache reverts to default configuration.
I believe that {{AbstractFileLookup.lookupFileStrict}} can be fixed by replacing current
jar scheme handling
{code}
case "jar":
String uriAsString = uri.toString();
String fileName = uriAsString.substring(uriAsString.lastIndexOf(":") +
1);
return new FileInputStream(new File(fileName));
{code}
with something like this
{code}
case "jar": {
// Invalid code commented out.
// String uriAsString = uri.toString();
// String fileName =
uriAsString.substring(uriAsString.lastIndexOf(":") + 1);
// return new FileInputStream(new File(fileName));
// ===== fix - start =====
String uriAsString = uri.toString();
String insideJarFilePath =
uriAsString.substring(uriAsString.lastIndexOf("!") + 1);
InputStream streamToBeReturned =
getAsInputStreamFromClassLoader(insideJarFilePath, cl);
if (streamToBeReturned == null) {
throw log.unableToLoadFileUsingScheme(scheme);
}
return streamToBeReturned;
// ===== fix - end =====
}
{code}
I'm using Infinispan 9.1.6, but I think that 9.2.0 has same problem. I will try to
submit pull request.