Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

Forbidden-API: Path.startsWith(String) (#3303)

David Smiley51f06f18684a
diff --git a/gradle/validation/forbidden-apis/defaults.all.txt b/gradle/validation/forbidden-apis/defaults.all.txt
index 211968725dd..a8be2d60091 100644
--- a/gradle/validation/forbidden-apis/defaults.all.txt
+++ b/gradle/validation/forbidden-apis/defaults.all.txt
@@ -97,3 +97,6 @@ java.util.Locale#<init>(**)
@defaultMessage Use Path.of(...) methods instead.
java.nio.file.Paths#get(**)
+
+@defaultMessage You probably meant to call String.startsWith
+java.nio.file.Path#startsWith(java.lang.String)
\ No newline at end of file
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 837f031ccec..9993e1bb642 100644
--- a/solr/core/src/java/org/apache/solr/update/UpdateLog.java
+++ b/solr/core/src/java/org/apache/solr/update/UpdateLog.java
@@ -350,8 +350,9 @@ public class UpdateLog implements PluginInfoInitialized, SolrMetricProducer {
public static Path ulogToTlogDir(
String coreName, Path ulogDirPath, Path instancePath, String coreDataDir) {
+ final Path coreDataPath = ulogDirPath.getFileSystem().getPath(coreDataDir);
boolean unscopedDataDir =
- !ulogDirPath.startsWith(instancePath) && !ulogDirPath.startsWith(coreDataDir);
+ !ulogDirPath.startsWith(instancePath) && !ulogDirPath.startsWith(coreDataPath);
// if the ulog dataDir is unscoped (neither under core instanceDir, nor core dataDir),
// then we must scope it to the core; otherwise, scope to purpose (TLOG_NAME).