Skip to content

Apache Lucene open-source search software

Fix some strange things on ApacheCon

Uwe Schindlere69b4d43f609
diff --git a/src/java/org/apache/lucene/index/SegmentInfo.java b/src/java/org/apache/lucene/index/SegmentInfo.java
index f4296088eac..bd748cdc856 100644
--- a/src/java/org/apache/lucene/index/SegmentInfo.java
+++ b/src/java/org/apache/lucene/index/SegmentInfo.java
@@ -152,12 +152,10 @@ public final class SegmentInfo {
delCount = src.delCount;
}
- // must be Map<String, String>
void setDiagnostics(Map<String, String> diagnostics) {
this.diagnostics = diagnostics;
}
- // returns Map<String, String>
public Map<String, String> getDiagnostics() {
return diagnostics;
}
@@ -714,13 +712,13 @@ public final class SegmentInfo {
* has the same dir and same name. */
@Override
public boolean equals(Object obj) {
- SegmentInfo other;
- try {
- other = (SegmentInfo) obj;
- } catch (ClassCastException cce) {
+ if (this == obj) return true;
+ if (obj instanceof SegmentInfo) {
+ final SegmentInfo other = (SegmentInfo) obj;
+ return other.dir == dir && other.name.equals(name);
+ } else {
return false;
}
- return other.dir == dir && other.name.equals(name);
}
@Override
diff --git a/src/java/org/apache/lucene/index/SegmentInfos.java b/src/java/org/apache/lucene/index/SegmentInfos.java
index 809a7298d31..374ae68fb4a 100644
--- a/src/java/org/apache/lucene/index/SegmentInfos.java
+++ b/src/java/org/apache/lucene/index/SegmentInfos.java
@@ -28,6 +28,7 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.PrintStream;
import java.util.Vector;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
@@ -648,14 +649,7 @@ public final class SegmentInfos extends Vector<SegmentInfo> {
if (gen == -1) {
// Neither approach found a generation
- String s;
- if (files != null) {
- s = "";
- for(int i=0;i<files.length;i++)
- s += " " + files[i];
- } else
- s = " null";
- throw new FileNotFoundException("no segments* file found in " + directory + ": files:" + s);
+ throw new FileNotFoundException("no segments* file found in " + directory + ": files: " + Arrays.toString(files));
}
}
diff --git a/src/java/org/apache/lucene/messages/MessageImpl.java b/src/java/org/apache/lucene/messages/MessageImpl.java
index 7cb525ea94f..cb837351f12 100644
--- a/src/java/org/apache/lucene/messages/MessageImpl.java
+++ b/src/java/org/apache/lucene/messages/MessageImpl.java
@@ -60,13 +60,13 @@ public class MessageImpl implements Message {
@Override
public String toString() {
Object[] args = getArguments();
- String argsString = "";
+ StringBuilder sb = new StringBuilder(getKey());
if (args != null) {
for (int i = 0; i < args.length; i++) {
- argsString += args[i] + (i < args.length ? "" : ", ");
+ sb.append(i == 0 ? " " : ", ").append(args[i]);
}
}
- return getKey() + " " + argsString;
+ return sb.toString();
}
}