@@ -755,7 +755,8 @@ static class KnownObjects {
755755 private final Lock write = lock .writeLock ();
756756
757757 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 <>();
759760 private final Set <Long > idsInCreation = new HashSet <>();
760761
761762 private void storeObject (@ Nullable Long internalId , Object object ) {
@@ -766,7 +767,7 @@ private void storeObject(@Nullable Long internalId, Object object) {
766767 write .lock ();
767768 idsInCreation .remove (internalId );
768769 internalIdStore .put (internalId , object );
769- internalNextRecord .put (internalId , false );
770+ internalCurrentRecord .put (internalId , false );
770771 } finally {
771772 write .unlock ();
772773 }
@@ -837,23 +838,19 @@ private boolean alreadyMappedInPreviousRecord(@Nullable Long internalId) {
837838
838839 read .lock ();
839840
840- Boolean nextRecord = internalNextRecord .get (internalId );
841-
842- if (nextRecord != null ) {
843- return nextRecord ;
844- }
841+ return previousRecords .contains (internalId ) || internalCurrentRecord .get (internalId );
845842
846843 } finally {
847844 read .unlock ();
848845 }
849- return false ;
850846 }
851847
852848 /**
853849 * Mark all currently existing objects as mapped.
854850 */
855851 private void nextRecord () {
856- internalNextRecord .replaceAll ((x , y ) -> true );
852+ previousRecords .addAll (internalCurrentRecord .keySet ());
853+ internalCurrentRecord .clear ();
857854 }
858855 }
859856}
0 commit comments