Buggy code:
public class TestMatchAllDocsQuery extends LuceneTestCase { private Analyzer analyzer = new org . apache . lucene . analysis . standard . StandardAnalyzer ( Version . LUCENE_CURRENT ) ; public void testQuery ( ) throws Exception { RAMDirectory dir = new RAMDirectory ( ) ; IndexWriter iw = new IndexWriter ( dir , analyzer , true , MaxFieldLength . LIMITED ) ; iw . setMaxBufferedDocs ( 2 ) ; addDoc ( "one" , iw , 1.0F ) ; addDoc ( "two" , iw , 20.0F ) ; addDoc ( "three<seq2seq4repair_space>four" , iw , 300.0F ) ; iw . close ( ) ; IndexReader ir = IndexReader . open ( dir , false ) ; IndexSearcher is = new IndexSearcher ( ir ) ; ScoreDoc [ ] hits ; hits = is . search ( new MatchAllDocsQuery ( ) , null , 1000 ) . scoreDocs ; assertEquals ( 3 , hits . length ) ; assertEquals ( "one" , ir . document ( hits [ 0 ] . doc ) . get ( "key" ) ) ; assertEquals ( "two" , ir . document ( hits [ 1 ] . doc ) . get ( "key" ) ) ; assertEquals ( "three<seq2seq4repair_space>four" , ir . document ( hits [ 2 ] . doc ) . get ( "key" ) ) ; MatchAllDocsQuery normsQuery = new MatchAllDocsQuery ( "key" ) ; hits = is . search ( normsQuery , null , 1000 ) . scoreDocs ; assertEquals ( 3 , hits . length ) ; assertEquals ( "three<seq2seq4repair_space>four" , ir . document ( hits [ 0 ] . doc ) . get ( "key" ) ) ; assertEquals ( "two" , ir . document ( hits [ 1 ] . doc ) . get ( "key" ) ) ; assertEquals ( "one" , ir . document ( hits [ 2 ] . doc ) . get ( "key" ) ) ; ir . setNorm ( 0 , "key" , 400.0F ) ; normsQuery = new MatchAllDocsQuery ( "key" ) ; hits = is . search ( normsQuery , null , 1000 ) . scoreDocs ; assertEquals ( 3 , hits . length ) ; assertEquals ( "one" , ir . document ( hits [ 0 ] . doc ) . get ( "key" ) ) ; assertEquals ( "three<seq2seq4repair_space>four" , ir . document ( hits [ 1 ] . doc ) . get ( "key" ) ) ; assertEquals ( "two" , ir . document ( hits [ 2 ] . doc ) . get ( "key" ) ) ; BooleanQuery bq = new BooleanQuery ( ) ; bq . add ( new MatchAllDocsQuery ( ) , MUST ) ; bq . add ( new MatchAllDocsQuery ( ) , MUST ) ; hits = is . search ( bq , null , 1000 ) . scoreDocs ; assertEquals ( 3 , hits . length ) ; bq = new BooleanQuery ( ) ; bq . add ( new MatchAllDocsQuery ( ) , MUST ) ; bq . add ( new TermQuery ( new Term ( "key" , "three" ) ) , MUST ) ; hits = is . search ( bq , null , 1000 ) . scoreDocs ; assertEquals ( 1 , hits . length ) ; is . getIndexReader ( ) . deleteDocument ( 0 ) ; hits = is . search ( new MatchAllDocsQuery ( ) , null , 1000 ) . scoreDocs ; assertEquals ( 2 , hits . length ) ; <START_BUG> QueryParser qp = new QueryParser ( "key" , analyzer ) ; <END_BUG> hits = is . search ( qp . parse ( new MatchAllDocsQuery ( ) . toString ( ) ) , null , 1000 ) . scoreDocs ; assertEquals ( 2 , hits . length ) ; Query maq = new MatchAllDocsQuery ( ) ; maq . setBoost ( 2.3F ) ; Query pq = qp . parse ( maq . toString ( ) ) ; hits = is . search ( pq , null , 1000 ) . scoreDocs ; assertEquals ( 2 , hits . length ) ; is . close ( ) ; ir . close ( ) ; dir . close ( ) ; } public void testEquals ( ) { } private void addDoc ( String text , IndexWriter iw , float boost ) throws IOException { } }

Fix:
QueryParser qp = new QueryParser ( Version . LUCENE_CURRENT , "key" , analyzer ) ;