Buggy code:
public class ExtentImpl implements Extent { private static final ClassMetaData [ ] EMPTY_METAS = new ClassMetaData [ 0 ] ; private final Broker _broker ; private final Class _type ; private final boolean _subs ; private final FetchConfiguration _fc ; private final ReentrantLock _lock ; private boolean _ignore = false ; private ReferenceHashSet _openItrs = null ; ExtentImpl ( Broker broker , Class type , boolean subs , FetchConfiguration fetch ) { } public FetchConfiguration getFetchConfiguration ( ) { } public boolean getIgnoreChanges ( ) { } public void setIgnoreChanges ( boolean ignoreChanges ) { } public List list ( ) { } public Iterator iterator ( ) { _broker . assertNontransactionalRead ( ) ; ExtentImpl . CloseableIterator citr = null ; try { ExtentImpl . CloseableIteratorChain chain = new ExtentImpl . CloseableIteratorChain ( ) ; boolean trans = ( ! ( _ignore ) ) && ( _broker . isActive ( ) ) ; if ( trans ) chain . addIterator ( new ExtentImpl . FilterNewIterator ( ) ) ; <START_BUG> MetaDataRepository repos = _broker . getConfiguration ( ) . getMetaDataRepository ( ) ; <END_BUG> ClassMetaData meta = repos . getMetaData ( _type , _broker . getClassLoader ( ) , false ) ; ClassMetaData [ ] metas ; if ( ( meta != null ) && ( ( meta . isMapped ( ) ) || ( ( _subs ) && ( ( meta . getMappedPCSubclassMetaDatas ( ) . length ) > 0 ) ) ) ) metas = new ClassMetaData [ ] { meta } ; else if ( ( meta == null ) && ( _subs ) ) metas = repos . getImplementorMetaDatas ( _type , _broker . getClassLoader ( ) , false ) ; else metas = ExtentImpl . EMPTY_METAS ; ResultObjectProvider rop ; for ( int i = 0 ; i < ( metas . length ) ; i ++ ) { rop = _broker . getStoreManager ( ) . executeExtent ( metas [ i ] , _subs , _fc ) ; if ( rop != null ) chain . addIterator ( new org . apache . openjpa . lib . rop . ResultObjectProviderIterator ( rop ) ) ; } if ( trans ) citr = new ExtentImpl . FilterDeletedIterator ( chain ) ; else citr = chain ; citr . setRemoveOnClose ( this ) ; } catch ( OpenJPAException ke ) { throw ke ; } catch ( RuntimeException re ) { throw new GeneralException ( re ) ; } lock ( ) ; try { if ( ( _openItrs ) == null ) _openItrs = new ReferenceHashSet ( ReferenceHashSet . WEAK ) ; _openItrs . add ( citr ) ; } finally { unlock ( ) ; } return citr ; } public Broker getBroker ( ) { } public Class getElementType ( ) { } public boolean hasSubclasses ( ) { } public void closeAll ( ) { } public void lock ( ) { } public void unlock ( ) { } private static interface CloseableIterator extends Iterator , Closeable { public void setRemoveOnClose ( ExtentImpl extent ) { } } private static class CloseableIteratorChain extends IteratorChain implements ExtentImpl . CloseableIterator { private ExtentImpl _extent = null ; private boolean _closed = false ; public boolean hasNext ( ) { } public Object next ( ) { } public void remove ( ) { } public void setRemoveOnClose ( ExtentImpl extent ) { } public void close ( ) throws Exception { } } private static class FilterDeletedIterator extends FilterIterator implements Predicate , ExtentImpl . CloseableIterator { private ExtentImpl _extent = null ; private boolean _closed = false ; public FilterDeletedIterator ( Iterator itr ) { } public boolean hasNext ( ) { } public Object next ( ) { } public void remove ( ) { } public void setRemoveOnClose ( ExtentImpl extent ) { } public void close ( ) throws Exception { } public boolean evaluate ( Object o ) { } } private class FilterNewIterator extends FilterIterator implements Predicate , Closeable { public FilterNewIterator ( ) { } public void close ( ) { } public boolean evaluate ( Object o ) { } } }

Fix:
MetaDataRepository repos = _broker . getConfiguration ( ) . getMetaDataRepositoryInstance ( ) ;