Skip to content

Apache Lucene open-source search software

SOLR-3206: fixed the test, will follow up with a root problem fix too.

Dawid Weissad453aeeda70
diff --git a/solr/core/src/java/org/apache/solr/update/UpdateLog.java b/solr/core/src/java/org/apache/solr/update/UpdateLog.java
index e85b4bbe271..0ab9735ff41 100644
--- a/solr/core/src/java/org/apache/solr/update/UpdateLog.java
+++ b/solr/core/src/java/org/apache/solr/update/UpdateLog.java
@@ -49,6 +49,9 @@ import java.util.concurrent.*;
/** @lucene.experimental */
public class UpdateLog implements PluginInfoInitialized {
+ public static String LOG_FILENAME_PATTERN = "%s.%019d";
+ public static String TLOG_NAME="tlog";
+
public static Logger log = LoggerFactory.getLogger(UpdateLog.class);
public boolean debug = log.isDebugEnabled();
public boolean trace = log.isTraceEnabled();
@@ -76,10 +79,6 @@ public class UpdateLog implements PluginInfoInitialized {
}
}
-
-
- public static String TLOG_NAME="tlog";
-
long id = -1;
private State state = State.ACTIVE;
@@ -615,7 +614,7 @@ public class UpdateLog implements PluginInfoInitialized {
private void ensureLog() {
if (tlog == null) {
- String newLogName = String.format(Locale.ENGLISH, "%s.%019d", TLOG_NAME, id);
+ String newLogName = String.format(Locale.ENGLISH, LOG_FILENAME_PATTERN, TLOG_NAME, id);
try {
tlog = new TransactionLog(new File(tlogDir, newLogName), globalStrings);
} catch (IOException e) {
diff --git a/solr/core/src/test/org/apache/solr/search/TestRecovery.java b/solr/core/src/test/org/apache/solr/search/TestRecovery.java
index e253507052b..8e09d86b79f 100644
--- a/solr/core/src/test/org/apache/solr/search/TestRecovery.java
+++ b/solr/core/src/test/org/apache/solr/search/TestRecovery.java
@@ -785,7 +785,11 @@ public class TestRecovery extends SolrTestCaseJ4 {
findReplace("CCCCCC".getBytes("UTF-8"), "cccccc".getBytes("UTF-8"), content);
// WARNING... assumes format of .00000n where n is less than 9
- String fname2 = fname.substring(0, fname.length()-1) + (char)(fname.charAt(fname.length()-1)+1);
+ long logNumber = Long.parseLong(fname.substring(fname.lastIndexOf(".") + 1));
+ String fname2 = String.format(Locale.ENGLISH,
+ UpdateLog.LOG_FILENAME_PATTERN,
+ UpdateLog.TLOG_NAME,
+ logNumber + 1);
raf = new RandomAccessFile(new File(logDir, fname2), "rw");
raf.write(content);
raf.close();