Program: 168753
Project: 168753
Buggy source:
@Override @SuppressWarnings("String_Node_Str") public boolean flushEntity(UpdateContext context,E entity,Object view,V value,Runnable postReplaceListener){
  if (flushOperation != null) {
    replaceWithRecordingCollection(context,view,value,collectionActions);
    invokeFlushOperation(context,view,entity,value);
    return true;
  }
  if (collectionUpdatable) {
    boolean replace=false;
    boolean wasDirty=false;
    boolean isRecording=value instanceof RecordingCollection<?,?>;
    List<CollectionAction<Collection<?>>> actions=null;
    if (isRecording) {
      RecordingCollection<Collection<?>,?> recordingCollection=(RecordingCollection<Collection<?>,?>)value;
      if (inverseFlusher != null) {
        Map<Object,Object> added;
        Map<Object,Object> removed;
        if (recordingCollection.hasActions()) {
          Map<Object,Object>[] addedAndRemoved=getAddedAndRemovedElements(recordingCollection,(List<CollectionAction<Collection<?>>>)(List<?>)recordingCollection.resetActions(context));
          added=addedAndRemoved[0];
          removed=addedAndRemoved[1];
        }
 else {
          added=removed=new HashMap<>();
        }
        if (flushStrategy == FlushStrategy.ENTITY) {
          visitInverseElementFlushersForActions(context,recordingCollection,added,removed,new ElementFlusherEntityExecutor(context,entity));
        }
 else {
          visitInverseElementFlushersForActions(context,recordingCollection,added,removed,new ElementFlusherQueryExecutor(context,entity,null));
        }
        return true;
      }
      if (elementDescriptor.shouldFlushMutations()) {
        if (elementDescriptor.shouldJpaPersistOrMerge()) {
          wasDirty|=mergeAndRequeue(context,recordingCollection,(Collection<Object>)recordingCollection.getDelegate());
        }
 else         if (elementDescriptor.isSubview() && elementDescriptor.isIdentifiable()) {
          final ViewToEntityMapper viewToEntityMapper=elementDescriptor.getViewToEntityMapper();
          final Iterator<Object> iter=getRecordingIterator(value);
          try {
            while (iter.hasNext()) {
              Object elem=iter.next();
              viewToEntityMapper.applyToEntity(context,null,elem);
            }
          }
  finally {
            resetRecordingIterator(value);
          }
          wasDirty=true;
        }
 else {
          if (fetch && elementDescriptor.supportsDeepEqualityCheck()) {
            Collection<Object> jpaCollection=(Collection<Object>)entityAttributeMapper.getValue(entity);
            EqualityChecker equalityChecker;
            if (elementDescriptor.getBasicUserType() != null) {
              equalityChecker=new DeepEqualityChecker(elementDescriptor.getBasicUserType());
            }
 else {
              equalityChecker=new EntityWithViewEqualityChecker(elementDescriptor.getViewToEntityMapper());
            }
            actions=determineJpaCollectionActions(context,(V)jpaCollection,value,equalityChecker);
            if (actions.size() > value.size()) {
              replace=true;
            }
 else {
              return executeActions(context,jpaCollection,actions,elementDescriptor.getLoadOnlyViewToEntityMapper());
            }
          }
 else {
            replace=true;
          }
        }
      }
      if (!replace) {
        recordingCollection.replay((Collection<?>)entityAttributeMapper.getValue(entity),context,elementDescriptor.getLoadOnlyViewToEntityMapper(),removeListener);
      }
    }
 else {
      actions=new ArrayList<>();
      actions.add(new CollectionClearAction());
      if (value != null && !value.isEmpty()) {
        actions.add(new CollectionAddAllAction(value,collectionInstantiator.allowsDuplicates()));
      }
      value=replaceWithRecordingCollection(context,view,value,actions);
      if (fetch) {
        EqualityChecker equalityChecker=null;
        if (value == null || value.isEmpty()) {
          replace=true;
        }
 else         if (elementDescriptor.shouldFlushMutations()) {
          if (elementDescriptor.shouldJpaPersistOrMerge()) {
            equalityChecker=new IdentityEqualityChecker(elementDescriptor.getBasicUserType());
            wasDirty|=mergeAndRequeue(context,null,(Collection<Object>)value);
          }
 else           if (elementDescriptor.isSubview()) {
            if (elementDescriptor.isIdentifiable()) {
              equalityChecker=EqualsEqualityChecker.INSTANCE;
              ViewToEntityMapper viewToEntityMapper=elementDescriptor.getViewToEntityMapper();
              final Iterator<Object> iter=getRecordingIterator(value);
              try {
                while (iter.hasNext()) {
                  Object elem=iter.next();
                  viewToEntityMapper.applyToEntity(context,null,elem);
                }
              }
  finally {
                resetRecordingIterator(value);
              }
              wasDirty=true;
            }
 else {
              equalityChecker=new EntityWithViewEqualityChecker(elementDescriptor.getViewToEntityMapper());
            }
          }
 else           if (elementDescriptor.supportsDeepEqualityCheck()) {
            equalityChecker=new DeepEqualityChecker(elementDescriptor.getBasicUserType());
          }
 else {
            replace=true;
          }
        }
 else         if (elementDescriptor.supportsEqualityCheck()) {
          equalityChecker=new IdentityEqualityChecker(elementDescriptor.getBasicUserType());
        }
        if (!replace) {
          Collection<Object> jpaCollection=(Collection<Object>)entityAttributeMapper.getValue(entity);
          if (jpaCollection == null || jpaCollection.isEmpty()) {
            replace=true;
          }
 else           if (equalityChecker != null) {
            actions=determineJpaCollectionActions(context,(V)jpaCollection,value,equalityChecker);
            if (actions.size() > value.size()) {
              replace=true;
            }
 else {
              wasDirty|=executeActions(context,jpaCollection,actions,elementDescriptor.getLoadOnlyViewToEntityMapper());
            }
          }
 else {
            replace=true;
          }
        }
      }
 else {
        replace=true;
      }
    }
    if (replace) {
      replaceCollection(context,entity,value);
      return true;
    }
    return wasDirty;
  }
 else   if (elementDescriptor.shouldFlushMutations()) {
    if (value != null && !value.isEmpty()) {
      return mergeCollectionElements(context,view,entity,value);
    }
    return false;
  }
 else {
    replaceCollection(context,entity,value);
    return true;
  }
}

Fixed version (ground truth):
@Override @SuppressWarnings("String_Node_Str") public boolean flushEntity(UpdateContext context,E entity,Object view,V value,Runnable postReplaceListener){
  if (flushOperation != null) {
    replaceWithRecordingCollection(context,view,value,collectionActions);
    invokeFlushOperation(context,view,entity,value);
    return true;
  }
  if (collectionUpdatable) {
    boolean replace=false;
    boolean wasDirty=false;
    boolean isRecording=value instanceof RecordingCollection<?,?>;
    List<CollectionAction<Collection<?>>> actions=null;
    if (isRecording) {
      RecordingCollection<Collection<?>,?> recordingCollection=(RecordingCollection<Collection<?>,?>)value;
      if (inverseFlusher != null) {
        Map<Object,Object> added;
        Map<Object,Object> removed;
        if (recordingCollection.hasActions()) {
          Map<Object,Object>[] addedAndRemoved=getAddedAndRemovedElements(recordingCollection,context);
          added=addedAndRemoved[0];
          removed=addedAndRemoved[1];
        }
 else {
          added=removed=new HashMap<>();
        }
        if (flushStrategy == FlushStrategy.ENTITY) {
          visitInverseElementFlushersForActions(context,recordingCollection,added,removed,new ElementFlusherEntityExecutor(context,entity));
        }
 else {
          visitInverseElementFlushersForActions(context,recordingCollection,added,removed,new ElementFlusherQueryExecutor(context,entity,null));
        }
        return true;
      }
      if (elementDescriptor.shouldFlushMutations()) {
        if (elementDescriptor.shouldJpaPersistOrMerge()) {
          wasDirty|=mergeAndRequeue(context,recordingCollection,(Collection<Object>)recordingCollection.getDelegate());
        }
 else         if (elementDescriptor.isSubview() && elementDescriptor.isIdentifiable()) {
          final ViewToEntityMapper viewToEntityMapper=elementDescriptor.getViewToEntityMapper();
          final Iterator<Object> iter=getRecordingIterator(value);
          try {
            while (iter.hasNext()) {
              Object elem=iter.next();
              viewToEntityMapper.applyToEntity(context,null,elem);
            }
          }
  finally {
            resetRecordingIterator(value);
          }
          wasDirty=true;
        }
 else {
          if (fetch && elementDescriptor.supportsDeepEqualityCheck()) {
            Collection<Object> jpaCollection=(Collection<Object>)entityAttributeMapper.getValue(entity);
            EqualityChecker equalityChecker;
            if (elementDescriptor.getBasicUserType() != null) {
              equalityChecker=new DeepEqualityChecker(elementDescriptor.getBasicUserType());
            }
 else {
              equalityChecker=new EntityWithViewEqualityChecker(elementDescriptor.getViewToEntityMapper());
            }
            actions=determineJpaCollectionActions(context,(V)jpaCollection,value,equalityChecker);
            if (actions.size() > value.size()) {
              replace=true;
            }
 else {
              return executeActions(context,jpaCollection,actions,elementDescriptor.getLoadOnlyViewToEntityMapper());
            }
          }
 else {
            replace=true;
          }
        }
      }
      if (!replace) {
        recordingCollection.replay((Collection<?>)entityAttributeMapper.getValue(entity),context,elementDescriptor.getLoadOnlyViewToEntityMapper(),removeListener);
      }
    }
 else {
      actions=new ArrayList<>();
      actions.add(new CollectionClearAction());
      if (value != null && !value.isEmpty()) {
        actions.add(new CollectionAddAllAction(value,collectionInstantiator.allowsDuplicates()));
      }
      value=replaceWithRecordingCollection(context,view,value,actions);
      if (fetch) {
        EqualityChecker equalityChecker=null;
        if (value == null || value.isEmpty()) {
          replace=true;
        }
 else         if (elementDescriptor.shouldFlushMutations()) {
          if (elementDescriptor.shouldJpaPersistOrMerge()) {
            equalityChecker=new IdentityEqualityChecker(elementDescriptor.getBasicUserType());
            wasDirty|=mergeAndRequeue(context,null,(Collection<Object>)value);
          }
 else           if (elementDescriptor.isSubview()) {
            if (elementDescriptor.isIdentifiable()) {
              equalityChecker=EqualsEqualityChecker.INSTANCE;
              ViewToEntityMapper viewToEntityMapper=elementDescriptor.getViewToEntityMapper();
              final Iterator<Object> iter=getRecordingIterator(value);
              try {
                while (iter.hasNext()) {
                  Object elem=iter.next();
                  viewToEntityMapper.applyToEntity(context,null,elem);
                }
              }
  finally {
                resetRecordingIterator(value);
              }
              wasDirty=true;
            }
 else {
              equalityChecker=new EntityWithViewEqualityChecker(elementDescriptor.getViewToEntityMapper());
            }
          }
 else           if (elementDescriptor.supportsDeepEqualityCheck()) {
            equalityChecker=new DeepEqualityChecker(elementDescriptor.getBasicUserType());
          }
 else {
            replace=true;
          }
        }
 else         if (elementDescriptor.supportsEqualityCheck()) {
          equalityChecker=new IdentityEqualityChecker(elementDescriptor.getBasicUserType());
        }
        if (!replace) {
          Collection<Object> jpaCollection=(Collection<Object>)entityAttributeMapper.getValue(entity);
          if (jpaCollection == null || jpaCollection.isEmpty()) {
            replace=true;
          }
 else           if (equalityChecker != null) {
            actions=determineJpaCollectionActions(context,(V)jpaCollection,value,equalityChecker);
            if (actions.size() > value.size()) {
              replace=true;
            }
 else {
              wasDirty|=executeActions(context,jpaCollection,actions,elementDescriptor.getLoadOnlyViewToEntityMapper());
            }
          }
 else {
            replace=true;
          }
        }
      }
 else {
        replace=true;
      }
    }
    if (replace) {
      replaceCollection(context,entity,value);
      return true;
    }
    return wasDirty;
  }
 else   if (elementDescriptor.shouldFlushMutations()) {
    if (value != null && !value.isEmpty()) {
      return mergeCollectionElements(context,view,entity,value);
    }
    return false;
  }
 else {
    replaceCollection(context,entity,value);
    return true;
  }
}