[infinispan-issues] [JBoss JIRA] (ISPN-8935) AbstractFileLookup.lookupFileStrict does not work for jar scheme

Damir Murat (JIRA) issues at jboss.org
Tue Mar 13 07:45:00 EDT 2018


    [ https://issues.jboss.org/browse/ISPN-8935?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13545029#comment-13545029 ] 

Damir Murat commented on ISPN-8935:
-----------------------------------

Related issues: [ISPN-7704|https://issues.jboss.org/browse/ISPN-7704], [ISPN-7313|https://issues.jboss.org/browse/ISPN-7313].

> AbstractFileLookup.lookupFileStrict does not work for jar scheme
> ----------------------------------------------------------------
>
>                 Key: ISPN-8935
>                 URL: https://issues.jboss.org/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
>
> As documented [here|https://docs.oracle.com/javase/7/docs/api/java/net/JarURLConnection.html], 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.



--
This message was sent by Atlassian JIRA
(v7.5.0#75005)


More information about the infinispan-issues mailing list