HHH-10181 - CacheableFileXmlSource.doBind uses obsolete .bin file

Check for obsolete cache file during runtime of doBind(..) instead of
CacheableFileXmlSource instantiation only. Subsequent calls of doBind on
a given CacheableFileXmlSource instance should detect that cache file is
fresh and make use of it.

(cherry picked from commit b1e4fc1ae4)
This commit is contained in:
Selaron 2015-11-07 19:52:56 +01:00 committed by Steve Ebersole
parent fe6e2842fd
commit 0280fe6d2a
1 changed files with 6 additions and 5 deletions

View File

@ -32,7 +32,6 @@ public class CacheableFileXmlSource extends XmlSource {
private final File xmlFile;
private final File serFile;
private final boolean strict;
private final boolean serFileObsolete;
public CacheableFileXmlSource(Origin origin, File xmlFile, boolean strict) {
super( origin );
@ -41,8 +40,6 @@ public class CacheableFileXmlSource extends XmlSource {
this.serFile = determineCachedFile( xmlFile );
this.serFileObsolete = xmlFile.exists() && serFile.exists() && xmlFile.lastModified() > serFile.lastModified();
if ( strict ) {
if ( !serFile.exists() ) {
throw new MappingException(
@ -50,7 +47,7 @@ public class CacheableFileXmlSource extends XmlSource {
origin
);
}
if ( serFileObsolete ) {
if ( isSerfileObsolete() ) {
throw new MappingException(
String.format( "Cached file [%s] could not be used as the mapping file is newer", origin.getName() ),
origin
@ -86,7 +83,7 @@ public class CacheableFileXmlSource extends XmlSource {
}
}
else {
if ( !serFileObsolete ) {
if ( !isSerfileObsolete() ) {
try {
return readSerFile();
}
@ -142,4 +139,8 @@ public class CacheableFileXmlSource extends XmlSource {
);
}
private boolean isSerfileObsolete() {
return xmlFile.exists() && serFile.exists() && xmlFile.lastModified() > serFile.lastModified();
}
}