@@ -738,7 +738,8 @@ static class KnownObjects {
738738 private final Lock write = lock .writeLock ();
739739
740740 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 <>();
742743 private final Set <Long > idsInCreation = new HashSet <>();
743744
744745 private void storeObject (@ Nullable Long internalId , Object object ) {
@@ -749,7 +750,7 @@ private void storeObject(@Nullable Long internalId, Object object) {
749750 write .lock ();
750751 idsInCreation .remove (internalId );
751752 internalIdStore .put (internalId , object );
752- internalNextRecord .put (internalId , false );
753+ internalCurrentRecord .put (internalId , false );
753754 } finally {
754755 write .unlock ();
755756 }
@@ -820,23 +821,19 @@ private boolean alreadyMappedInPreviousRecord(@Nullable Long internalId) {
820821
821822 read .lock ();
822823
823- Boolean nextRecord = internalNextRecord .get (internalId );
824-
825- if (nextRecord != null ) {
826- return nextRecord ;
827- }
824+ return previousRecords .contains (internalId ) || internalCurrentRecord .get (internalId );
828825
829826 } finally {
830827 read .unlock ();
831828 }
832- return false ;
833829 }
834830
835831 /**
836832 * Mark all currently existing objects as mapped.
837833 */
838834 private void nextRecord () {
839- internalNextRecord .replaceAll ((x , y ) -> true );
835+ previousRecords .addAll (internalCurrentRecord .keySet ());
836+ internalCurrentRecord .clear ();
840837 }
841838 }
842839}
0 commit comments