shiro-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Les Hazlewood (JIRA)" <j...@apache.org>
Subject [jira] [Resolved] (SHIRO-394) PropertiesRealm reloading not working when loading from file
Date Sat, 04 May 2013 23:00:17 GMT

     [ https://issues.apache.org/jira/browse/SHIRO-394?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Les Hazlewood resolved SHIRO-394.
---------------------------------

       Resolution: Fixed
    Fix Version/s: 1.3.0
                   1.2.2
    
> 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, 1.3.0
>
>
> 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 is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message