Buggy code:
public class QueryCacheStoreQuery implements StoreQuery { private final StoreQuery _query ; private final QueryCache _cache ; private StoreContext _sctx ; private MetaDataRepository _repos ; public QueryCacheStoreQuery ( StoreQuery query , QueryCache cache ) { } public QueryCache getCache ( ) { } public StoreQuery getDelegate ( ) { } private List checkCache ( QueryKey qk ) { } private ResultObjectProvider wrapResult ( ResultObjectProvider rop , QueryKey key ) { } private static Object copyProjection ( Object obj , StoreContext ctx ) { } private static Object fromObjectId ( Object oid , StoreContext sctx ) { } public Object writeReplace ( ) throws ObjectStreamException { } public QueryContext getContext ( ) { } public void setContext ( QueryContext qctx ) { _query . setContext ( qctx ) ; _sctx = qctx . getStoreContext ( ) ; <START_BUG> _repos = _sctx . getConfiguration ( ) . getMetaDataRepository ( ) ; <END_BUG> } public boolean setQuery ( Object query ) { } public FilterListener getFilterListener ( String tag ) { } public AggregateListener getAggregateListener ( String tag ) { } public Object newCompilationKey ( ) { } public Object newCompilation ( ) { } public void populateFromCompilation ( Object comp ) { } public void invalidateCompilation ( ) { } public boolean supportsDataStoreExecution ( ) { } public boolean supportsInMemoryExecution ( ) { } public Executor newInMemoryExecutor ( ClassMetaData meta , boolean subs ) { } public Executor newDataStoreExecutor ( ClassMetaData meta , boolean subs ) { } public boolean supportsAbstractExecutors ( ) { } public boolean requiresCandidateType ( ) { } public boolean requiresParameterDeclarations ( ) { } public boolean supportsParameterDeclarations ( ) { } private static class QueryCacheExecutor implements Executor { private final Executor _ex ; private final Class _candidate ; private final boolean _subs ; public QueryCacheExecutor ( Executor ex , ClassMetaData meta , boolean subs ) { } public ResultObjectProvider executeQuery ( StoreQuery q , Object [ ] params , boolean lrs , long startIdx , long endIdx ) { } public ResultObjectProvider executeQuery ( StoreQuery q , Map params , boolean lrs , long startIdx , long endIdx ) { } private void clearAccesssPath ( StoreQuery q ) { } public Number executeDelete ( StoreQuery q , Object [ ] params ) { } public Number executeDelete ( StoreQuery q , Map params ) { } public Number executeUpdate ( StoreQuery q , Object [ ] params ) { } public Number executeUpdate ( StoreQuery q , Map params ) { } public String [ ] getDataStoreActions ( StoreQuery q , Object [ ] params , long startIdx , long endIdx ) { } public Object getOrderingValue ( StoreQuery q , Object [ ] params , Object resultObject , int orderIndex ) { } public boolean [ ] getAscending ( StoreQuery q ) { } public boolean isPacking ( StoreQuery q ) { } public String getAlias ( StoreQuery q ) { } public Class getResultClass ( StoreQuery q ) { } public String [ ] getProjectionAliases ( StoreQuery q ) { } public Class [ ] getProjectionTypes ( StoreQuery q ) { } public ClassMetaData [ ] getAccessPathMetaDatas ( StoreQuery q ) { } public int getOperation ( StoreQuery q ) { } public boolean isAggregate ( StoreQuery q ) { } public boolean hasGrouping ( StoreQuery q ) { } public LinkedMap getParameterTypes ( StoreQuery q ) { } public Map getUpdates ( StoreQuery q ) { } private static StoreQuery unwrap ( StoreQuery q ) { } } public static class CachedList extends AbstractList implements Serializable { private final QueryResult _res ; private final boolean _proj ; private final StoreContext _sctx ; public CachedList ( QueryResult res , boolean proj , StoreContext ctx ) { } public Object get ( int idx ) { } public int size ( ) { } public Object writeReplace ( ) throws ObjectStreamException { } } private class CachingResultObjectProvider implements TypesChangedListener , ResultObjectProvider { private final ResultObjectProvider _rop ; private final boolean _proj ; private final QueryKey _qk ; private final TreeMap _data = new TreeMap ( ) ; private boolean _maintainCache = true ; private int _pos = - 1 ; private int _max = - 1 ; private int _size = Integer . MAX_VALUE ; public CachingResultObjectProvider ( ResultObjectProvider rop , boolean proj , QueryKey key ) { } private void abortCaching ( ) { } private void checkFinished ( Object obj , boolean result ) { } public boolean supportsRandomAccess ( ) { } public void open ( ) throws Exception { } public Object getResultObject ( ) throws Exception { } public boolean next ( ) throws Exception { } public boolean absolute ( int pos ) throws Exception { } public int size ( ) throws Exception { } public void reset ( ) throws Exception { } public void close ( ) throws Exception { } public void handleCheckedException ( Exception e ) { } public void onTypesChanged ( TypesChangedEvent ev ) { } } private static class CachedObjectId { public final Object oid ; public CachedObjectId ( Object oid ) { } } }

Fix:
_repos = _sctx . getConfiguration ( ) . getMetaDataRepositoryInstance ( ) ;