@@ -755,7 +755,8 @@ static class KnownObjects {
755
755
private final Lock write = lock .writeLock ();
756
756
757
757
private final Map <Long , Object > internalIdStore = new HashMap <>();
758
- private final Map <Long , Boolean > internalNextRecord = new HashMap <>();
758
+ private final Map <Long , Boolean > internalCurrentRecord = new HashMap <>();
759
+ private final Set <Long > previousRecords = new HashSet <>();
759
760
private final Set <Long > idsInCreation = new HashSet <>();
760
761
761
762
private void storeObject (@ Nullable Long internalId , Object object ) {
@@ -766,7 +767,7 @@ private void storeObject(@Nullable Long internalId, Object object) {
766
767
write .lock ();
767
768
idsInCreation .remove (internalId );
768
769
internalIdStore .put (internalId , object );
769
- internalNextRecord .put (internalId , false );
770
+ internalCurrentRecord .put (internalId , false );
770
771
} finally {
771
772
write .unlock ();
772
773
}
@@ -837,23 +838,19 @@ private boolean alreadyMappedInPreviousRecord(@Nullable Long internalId) {
837
838
838
839
read .lock ();
839
840
840
- Boolean nextRecord = internalNextRecord .get (internalId );
841
-
842
- if (nextRecord != null ) {
843
- return nextRecord ;
844
- }
841
+ return previousRecords .contains (internalId ) || internalCurrentRecord .get (internalId );
845
842
846
843
} finally {
847
844
read .unlock ();
848
845
}
849
- return false ;
850
846
}
851
847
852
848
/**
853
849
* Mark all currently existing objects as mapped.
854
850
*/
855
851
private void nextRecord () {
856
- internalNextRecord .replaceAll ((x , y ) -> true );
852
+ previousRecords .addAll (internalCurrentRecord .keySet ());
853
+ internalCurrentRecord .clear ();
857
854
}
858
855
}
859
856
}
0 commit comments