@@ -738,7 +738,8 @@ static class KnownObjects {
738
738
private final Lock write = lock .writeLock ();
739
739
740
740
private final Map <Long , Object > internalIdStore = new HashMap <>();
741
- private final Map <Long , Boolean > internalNextRecord = new HashMap <>();
741
+ private final Map <Long , Boolean > internalCurrentRecord = new HashMap <>();
742
+ private final Set <Long > previousRecords = new HashSet <>();
742
743
private final Set <Long > idsInCreation = new HashSet <>();
743
744
744
745
private void storeObject (@ Nullable Long internalId , Object object ) {
@@ -749,7 +750,7 @@ private void storeObject(@Nullable Long internalId, Object object) {
749
750
write .lock ();
750
751
idsInCreation .remove (internalId );
751
752
internalIdStore .put (internalId , object );
752
- internalNextRecord .put (internalId , false );
753
+ internalCurrentRecord .put (internalId , false );
753
754
} finally {
754
755
write .unlock ();
755
756
}
@@ -820,23 +821,19 @@ private boolean alreadyMappedInPreviousRecord(@Nullable Long internalId) {
820
821
821
822
read .lock ();
822
823
823
- Boolean nextRecord = internalNextRecord .get (internalId );
824
-
825
- if (nextRecord != null ) {
826
- return nextRecord ;
827
- }
824
+ return previousRecords .contains (internalId ) || internalCurrentRecord .get (internalId );
828
825
829
826
} finally {
830
827
read .unlock ();
831
828
}
832
- return false ;
833
829
}
834
830
835
831
/**
836
832
* Mark all currently existing objects as mapped.
837
833
*/
838
834
private void nextRecord () {
839
- internalNextRecord .replaceAll ((x , y ) -> true );
835
+ previousRecords .addAll (internalCurrentRecord .keySet ());
836
+ internalCurrentRecord .clear ();
840
837
}
841
838
}
842
839
}
0 commit comments