mirror of https://github.com/apache/lucene.git
LUCENE-2289: check infoStream != null before calling message
git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@917204 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e4702cafd7
commit
1793470004
|
@ -493,10 +493,14 @@ public final class SegmentInfos extends Vector<SegmentInfo> {
|
|||
return infoStream;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints the given message to the infoStream. Note, this method does not
|
||||
* check for null infoStream. It assumes this check has been performed by the
|
||||
* caller, which is recommended to avoid the (usually) expensive message
|
||||
* creation.
|
||||
*/
|
||||
private static void message(String message) {
|
||||
if (infoStream != null) {
|
||||
infoStream.println("SIS [" + Thread.currentThread().getName() + "]: " + message);
|
||||
}
|
||||
infoStream.println("SIS [" + Thread.currentThread().getName() + "]: " + message);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -569,7 +573,9 @@ public final class SegmentInfos extends Vector<SegmentInfo> {
|
|||
if (files != null)
|
||||
genA = getCurrentSegmentGeneration(files);
|
||||
|
||||
message("directory listing genA=" + genA);
|
||||
if (infoStream != null) {
|
||||
message("directory listing genA=" + genA);
|
||||
}
|
||||
|
||||
// Method 2: open segments.gen and read its
|
||||
// contents. Then we take the larger of the two
|
||||
|
@ -582,10 +588,14 @@ public final class SegmentInfos extends Vector<SegmentInfo> {
|
|||
try {
|
||||
genInput = directory.openInput(IndexFileNames.SEGMENTS_GEN);
|
||||
} catch (FileNotFoundException e) {
|
||||
message("segments.gen open: FileNotFoundException " + e);
|
||||
if (infoStream != null) {
|
||||
message("segments.gen open: FileNotFoundException " + e);
|
||||
}
|
||||
break;
|
||||
} catch (IOException e) {
|
||||
message("segments.gen open: IOException " + e);
|
||||
if (infoStream != null) {
|
||||
message("segments.gen open: IOException " + e);
|
||||
}
|
||||
}
|
||||
|
||||
if (genInput != null) {
|
||||
|
@ -594,7 +604,9 @@ public final class SegmentInfos extends Vector<SegmentInfo> {
|
|||
if (version == FORMAT_LOCKLESS) {
|
||||
long gen0 = genInput.readLong();
|
||||
long gen1 = genInput.readLong();
|
||||
message("fallback check: " + gen0 + "; " + gen1);
|
||||
if (infoStream != null) {
|
||||
message("fallback check: " + gen0 + "; " + gen1);
|
||||
}
|
||||
if (gen0 == gen1) {
|
||||
// The file is consistent.
|
||||
genB = gen0;
|
||||
|
@ -614,7 +626,9 @@ public final class SegmentInfos extends Vector<SegmentInfo> {
|
|||
}
|
||||
}
|
||||
|
||||
message(IndexFileNames.SEGMENTS_GEN + " check: genB=" + genB);
|
||||
if (infoStream != null) {
|
||||
message(IndexFileNames.SEGMENTS_GEN + " check: genB=" + genB);
|
||||
}
|
||||
|
||||
// Pick the larger of the two gen's:
|
||||
if (genA > genB)
|
||||
|
@ -639,7 +653,9 @@ public final class SegmentInfos extends Vector<SegmentInfo> {
|
|||
if (genLookaheadCount < defaultGenLookaheadCount) {
|
||||
gen++;
|
||||
genLookaheadCount++;
|
||||
message("look ahead increment gen to " + gen);
|
||||
if (infoStream != null) {
|
||||
message("look ahead increment gen to " + gen);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -674,7 +690,7 @@ public final class SegmentInfos extends Vector<SegmentInfo> {
|
|||
|
||||
try {
|
||||
Object v = doBody(segmentFileName);
|
||||
if (exc != null) {
|
||||
if (exc != null && infoStream != null) {
|
||||
message("success on " + segmentFileName);
|
||||
}
|
||||
return v;
|
||||
|
@ -685,7 +701,9 @@ public final class SegmentInfos extends Vector<SegmentInfo> {
|
|||
exc = err;
|
||||
}
|
||||
|
||||
message("primary Exception on '" + segmentFileName + "': " + err + "'; will retry: retry=" + retry + "; gen = " + gen);
|
||||
if (infoStream != null) {
|
||||
message("primary Exception on '" + segmentFileName + "': " + err + "'; will retry: retry=" + retry + "; gen = " + gen);
|
||||
}
|
||||
|
||||
if (!retry && gen > 1) {
|
||||
|
||||
|
@ -702,13 +720,19 @@ public final class SegmentInfos extends Vector<SegmentInfo> {
|
|||
prevExists = directory.fileExists(prevSegmentFileName);
|
||||
|
||||
if (prevExists) {
|
||||
message("fallback to prior segment file '" + prevSegmentFileName + "'");
|
||||
if (infoStream != null) {
|
||||
message("fallback to prior segment file '" + prevSegmentFileName + "'");
|
||||
}
|
||||
try {
|
||||
Object v = doBody(prevSegmentFileName);
|
||||
message("success on fallback " + prevSegmentFileName);
|
||||
if (infoStream != null) {
|
||||
message("success on fallback " + prevSegmentFileName);
|
||||
}
|
||||
return v;
|
||||
} catch (IOException err2) {
|
||||
message("secondary Exception on '" + prevSegmentFileName + "': " + err2 + "'; will retry");
|
||||
if (infoStream != null) {
|
||||
message("secondary Exception on '" + prevSegmentFileName + "': " + err2 + "'; will retry");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue