private final Map<String, TeamModel> teams = new ConcurrentHashMap<String, TeamModel>();\r
\r
private volatile long lastModified;\r
+ \r
+ private volatile boolean forceReload;\r
\r
public ConfigUserService(File realmFile) {\r
this.realmFile = realmFile;\r
}\r
\r
config.save();\r
+ // manually set the forceReload flag because not all JVMs support real\r
+ // millisecond resolution of lastModified. (issue-55)\r
+ forceReload = true;\r
\r
// If the write is successful, delete the current file and rename\r
// the temporary copy to the original filename.\r
* Reads the realm file and rebuilds the in-memory lookup tables.\r
*/\r
protected synchronized void read() {\r
- if (realmFile.exists() && (realmFile.lastModified() > lastModified)) {\r
+ if (realmFile.exists() && (forceReload || (realmFile.lastModified() != lastModified))) {\r
+ forceReload = false;\r
lastModified = realmFile.lastModified();\r
users.clear();\r
cookies.clear();\r
private final Properties properties = new Properties();\r
\r
private volatile long lastModified;\r
+ \r
+ private volatile boolean forceReload;\r
\r
public FileSettings(String file) {\r
super(FileSettings.class);\r
*/\r
@Override\r
protected synchronized Properties read() {\r
- if (propertiesFile.exists() && (propertiesFile.lastModified() > lastModified)) {\r
+ if (propertiesFile.exists() && (forceReload || (propertiesFile.lastModified() > lastModified))) {\r
FileInputStream is = null;\r
try {\r
Properties props = new Properties();\r
properties.clear();\r
properties.putAll(props);\r
lastModified = propertiesFile.lastModified();\r
+ forceReload = false;\r
} catch (FileNotFoundException f) {\r
// IGNORE - won't happen because file.exists() check above\r
} catch (Throwable t) {\r
content = content.replaceAll(regex, setting.getKey() + " = " + setting.getValue());\r
}\r
FileUtils.writeContent(propertiesFile, content);\r
+ // manually set the forceReload flag because not all JVMs support real\r
+ // millisecond resolution of lastModified. (issue-55) \r
+ forceReload = true;\r
return true;\r
}\r
\r
return lastModified;\r
}\r
\r
+ /**\r
+ * @return the state of the force reload flag\r
+ */\r
+ protected boolean forceReload() {\r
+ return forceReload;\r
+ }\r
+\r
@Override\r
public String toString() {\r
return propertiesFile.getAbsolutePath();\r
@Override\r
protected synchronized Properties read() {\r
long lastRead = lastModified();\r
+ boolean reload = forceReload();\r
Properties allUsers = super.read();\r
- if (lastRead != lastModified()) {\r
+ if (reload || (lastRead != lastModified())) {\r
// reload hash cache\r
cookies.clear();\r
teams.clear();\r