You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shiro.apache.org by "Brian Demers (JIRA)" <ji...@apache.org> on 2016/07/15 14:56:20 UTC
[jira] [Closed] (SHIRO-394) PropertiesRealm reloading not working
when loading from file
[ https://issues.apache.org/jira/browse/SHIRO-394?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Brian Demers closed SHIRO-394.
------------------------------
> PropertiesRealm reloading not working when loading from file
> ------------------------------------------------------------
>
> Key: SHIRO-394
> URL: https://issues.apache.org/jira/browse/SHIRO-394
> Project: Shiro
> Issue Type: Bug
> Components: Realms
> Affects Versions: 1.2.1
> Environment: All
> Reporter: Jan Stamer
> Fix For: 1.2.2
>
>
> I use a PropertiesRealm with a file url. This works fine when initially loading the properties file. Yet I was puzzled to find out that reloading does not work.
> I debugged and found the problem:
> First of all the method isFileModified() checks for the lastModified date. Yet this returns 0 if the file does not exist. This is always the case when using the prefix "file:". Therefore the file was never reloaded because the reload file was checking the last modfied date of a file that was never there.
> I have several problems with that:
> 1. Frankly speaking has anyone ever tested that stuff? To me it does not look like that and I think Shiro can do better.
> 2. The isModified method should react if the file is not existing (any more). Because maybe someone deleted in by accident which causes problems for the next startup.
> 3. The initial file loading and the reloading should use the same code. So at least then its clear that if the initial load succeeds so does the reloading.
> The quick fix is pretty straightforward - just remove the prefix "file:" from the resource path::
> private boolean isFileModified() {
> File propertyFile = new File(ResourceUtils.stripPrefix(this.resourcePath));
> long currentLastModified = propertyFile.lastModified();
> if (currentLastModified > this.fileLastModified) {
> this.fileLastModified = currentLastModified;
> return true;
> } else {
> return false;
> }
> }
> I will hopefully be able to supply a patch soon.
> Thanks,
> Jan
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)