This is an automated email from the ASF dual-hosted git repository.
dsmiley pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr.git
The following commit(s) were added to refs/heads/main by this push:
new 51f06f18684 Forbidden-API: Path.startsWith(String) (#3303)
51f06f18684 is described below
commit 51f06f18684a963dc4e9cfadc964200c6a2b024f
Author: David Smiley <[email protected]>
AuthorDate: Wed Apr 2 10:33:12 2025 -0400
Forbidden-API: Path.startsWith(String) (#3303)
Very error-prone; confused with String.startsWith.
---
gradle/validation/forbidden-apis/defaults.all.txt | 3 +++
solr/core/src/java/org/apache/solr/update/UpdateLog.java | 3 ++-
2 files changed, 5 insertions(+), 1 deletion(-)
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).