Buggy code:
public class DetachManager implements DetachState { private static Localizer _loc = Localizer . forPackage ( DetachManager . class ) ; private final BrokerImpl _broker ; private final boolean _copy ; private final boolean _full ; private final ProxyManager _proxy ; private final DetachOptions _opts ; private final OpCallbacks _call ; private final boolean _failFast ; private boolean _flushed = false ; private final IdentityMap _detached ; private final DetachManager . DetachFieldManager _fullFM ; static boolean preSerialize ( StateManagerImpl sm ) { } static boolean writeDetachedState ( StateManagerImpl sm , ObjectOutput out , BitSet idxs ) throws IOException { } private static void preDetach ( Broker broker , StateManagerImpl sm , BitSet idxs ) { } private static Object getDetachedState ( StateManagerImpl sm , BitSet fields ) { } private static boolean flushDirty ( StateManagerImpl sm ) { <START_BUG> if ( ! ( sm . isDirty ( ) ) ) <END_BUG> return false ; BitSet dirtyFields = sm . getDirty ( ) ; BitSet flushedFields = sm . getFlushed ( ) ; for ( int i = 0 ; i < ( dirtyFields . size ( ) ) ; i ++ ) { if ( ( dirtyFields . get ( i ) ) && ( ! ( flushedFields . get ( i ) ) ) ) { if ( sm . getBroker ( ) . getRollbackOnly ( ) ) sm . getBroker ( ) . preFlush ( ) ; else sm . getBroker ( ) . flush ( ) ; return true ; } } return false ; } private static void setFetchGroupFields ( Broker broker , StateManagerImpl sm , BitSet idxs ) { } public DetachManager ( BrokerImpl broker , boolean full , OpCallbacks call ) { } public Object detach ( Object toDetach ) { } public Object [ ] detachAll ( Collection instances ) { } private List invokeAfterDetach ( Collection objs , List exceps ) { } private List add ( List exceps , RuntimeException re ) { } private void throwExceptions ( List exceps ) { } private Object detachInternal ( Object toDetach ) { } private static boolean useDetachedStateManager ( StateManagerImpl sm , DetachOptions opts ) { } private static class DetachFieldManager extends TransferFieldManager { protected StateManagerImpl sm ; public void setStateManager ( StateManagerImpl sm ) { } public void detachVersion ( ) { } public void reproxy ( DetachedStateManager dsm ) { } protected PersistenceCapable getDetachedPersistenceCapable ( ) { } } private class InstanceDetachFieldManager extends DetachManager . DetachFieldManager { private final PersistenceCapable _to ; private final DetachedStateManager _detSM ; public InstanceDetachFieldManager ( PersistenceCapable to , DetachedStateManager detSM ) { } protected PersistenceCapable getDetachedPersistenceCapable ( ) { } public void detachFields ( BitSet fgfields ) { } private void detachField ( PersistenceCapable from , int i , boolean fg ) { } public void storeBooleanField ( int field , boolean curVal ) { } public void storeByteField ( int field , byte curVal ) { } public void storeCharField ( int field , char curVal ) { } public void storeDoubleField ( int field , double curVal ) { } public void storeFloatField ( int field , float curVal ) { } public void storeIntField ( int field , int curVal ) { } public void storeLongField ( int field , long curVal ) { } public void storeShortField ( int field , short curVal ) { } public void storeStringField ( int field , String curVal ) { } public void storeObjectField ( int field , Object curVal ) { } private Object reproxy ( Object obj , int field ) { } private Object detachField ( Object curVal , int field ) { } private void detachArray ( Object array , FieldMetaData fmd ) { } private void detachCollection ( Collection coll , Collection orig , FieldMetaData fmd ) { } private void detachMap ( Map map , Map orig , FieldMetaData fmd ) { } } }

Fix:
if ( ( ! ( sm . isDirty ( ) ) ) || ( ! ( sm . getBroker ( ) . isActive ( ) ) ) )