LUCENE-1520: prevent OOM in CheckIndex with large segment that has many fields w/ norms

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@734967 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2009-01-16 10:48:11 +00:00
parent 888af0337d
commit 5c948da5fb

View File

@ -414,7 +414,8 @@ public class CheckIndex {
Iterator it = fieldNames.iterator(); Iterator it = fieldNames.iterator();
while(it.hasNext()) { while(it.hasNext()) {
final String fieldName = (String) it.next(); final String fieldName = (String) it.next();
byte[] b = reader.norms(fieldName); final byte[] b = new byte[reader.maxDoc()];
reader.norms(fieldName, b, 0);
if (b.length != info.docCount) if (b.length != info.docCount)
throw new RuntimeException("norms for field \"" + fieldName + "\" is length " + b.length + " != maxDoc " + info.docCount); throw new RuntimeException("norms for field \"" + fieldName + "\" is length " + b.length + " != maxDoc " + info.docCount);