Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the method getResource should have issue on line 164 #23

Open
hylinux opened this issue Aug 12, 2017 · 4 comments
Open

the method getResource should have issue on line 164 #23

hylinux opened this issue Aug 12, 2017 · 4 comments

Comments

@hylinux
Copy link

hylinux commented Aug 12, 2017

Hi, I just tried use the library for my project.
but I found there is a issue in method getResource in class EhcacheShiroManager

the line 164. I found the code always strip the prefix. but when we put the path into. the code use a url for it.

then it always throws a MalformedURLException, and Caused by: java.net.MalformedURLException: no protocol:

I suppose this is a bug for this code.

thanks

Mike

@nenko-tabakov
Copy link
Contributor

Hi,
have you tried adding a 'file:/' prefix to the path?

Kind regards,
Nenko

@hylinux
Copy link
Author

hylinux commented Aug 12, 2017

yes. I did.

still got that issue....

@henri-tremblay
Copy link
Contributor

This error can be easily reproduced with

  @Test
  public void testNoPrefix() {
    EhcacheShiroManager cacheManager = new EhcacheShiroManager();
    cacheManager.setCacheManagerConfigFile("file:config/ehcache.xml");
    Cache<Object, Object> someCache = cacheManager.getCache("someCache");
    assertNotNull(someCache);
  }
}

I think the correct code should mimic ResourceUtils.getInputStreamForPath.

@bmarwell
Copy link

I can see the fix in the code, where this was changed:

if (cacheManagerConfigFile.startsWith(ResourceUtils.CLASSPATH_PREFIX)) {
      return EhcacheShiroManager.class.getClass().getResource(stripPrefix(cacheManagerConfigFile));
    }

to this:

if (cacheManagerConfigFile.startsWith(ResourceUtils.CLASSPATH_PREFIX)) {
      return ClassUtils.getResource(configFileWithoutPrefix);
    }

@nenko-tabakov can you please release the fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants