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 < Object > checkCache ( QueryKey qk ) { if ( qk == null ) return null ; FetchConfiguration fetch = getContext ( ) . getFetchConfiguration ( ) ; if ( ! ( fetch . getQueryCacheEnabled ( ) ) ) return null ; if ( ( fetch . getReadLockLevel ( ) ) > ( LockLevels . LOCK_NONE ) ) return null ; QueryResult res = _cache . get ( qk ) ; if ( res == null ) { return null ; } if ( ( _cache ) instanceof AbstractQueryCache ) { AbstractQueryCache qcache = ( ( AbstractQueryCache ) ( _cache ) ) ; if ( ( qcache . getEvictPolicy ( ) ) == ( EvictPolicy . TIMESTAMP ) ) { Set < String > classNames = qk . getAcessPathClassNames ( ) ; List < String > keyList = new ArrayList < String > ( ) ; keyList . addAll ( classNames ) ; List < Long > timestamps = qcache . getAllEntityTimestamp ( keyList ) ; long queryTS = res . getTimestamp ( ) ; if ( timestamps != null ) { for ( Long ts : timestamps ) { <START_BUG> if ( queryTS < ts ) { <END_BUG> qcache . remove ( qk ) ; return null ; } } } } } if ( res . isEmpty ( ) ) { return Collections . emptyList ( ) ; } int projs = getContext ( ) . getProjectionAliases ( ) . length ; if ( projs == 0 ) { if ( ( getContext ( ) . getStoreContext ( ) . isCached ( res ) ) == false ) { return null ; } } return new QueryCacheStoreQuery . CachedList ( res , ( projs != 0 ) , _sctx ) ; } 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 ) { } 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 ( ) { } public Object evaluate ( Object value , Object ob , Object [ ] params , OpenJPAStateManager sm ) { } private static class QueryCacheExecutor implements Executor { private final Executor _ex ; private final Class < ? > _candidate ; private final boolean _subs ; private final FetchConfiguration _fc ; public QueryCacheExecutor ( Executor ex , ClassMetaData meta , boolean subs , FetchConfiguration fc ) { } public ResultObjectProvider executeQuery ( StoreQuery q , Object [ ] params , Range range ) { } public QueryExpressions [ ] getQueryExpressions ( ) { } private void clearAccessPath ( StoreQuery q ) { } public Number executeDelete ( StoreQuery q , Object [ ] params ) { } public Number executeUpdate ( StoreQuery q , Object [ ] params ) { } public String [ ] getDataStoreActions ( StoreQuery q , Object [ ] params , Range range ) { } public void validate ( StoreQuery q ) { } public void getRange ( StoreQuery q , Object [ ] params , Range range ) { } 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 ResultShape < ? > getResultShape ( 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 isDistinct ( StoreQuery q ) { } public boolean hasGrouping ( StoreQuery q ) { } public OrderedMap < Object , Class < ? > > getOrderedParameterTypes ( StoreQuery q ) { } public LinkedMap getParameterTypes ( StoreQuery q ) { } public Object [ ] toParameterArray ( StoreQuery q , Map userParams ) { } public Map getUpdates ( StoreQuery q ) { } private static StoreQuery unwrap ( StoreQuery q ) { } } public static class CachedList extends AbstractList < Object > 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 ;

Fix:
if ( queryTS <= ts ) {