Buggy code:
@ SuppressCodecs ( { "Lucene3x" , "MockFixedIntBlock" , "MockVariableIntBlock" , "MockSep" , "MockRandom" } ) public class TestBackwardsCompatibility3x extends LuceneTestCase { static final String [ ] oldNames = new String [ ] { "30.cfs" , "30.nocfs" , "31.cfs" , "31.nocfs" , "32.cfs" , "32.nocfs" , "34.cfs" , "34.nocfs" } ; final String [ ] unsupportedNames = new String [ ] { "19.cfs" , "19.nocfs" , "20.cfs" , "20.nocfs" , "21.cfs" , "21.nocfs" , "22.cfs" , "22.nocfs" , "23.cfs" , "23.nocfs" , "24.cfs" , "24.nocfs" , "29.cfs" , "29.nocfs" } ; static final String [ ] oldSingleSegmentNames = new String [ ] { "31.optimized.cfs" , "31.optimized.nocfs" } ; static Map < String , Directory > oldIndexDirs ; @ BeforeClass public static void beforeClass ( ) throws Exception { } @ AfterClass public static void afterClass ( ) throws Exception { } public void testUnsupportedOldIndexes ( ) throws Exception { } public void testFullyMergeOldIndex ( ) throws Exception { } public void testAddOldIndexes ( ) throws IOException { } public void testAddOldIndexesReader ( ) throws IOException { } public void testSearchOldIndex ( ) throws IOException { } public void testIndexOldIndexNoAdds ( ) throws IOException { } public void testIndexOldIndex ( ) throws IOException { } @ Deprecated public void testDeleteOldIndex ( ) throws IOException { } private void doTestHits ( ScoreDoc [ ] hits , int expectedCount , IndexReader reader ) throws IOException { } public void searchIndex ( Directory dir , String oldName ) throws IOException { } private int compare ( String name , String v ) { } public void changeIndexWithAdds ( Random random , Directory dir , String origOldName ) throws IOException { } public void changeIndexNoAdds ( Random random , Directory dir ) throws IOException { } public File createIndex ( String dirName , boolean doCFS , boolean fullyMerged ) throws IOException { } public void testExactFileNames ( ) throws IOException { } private String asString ( String [ ] l ) { } private void addDoc ( IndexWriter writer , int id ) throws IOException { } private void addNoProxDoc ( IndexWriter writer ) throws IOException { } private int countDocs ( DocsEnum docs ) throws IOException { } public void testNextIntoWrongField ( ) throws Exception { } public void testOldVersions ( ) throws Exception { } public void testNumericFields ( ) throws Exception { } private int checkAllSegmentsUpgraded ( Directory dir ) throws IOException { } private int getNumberOfSegments ( Directory dir ) throws IOException { } public void testUpgradeOldIndex ( ) throws Exception { } public void testUpgradeOldSingleSegmentIndexWithAdditions ( ) throws Exception { } public static final String surrogatesIndexName = "index.36.surrogates.zip" ; public void testSurrogates ( ) throws Exception { } public static final String bogus24IndexName = "bogus24.upgraded.to.36.zip" ; public void testNegativePositions ( ) throws Exception { File oldIndexDir = _TestUtil . getTempDir ( "negatives" ) ; _TestUtil . unzip ( getDataFile ( TestBackwardsCompatibility3x . bogus24IndexName ) , oldIndexDir ) ; Directory dir = newFSDirectory ( oldIndexDir ) ; DirectoryReader ir = DirectoryReader . open ( dir ) ; IndexSearcher is = new IndexSearcher ( ir ) ; PhraseQuery pq = new PhraseQuery ( ) ; pq . add ( new Term ( "field3" , "more" ) ) ; pq . add ( new Term ( "field3" , "text" ) ) ; TopDocs td = is . search ( pq , 10 ) ; assertEquals ( 1 , td . totalHits ) ; <START_BUG> SlowCompositeReaderWrapper wrapper = new SlowCompositeReaderWrapper ( ir ) ; <END_BUG> DocsAndPositionsEnum de = wrapper . termPositionsEnum ( new Term ( "field3" , "broken" ) ) ; assert de != null ; assertEquals ( 0 , de . nextDoc ( ) ) ; assertEquals ( 0 , de . nextPosition ( ) ) ; ir . close ( ) ; _TestUtil . checkIndex ( dir ) ; dir . close ( ) ; } }

Fix:
AtomicReader wrapper = SlowCompositeReaderWrapper . wrap ( ir ) ;