Buggy code:
public class TestWildcard extends LuceneTestCase { public void testEquals ( ) { } public void testTermWithoutWildcard ( ) throws IOException { } public void testEmptyTerm ( ) throws IOException { } public void testPrefixTerm ( ) throws IOException { } public void testAsterisk ( ) throws IOException { } public void testQuestionmark ( ) throws IOException { } private RAMDirectory getIndexStore ( String field , String [ ] contents ) throws IOException { } private void assertMatches ( IndexSearcher searcher , Query q , int expectedMatches ) throws IOException { } public void testParsingAndSearching ( ) throws Exception { String field = "content" ; boolean dbg = false ; <START_BUG> QueryParser qp = new QueryParser ( Version . LUCENE_CURRENT , field , new WhitespaceAnalyzer ( ) ) ; <END_BUG> qp . setAllowLeadingWildcard ( true ) ; String [ ] docs = new String [ ] { "\\<seq2seq4repair_space>abcdefg1" , "\\79<seq2seq4repair_space>hijklmn1" , "\\\\<seq2seq4repair_space>opqrstu1" } ; String [ ] matchAll = new String [ ] { "*" , "*1" , "**1" , "*?" , "*?1" , "?*1" , "**" , "***" , "\\\\*" } ; String [ ] matchNone = new String [ ] { "a*h" , "a?h" , "*a*h" , "?a" , "a?" } ; String [ ] [ ] matchOneDocPrefix = new String [ ] [ ] { new String [ ] { "a*" , "ab*" , "abc*" } , new String [ ] { "h*" , "hi*" , "hij*" , "\\\\7*" } , new String [ ] { "o*" , "op*" , "opq*" , "\\\\\\\\*" } } ; String [ ] [ ] matchOneDocWild = new String [ ] [ ] { new String [ ] { "*a*" , "*ab*" , "*abc**" , "ab*e*" , "*g?" , "*f?1" , "abc**" } , new String [ ] { "*h*" , "*hi*" , "*hij**" , "hi*k*" , "*n?" , "*m?1" , "hij**" } , new String [ ] { "*o*" , "*op*" , "*opq**" , "op*q*" , "*u?" , "*t?1" , "opq**" } } ; RAMDirectory dir = new RAMDirectory ( ) ; IndexWriter iw = new IndexWriter ( dir , new WhitespaceAnalyzer ( ) , MaxFieldLength . LIMITED ) ; for ( int i = 0 ; i < ( docs . length ) ; i ++ ) { Document doc = new Document ( ) ; doc . add ( new org . apache . lucene . document . Field ( field , docs [ i ] , Store . NO , Index . ANALYZED ) ) ; iw . addDocument ( doc ) ; } iw . close ( ) ; IndexSearcher searcher = new IndexSearcher ( dir , true ) ; for ( int i = 0 ; i < ( matchAll . length ) ; i ++ ) { String qtxt = matchAll [ i ] ; Query q = qp . parse ( qtxt ) ; if ( dbg ) System . out . println ( ( ( ( ( ( "matchAll:<seq2seq4repair_space>qtxt=" + qtxt ) + "<seq2seq4repair_space>q=" ) + q ) + "<seq2seq4repair_space>" ) + ( q . getClass ( ) . getName ( ) ) ) ) ; ScoreDoc [ ] hits = searcher . search ( q , null , 1000 ) . scoreDocs ; assertEquals ( docs . length , hits . length ) ; } for ( int i = 0 ; i < ( matchNone . length ) ; i ++ ) { String qtxt = matchNone [ i ] ; Query q = qp . parse ( qtxt ) ; if ( dbg ) System . out . println ( ( ( ( ( ( "matchNone:<seq2seq4repair_space>qtxt=" + qtxt ) + "<seq2seq4repair_space>q=" ) + q ) + "<seq2seq4repair_space>" ) + ( q . getClass ( ) . getName ( ) ) ) ) ; ScoreDoc [ ] hits = searcher . search ( q , null , 1000 ) . scoreDocs ; assertEquals ( 0 , hits . length ) ; } for ( int i = 0 ; i < ( matchOneDocPrefix . length ) ; i ++ ) { for ( int j = 0 ; j < ( matchOneDocPrefix [ i ] . length ) ; j ++ ) { String qtxt = matchOneDocPrefix [ i ] [ j ] ; Query q = qp . parse ( qtxt ) ; if ( dbg ) System . out . println ( ( ( ( ( ( ( ( "match<seq2seq4repair_space>1<seq2seq4repair_space>prefix:<seq2seq4repair_space>doc=" + ( docs [ i ] ) ) + "<seq2seq4repair_space>qtxt=" ) + qtxt ) + "<seq2seq4repair_space>q=" ) + q ) + "<seq2seq4repair_space>" ) + ( q . getClass ( ) . getName ( ) ) ) ) ; assertEquals ( PrefixQuery . class , q . getClass ( ) ) ; ScoreDoc [ ] hits = searcher . search ( q , null , 1000 ) . scoreDocs ; assertEquals ( 1 , hits . length ) ; assertEquals ( i , hits [ 0 ] . doc ) ; } } for ( int i = 0 ; i < ( matchOneDocPrefix . length ) ; i ++ ) { for ( int j = 0 ; j < ( matchOneDocWild [ i ] . length ) ; j ++ ) { String qtxt = matchOneDocWild [ i ] [ j ] ; Query q = qp . parse ( qtxt ) ; if ( dbg ) System . out . println ( ( ( ( ( ( ( ( "match<seq2seq4repair_space>1<seq2seq4repair_space>wild:<seq2seq4repair_space>doc=" + ( docs [ i ] ) ) + "<seq2seq4repair_space>qtxt=" ) + qtxt ) + "<seq2seq4repair_space>q=" ) + q ) + "<seq2seq4repair_space>" ) + ( q . getClass ( ) . getName ( ) ) ) ) ; assertEquals ( WildcardQuery . class , q . getClass ( ) ) ; ScoreDoc [ ] hits = searcher . search ( q , null , 1000 ) . scoreDocs ; assertEquals ( 1 , hits . length ) ;

Fix:
QueryParser qp = new QueryParser ( TEST_VERSION_CURRENT , field , new WhitespaceAnalyzer ( ) ) ;