Turn some "assert false" in switch and switch-like statements into AssertionErrors. If we get into the default block we are wrong and we can also throw Ex, because then there is logic error (e.g. after new enum constant was added)

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1379450 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Uwe Schindler 2012-08-31 13:55:25 +00:00
parent 63a95f1175
commit 8f88aa6497
8 changed files with 9 additions and 10 deletions

View File

@ -170,7 +170,7 @@ public class DocMaker implements Closeable {
f = new DoubleField(name, 0.0, Field.Store.NO);
break;
default:
assert false;
throw new AssertionError("Cannot get here");
}
if (reuseFields) {
numericFields.put(name, f);

View File

@ -186,7 +186,7 @@ public final class Lucene40StoredFieldsWriter extends StoredFieldsWriter {
} else if (number instanceof Double) {
fieldsStream.writeLong(Double.doubleToLongBits(number.doubleValue()));
} else {
assert false;
throw new AssertionError("Cannot get here");
}
}
}

View File

@ -521,7 +521,7 @@ public class Field implements IndexableField {
nts.setDoubleValue(val.doubleValue());
break;
default:
assert false : "Should never get here";
throw new AssertionError("Should never get here");
}
return internalTokenStream;
}

View File

@ -365,7 +365,7 @@ final class DocumentsWriter {
if (!perThread.isActive()) {
ensureOpen();
assert false: "perThread is not active but we are still open";
throw new IllegalStateException("perThread is not active but we are still open");
}
final DocumentsWriterPerThread dwpt = perThread.dwpt;

View File

@ -324,7 +324,7 @@ final class DocumentsWriterDeleteQueue {
.newUpdater(Node.class, Node.class, "next");
void apply(BufferedDeletes bufferedDeletes, int docIDUpto) {
assert false : "sentinel item must never be applied";
throw new IllegalStateException("sentinel item must never be applied");
}
boolean casNext(Node<?> cmp, Node<?> val) {

View File

@ -401,8 +401,8 @@ public final class MultiTermsEnum extends TermsEnum {
subDocs[upto].slice = entry.subSlice;
upto++;
} else {
// One of our subs cannot provide a docsenum:
assert false;
// should this be an error?
assert false : "One of our subs cannot provide a docsenum";
}
}

View File

@ -362,8 +362,7 @@ public abstract class BufferedIndexInput extends IndexInput {
case MERGE:
return MERGE_BUFFER_SIZE;
default:
assert false : "unknown IOContext " + context.context;
return BUFFER_SIZE;
throw new AssertionError("unknown IOContext " + context.context);
}
}

View File

@ -223,7 +223,7 @@ public class TestNumericQueryParser extends LuceneTestCase {
field = new DoubleField(type.name(), 0.0, ft);
break;
default:
assert false;
fail();
field = null;
}
numericFieldMap.put(type.name(), field);