Buggy code:
public void flush ( ) { } public void preFlush ( ) { } public void validateChanges ( ) { } public boolean isActive ( ) { } public boolean isStoreActive ( ) { } boolean isTransactionEnding ( ) { } public boolean beginOperation ( boolean syncTrans ) { } public boolean endOperation ( ) { } public Synchronization getSynchronization ( ) { } public void setSynchronization ( Synchronization sync ) { } public void beforeCompletion ( ) { } public void afterCompletion ( int status ) { } private void flushSafe ( int reason ) { } protected void flush ( int reason ) { } private void flushAdditions ( Collection transactional , int reason ) { } private boolean flushTransAdditions ( Collection transactional , int reason ) { } private boolean deleteDerefAdditions ( Collection derefs ) { } private void deleteDeref ( StateManagerImpl sm ) { } private int processArgument ( int op , Object obj , OpenJPAStateManager sm , OpCallbacks call ) { } private OpenJPAException newFlushException ( Collection exceps ) { } protected void endTransaction ( int status ) { } public void persist ( Object obj , OpCallbacks call ) { } public OpenJPAStateManager persist ( Object obj , Object id , OpCallbacks call ) { } public void persistAll ( Collection objs , OpCallbacks call ) { } public void persistAll ( Collection objs , boolean explicit , OpCallbacks call ) { } private List add ( List l , Object o ) { } private void throwNestedExceptions ( List exceps , boolean datastore ) { } public void persist ( Object obj , boolean explicit , OpCallbacks call ) { } public OpenJPAStateManager persist ( Object obj , Object id , boolean explicit , OpCallbacks call ) { } private void cascadeTransient ( int op , Object obj , OpCallbacks call , String errOp ) { } public void deleteAll ( Collection objs , OpCallbacks call ) { } public void delete ( Object obj , OpCallbacks call ) { } void delete ( Object obj , StateManagerImpl sm , OpCallbacks call ) { } private OpenJPAException newDetachedException ( Object obj , String operation ) { } public void releaseAll ( Collection objs , OpCallbacks call ) { } public void release ( Object obj , OpCallbacks call ) { } public OpenJPAStateManager embed ( Object obj , Object id , OpenJPAStateManager owner , ValueMetaData ownerMeta ) { } OpenJPAStateManager copy ( OpenJPAStateManager copy , PCState state ) { } public void refreshAll ( Collection objs , OpCallbacks call ) { } public void refresh ( Object obj , OpCallbacks call ) { } void gatherCascadeRefresh ( Object obj , OpCallbacks call ) { } protected void refreshInternal ( Collection objs , OpCallbacks call ) { List exceps = null ; try { Collection load = null ; StateManagerImpl sm ; Object obj ; for ( Iterator itr = objs . iterator ( ) ; itr . hasNext ( ) ; ) { obj = itr . next ( ) ; if ( obj == null ) continue ; try { sm = getStateManagerImpl ( obj , true ) ; if ( ( ( processArgument ( OP_REFRESH , obj , sm , call ) ) & ( OpCallbacks . ACT_RUN ) ) == 0 ) continue ; if ( sm != null ) { if ( sm . isDetached ( ) ) throw newDetachedException ( obj , "refresh" ) ; else if ( sm . beforeRefresh ( true ) ) { if ( load == null ) load = new ArrayList ( objs . size ( ) ) ; load . add ( sm ) ; } } else if ( ( assertPersistenceCapable ( obj ) . pcIsDetached ( ) ) == ( Boolean . TRUE ) ) throw newDetachedException ( obj , "refresh" ) ; } catch ( OpenJPAException ke ) { exceps = add ( exceps , ke ) ; } } if ( load != null ) { <START_BUG> Collection failed = _store . loadAll ( load , null , _store . FORCE_LOAD_REFRESH , _fc , null ) ; <END_BUG> if ( ( failed != null ) && ( ! ( failed . isEmpty ( ) ) ) ) exceps = add ( exceps , BrokerImpl . newObjectNotFoundException ( failed ) ) ; for ( Iterator itr = load . iterator ( ) ; itr . hasNext ( ) ; ) { sm = ( ( StateManagerImpl ) ( itr . next ( ) ) ) ; if ( ( failed != null ) && ( failed . contains ( sm . getId ( ) ) ) ) continue ; try { sm . afterRefresh ( ) ; sm . load ( _fc , LOAD_FGS , null , null , false ) ; } catch ( OpenJPAException ke ) { exceps = add ( exceps , ke ) ; } } } for ( Iterator itr = objs . iterator ( ) ; itr . hasNext ( ) ; ) { try { sm = getStateManagerImpl ( itr . next ( ) , true ) ; if ( ( sm != null ) && ( ! ( sm . isDetached ( ) ) ) ) fireLifecycleEvent ( sm . getManagedInstance ( ) , null , sm . getMetaData ( ) , AFTER_REFRESH ) ; } catch ( OpenJPAException ke ) { exceps = add ( exceps , ke ) ; } } } catch ( OpenJPAException ke ) { throw ke ; } catch ( RuntimeException re ) { throw new GeneralException ( re ) ; } throwNestedExceptions ( exceps , false ) ; } protected void refreshInternal ( Object obj , OpCallbacks call ) { } public void retrieveAll ( Collection objs , boolean dfgOnly , OpCallbacks call ) { } public void retrieve ( Object obj , boolean dfgOnly , OpCallbacks call ) { } public void evictAll ( OpCallbacks call ) { }

Fix:
Collection failed = _store . loadAll ( load , null , FORCE_LOAD_REFRESH , _fc , null ) ;