Skip to content

Commit b1e4fc1

Browse files
Selaronsebersole
Selaron
authored andcommitted
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.
1 parent 5e87397 commit b1e4fc1

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

hibernate-core/src/main/java/org/hibernate/boot/jaxb/internal/CacheableFileXmlSource.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ public class CacheableFileXmlSource extends XmlSource {
3232
private final File xmlFile;
3333
private final File serFile;
3434
private final boolean strict;
35-
private final boolean serFileObsolete;
3635

3736
public CacheableFileXmlSource(Origin origin, File xmlFile, boolean strict) {
3837
super( origin );
@@ -41,16 +40,14 @@ public CacheableFileXmlSource(Origin origin, File xmlFile, boolean strict) {
4140

4241
this.serFile = determineCachedFile( xmlFile );
4342

44-
this.serFileObsolete = xmlFile.exists() && serFile.exists() && xmlFile.lastModified() > serFile.lastModified();
45-
4643
if ( strict ) {
4744
if ( !serFile.exists() ) {
4845
throw new MappingException(
4946
String.format( "Cached file [%s] could not be found", origin.getName() ),
5047
origin
5148
);
5249
}
53-
if ( serFileObsolete ) {
50+
if ( isSerfileObsolete() ) {
5451
throw new MappingException(
5552
String.format( "Cached file [%s] could not be used as the mapping file is newer", origin.getName() ),
5653
origin
@@ -86,7 +83,7 @@ public Binding doBind(Binder binder) {
8683
}
8784
}
8885
else {
89-
if ( !serFileObsolete ) {
86+
if ( !isSerfileObsolete() ) {
9087
try {
9188
return readSerFile();
9289
}
@@ -141,5 +138,9 @@ public static void createSerFile(File xmlFile, Binder binder) {
141138
determineCachedFile( xmlFile )
142139
);
143140
}
141+
142+
private boolean isSerfileObsolete() {
143+
return xmlFile.exists() && serFile.exists() && xmlFile.lastModified() > serFile.lastModified();
144+
}
144145

145146
}

0 commit comments

Comments
 (0)