Apache Solr open-source search software
Add Paths#get to forbidden APIs (#3289)
Andrey Bozhko470ae762b883
diff --git a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/GradlePropertiesGenerator.java b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/GradlePropertiesGenerator.javaindex 5436afe70f8..de99718ba6e 100644--- a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/GradlePropertiesGenerator.java+++ b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/GradlePropertiesGenerator.java@@ -20,7 +20,6 @@ import java.io.IOException;import java.nio.charset.StandardCharsets;import java.nio.file.Files;import java.nio.file.Path;-import java.nio.file.Paths;import java.nio.file.StandardOpenOption;import java.util.Map;@@ -37,7 +36,7 @@ public class GradlePropertiesGenerator {}try {- new GradlePropertiesGenerator().run(Paths.get(args[0]), Paths.get(args[1]));+ new GradlePropertiesGenerator().run(Path.of(args[0]), Path.of(args[1]));} catch (Exception e) {System.err.println("ERROR: " + e.getMessage());System.exit(3);diff --git a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/ProfileResults.java b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/ProfileResults.javaindex 15e0f11c56e..4a93ccbcfd3 100644--- a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/ProfileResults.java+++ b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/ProfileResults.java@@ -18,7 +18,7 @@package org.apache.lucene.gradle;import java.io.IOException;-import java.nio.file.Paths;+import java.nio.file.Path;import java.util.AbstractMap.SimpleEntry;import java.util.ArrayList;import java.util.Arrays;@@ -168,7 +168,7 @@ public class ProfileResults {long sumValues = 0;String framePadding = " ".repeat(COLUMN_SIZE * 2);for (String file : files) {- try (RecordingFile recording = new RecordingFile(Paths.get(file))) {+ try (RecordingFile recording = new RecordingFile(Path.of(file))) {while (recording.hasMoreEvents()) {RecordedEvent event = recording.readEvent();if (!isInteresting(mode, event)) {diff --git a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/WrapperDownloader.java b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/WrapperDownloader.javaindex adb8f3eaf07..4a0f494d38a 100644--- a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/WrapperDownloader.java+++ b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/WrapperDownloader.java@@ -26,7 +26,6 @@ import java.net.URI;import java.nio.charset.StandardCharsets;import java.nio.file.Files;import java.nio.file.Path;-import java.nio.file.Paths;import java.security.MessageDigest;import java.security.NoSuchAlgorithmException;import java.util.Locale;@@ -46,7 +45,7 @@ public class WrapperDownloader {try {checkVersion();- new WrapperDownloader().run(Paths.get(args[0]));+ new WrapperDownloader().run(Path.of(args[0]));} catch (Exception e) {System.err.println("ERROR: " + e.getMessage());System.exit(3);diff --git a/gradle/testing/randomization.gradle b/gradle/testing/randomization.gradleindex 9b7a8defe2c..e8cb4e8b061 100644--- a/gradle/testing/randomization.gradle+++ b/gradle/testing/randomization.gradle@@ -218,8 +218,8 @@ allprojects {systemProperty 'java.security.manager', "default"def gradleUserHome = project.gradle.getGradleUserHomeDir()- systemProperty 'gradle.lib.dir', Paths.get(project.class.location.toURI()).parent.toAbsolutePath().toString().replace('\\', '/')- systemProperty 'gradle.worker.jar', Paths.get("${gradleUserHome}/caches/${gradle.gradleVersion}/workerMain/gradle-worker.jar").toAbsolutePath().toString()+ systemProperty 'gradle.lib.dir', Path.of(project.class.location.toURI()).parent.toAbsolutePath().toString().replace('\\', '/')+ systemProperty 'gradle.worker.jar', Path.of("${gradleUserHome}/caches/${gradle.gradleVersion}/workerMain/gradle-worker.jar").toAbsolutePath().toString()systemProperty 'gradle.user.home', gradleUserHome.toPath().toAbsolutePath().toString()}diff --git a/gradle/validation/forbidden-apis/defaults.all.txt b/gradle/validation/forbidden-apis/defaults.all.txtindex ba0d86c5eec..211968725dd 100644--- a/gradle/validation/forbidden-apis/defaults.all.txt+++ b/gradle/validation/forbidden-apis/defaults.all.txt@@ -93,4 +93,7 @@ java.util.Collections#sort(java.util.List, java.util.Comparator)java.net.URL#<init>(**)@defaultMessage Use Locale.Builder instead.-java.util.Locale#<init>(**)\ No newline at end of file+java.util.Locale#<init>(**)++@defaultMessage Use Path.of(...) methods instead.+java.nio.file.Paths#get(**)diff --git a/solr/benchmark/src/java/org/apache/solr/bench/MiniClusterState.java b/solr/benchmark/src/java/org/apache/solr/bench/MiniClusterState.javaindex 7aee416c948..555463089fd 100755--- a/solr/benchmark/src/java/org/apache/solr/bench/MiniClusterState.java+++ b/solr/benchmark/src/java/org/apache/solr/bench/MiniClusterState.java@@ -29,7 +29,6 @@ import java.nio.charset.StandardCharsets;import java.nio.file.FileSystems;import java.nio.file.Files;import java.nio.file.Path;-import java.nio.file.Paths;import java.util.ArrayList;import java.util.List;import java.util.SplittableRandom;@@ -122,7 +121,7 @@ public class MiniClusterState {// dump Solr metricsPath metricsResults =- Paths.get(+ Path.of(workDir,"metrics-results",benchmarkParams.id(),@@ -203,7 +202,7 @@ public class MiniClusterState {workDir = System.getProperty("workBaseDir", "build/work");- Path currentRelativePath = Paths.get("");+ Path currentRelativePath = Path.of("");String s = currentRelativePath.toAbsolutePath().toString();log("current relative path is: " + s);log("work path is: " + workDir);@@ -226,13 +225,13 @@ public class MiniClusterState {String baseDirSysProp = System.getProperty("miniClusterBaseDir");if (baseDirSysProp != null) {deleteMiniCluster = false;- miniClusterBaseDir = Paths.get(baseDirSysProp);+ miniClusterBaseDir = Path.of(baseDirSysProp);if (Files.exists(miniClusterBaseDir)) {createCollectionAndIndex = false;allowClusterReuse = true;}} else {- miniClusterBaseDir = Paths.get(workDir, "mini-cluster");+ miniClusterBaseDir = Path.of(workDir, "mini-cluster");}System.setProperty("metricsEnabled", String.valueOf(metricsEnabled));@@ -584,6 +583,6 @@ public class MiniClusterState {"Cannot find resource in classpath or in file-system (relative to CWD): "+ name+ " CWD="- + Paths.get("").toAbsolutePath());+ + Path.of("").toAbsolutePath());}}diff --git a/solr/core/src/java/org/apache/solr/cli/AssertTool.java b/solr/core/src/java/org/apache/solr/cli/AssertTool.javaindex f4e92c0c008..74a3176d0ce 100644--- a/solr/core/src/java/org/apache/solr/cli/AssertTool.java+++ b/solr/core/src/java/org/apache/solr/cli/AssertTool.java@@ -20,7 +20,6 @@ import java.io.IOException;import java.lang.invoke.MethodHandles;import java.nio.file.Files;import java.nio.file.Path;-import java.nio.file.Paths;import java.nio.file.attribute.FileOwnerAttributeView;import java.util.concurrent.TimeUnit;import org.apache.commons.cli.CommandLine;@@ -344,8 +343,8 @@ public class AssertTool extends ToolBase {}public static int sameUser(String directory) throws Exception {- if (Files.exists(Paths.get(directory))) {- String userForDir = userForDir(Paths.get(directory));+ if (Files.exists(Path.of(directory))) {+ String userForDir = userForDir(Path.of(directory));if (!currentUser().equals(userForDir)) {return exitOrException("Must run as user " + userForDir + ". We are " + currentUser());}@@ -356,14 +355,14 @@ public class AssertTool extends ToolBase {}public static int assertFileExists(String directory) throws Exception {- if (!Files.exists(Paths.get(directory))) {+ if (!Files.exists(Path.of(directory))) {return exitOrException("Directory " + directory + " does not exist.");}return 0;}public static int assertFileNotExists(String directory) throws Exception {- if (Files.exists(Paths.get(directory))) {+ if (Files.exists(Path.of(directory))) {return exitOrException("Directory " + directory + " should not exist.");}return 0;diff --git a/solr/core/src/java/org/apache/solr/cli/CLIUtils.java b/solr/core/src/java/org/apache/solr/cli/CLIUtils.javaindex 22143e1dbfa..0f9f8641ac5 100644--- a/solr/core/src/java/org/apache/solr/cli/CLIUtils.java+++ b/solr/core/src/java/org/apache/solr/cli/CLIUtils.java@@ -26,7 +26,6 @@ import java.net.SocketException;import java.net.URI;import java.net.URISyntaxException;import java.nio.file.Path;-import java.nio.file.Paths;import java.util.Arrays;import java.util.Collections;import java.util.List;@@ -343,8 +342,7 @@ public final class CLIUtils {}public static Path getConfigSetsDir(Path solrInstallDir) {- Path configSetsPath = Paths.get("server/solr/configsets/");- return solrInstallDir.resolve(configSetsPath);+ return solrInstallDir.resolve("server/solr/configsets");}public static boolean isWindows() {diff --git a/solr/core/src/java/org/apache/solr/cli/ConfigSetDownloadTool.java b/solr/core/src/java/org/apache/solr/cli/ConfigSetDownloadTool.javaindex bc4390c8d01..7810d974586 100644--- a/solr/core/src/java/org/apache/solr/cli/ConfigSetDownloadTool.java+++ b/solr/core/src/java/org/apache/solr/cli/ConfigSetDownloadTool.java@@ -19,7 +19,6 @@ package org.apache.solr.cli;import java.lang.invoke.MethodHandles;import java.nio.file.Files;import java.nio.file.Path;-import java.nio.file.Paths;import org.apache.commons.cli.CommandLine;import org.apache.commons.cli.Option;import org.apache.commons.cli.Options;@@ -81,11 +80,11 @@ public class ConfigSetDownloadTool extends ToolBase {echoIfVerbose("\nConnecting to ZooKeeper at " + zkHost + " ...");try (SolrZkClient zkClient = CLIUtils.getSolrZkClient(cli, zkHost)) {- Path configSetPath = Paths.get(confDir);+ Path configSetPath = Path.of(confDir);// we try to be nice about having the "conf" in the directory, and we create it if it's not// there.if (!configSetPath.endsWith("/conf")) {- configSetPath = Paths.get(configSetPath.toString(), "conf");+ configSetPath = configSetPath.resolve("conf");}Files.createDirectories(configSetPath);echo(diff --git a/solr/core/src/java/org/apache/solr/cli/ConfigSetUploadTool.java b/solr/core/src/java/org/apache/solr/cli/ConfigSetUploadTool.javaindex 8b77fec8135..7088e8919bf 100644--- a/solr/core/src/java/org/apache/solr/cli/ConfigSetUploadTool.java+++ b/solr/core/src/java/org/apache/solr/cli/ConfigSetUploadTool.java@@ -18,7 +18,6 @@ package org.apache.solr.cli;import java.lang.invoke.MethodHandles;import java.nio.file.Path;-import java.nio.file.Paths;import org.apache.commons.cli.CommandLine;import org.apache.commons.cli.Option;import org.apache.commons.cli.Options;@@ -79,7 +78,7 @@ public class ConfigSetUploadTool extends ToolBase {String zkHost = CLIUtils.getZkHost(cli);final String solrInstallDir = System.getProperty("solr.install.dir");- Path solrInstallDirPath = Paths.get(solrInstallDir);+ Path solrInstallDirPath = Path.of(solrInstallDir);String confName = cli.getOptionValue(CONF_NAME_OPTION);String confDir = cli.getOptionValue(CONF_DIR_OPTION);diff --git a/solr/core/src/java/org/apache/solr/cli/CreateTool.java b/solr/core/src/java/org/apache/solr/cli/CreateTool.javaindex e297baa9e80..e9bf1dd4b1a 100644--- a/solr/core/src/java/org/apache/solr/cli/CreateTool.java+++ b/solr/core/src/java/org/apache/solr/cli/CreateTool.java@@ -19,7 +19,6 @@ package org.apache.solr.cli;import java.io.IOException;import java.nio.file.Files;import java.nio.file.Path;-import java.nio.file.Paths;import java.nio.file.StandardCopyOption;import java.util.Locale;import java.util.Set;@@ -151,8 +150,8 @@ public class CreateTool extends ToolBase {cli.getOptionValue(CONF_DIR_OPTION, DefaultValues.DEFAULT_CONFIG_SET);// we allow them to pass a directory instead of a configset name- Path configsetDir = Paths.get(confDirName);- Path solrInstallDirPath = Paths.get(solrInstallDir);+ Path configsetDir = Path.of(confDirName);+ Path solrInstallDirPath = Path.of(solrInstallDir);if (!Files.isDirectory(configsetDir)) {ensureConfDirExists(solrInstallDirPath, configsetDir);@@ -176,7 +175,7 @@ public class CreateTool extends ToolBase {+ "' already exists!\nChecked core existence using Core API command");}- Path coreInstanceDir = Paths.get(coreRootDirectory, coreName);+ Path coreInstanceDir = Path.of(coreRootDirectory, coreName);Path confDir = getFullConfDir(solrInstallDirPath, configsetDir).resolve("conf");if (!Files.isDirectory(coreInstanceDir)) {Files.createDirectories(coreInstanceDir);@@ -232,8 +231,8 @@ public class CreateTool extends ToolBase {final String solrInstallDir = System.getProperty("solr.install.dir");String confName = cli.getOptionValue(CONF_NAME_OPTION);String confDir = cli.getOptionValue(CONF_DIR_OPTION, DefaultValues.DEFAULT_CONFIG_SET);- Path solrInstallDirPath = Paths.get(solrInstallDir);- Path confDirPath = Paths.get(confDir);+ Path solrInstallDirPath = Path.of(solrInstallDir);+ Path confDirPath = Path.of(confDir);ensureConfDirExists(solrInstallDirPath, confDirPath);printDefaultConfigsetWarningIfNecessary(cli);diff --git a/solr/core/src/java/org/apache/solr/cli/SolrProcessManager.java b/solr/core/src/java/org/apache/solr/cli/SolrProcessManager.javaindex 42b38b2e7a8..b36575ae27d 100644--- a/solr/core/src/java/org/apache/solr/cli/SolrProcessManager.java+++ b/solr/core/src/java/org/apache/solr/cli/SolrProcessManager.java@@ -25,7 +25,6 @@ import java.lang.invoke.MethodHandles;import java.nio.charset.StandardCharsets;import java.nio.file.Files;import java.nio.file.Path;-import java.nio.file.Paths;import java.util.ArrayList;import java.util.Arrays;import java.util.Collection;@@ -71,7 +70,7 @@ public class SolrProcessManager {pidProcessMap.values().stream().collect(Collectors.toUnmodifiableMap(p -> p.port, p -> p));String solrInstallDir = EnvUtils.getProperty(SOLR_INSTALL_DIR_ATTRIBUTE);pidDir =- Paths.get(+ Path.of(EnvUtils.getProperty("solr.pid.dir",solrInstallDir != nulldiff --git a/solr/core/src/java/org/apache/solr/cli/StreamTool.java b/solr/core/src/java/org/apache/solr/cli/StreamTool.javaindex 62b80c6a40a..651eee6cc7b 100644--- a/solr/core/src/java/org/apache/solr/cli/StreamTool.java+++ b/solr/core/src/java/org/apache/solr/cli/StreamTool.java@@ -28,7 +28,6 @@ import java.nio.charset.Charset;import java.nio.charset.StandardCharsets;import java.nio.file.Files;import java.nio.file.Path;-import java.nio.file.Paths;import java.util.ArrayList;import java.util.Arrays;import java.util.HashMap;@@ -437,7 +436,7 @@ public class StreamTool extends ToolBase {final List<CrawlFile> crawlSeeds = new ArrayList<>();for (String crawlRootStr : commaDelimitedFilepaths.split(",")) {- Path crawlRootPath = Paths.get(crawlRootStr).normalize();+ Path crawlRootPath = Path.of(crawlRootStr).normalize();if (!Files.exists(crawlRootPath)) {throw new SolrException(diff --git a/solr/core/src/java/org/apache/solr/cli/ZkCpTool.java b/solr/core/src/java/org/apache/solr/cli/ZkCpTool.javaindex 0ae4c9f0055..09ebe88cf94 100644--- a/solr/core/src/java/org/apache/solr/cli/ZkCpTool.java+++ b/solr/core/src/java/org/apache/solr/cli/ZkCpTool.java@@ -21,7 +21,6 @@ import static org.apache.solr.packagemanager.PackageUtils.format;import java.lang.invoke.MethodHandles;import java.lang.reflect.InvocationTargetException;import java.nio.file.Path;-import java.nio.file.Paths;import java.util.Locale;import java.util.Properties;import java.util.concurrent.TimeUnit;@@ -165,7 +164,7 @@ public class ZkCpTool extends ToolBase {// solr start -DminStateByteLenForCompression=0 -c, this logic will not// know about the -DminStateByteLenForCompression and only return the// version set in the solr.xml. So you must edit solr.xml directly.- Path solrHomePath = Paths.get(solrHome);+ Path solrHomePath = Path.of(solrHome);Properties props = new Properties();props.put(SolrXmlConfig.ZK_HOST, zkHost);NodeConfig nodeConfig = NodeConfig.loadNodeConfig(solrHomePath, props);diff --git a/solr/core/src/java/org/apache/solr/core/CachingDirectoryFactory.java b/solr/core/src/java/org/apache/solr/core/CachingDirectoryFactory.javaindex 99047fc6690..dcf084670f6 100644--- a/solr/core/src/java/org/apache/solr/core/CachingDirectoryFactory.java+++ b/solr/core/src/java/org/apache/solr/core/CachingDirectoryFactory.java@@ -21,7 +21,6 @@ import java.lang.invoke.MethodHandles;import java.nio.file.DirectoryStream;import java.nio.file.Files;import java.nio.file.Path;-import java.nio.file.Paths;import java.util.ArrayList;import java.util.Collection;import java.util.HashMap;@@ -480,7 +479,7 @@ public abstract class CachingDirectoryFactory extends DirectoryFactory {// override global configif (args.get(SolrXmlConfig.SOLR_DATA_HOME) != null) {dataHomePath =- Paths.get((String) args.get(SolrXmlConfig.SOLR_DATA_HOME)).toAbsolutePath().normalize();+ Path.of((String) args.get(SolrXmlConfig.SOLR_DATA_HOME)).toAbsolutePath().normalize();}if (dataHomePath != null) {log.info("{} = {}", SolrXmlConfig.SOLR_DATA_HOME, dataHomePath);diff --git a/solr/core/src/java/org/apache/solr/core/CoreContainer.java b/solr/core/src/java/org/apache/solr/core/CoreContainer.javaindex 7462914e5b6..bf0d56495d5 100644--- a/solr/core/src/java/org/apache/solr/core/CoreContainer.java+++ b/solr/core/src/java/org/apache/solr/core/CoreContainer.java@@ -35,7 +35,6 @@ import jakarta.inject.Singleton;import java.io.IOException;import java.lang.invoke.MethodHandles;import java.nio.file.Path;-import java.nio.file.Paths;import java.text.SimpleDateFormat;import java.util.Arrays;import java.util.Collections;@@ -1597,7 +1596,7 @@ public class CoreContainer {// Validate paths are relative to known locations to avoid path traversalassertPathAllowed(cd.getInstanceDir());- assertPathAllowed(Paths.get(cd.getDataDir()));+ assertPathAllowed(Path.of(cd.getDataDir()));boolean preExistingZkEntry = false;try {diff --git a/solr/core/src/java/org/apache/solr/core/NodeConfig.java b/solr/core/src/java/org/apache/solr/core/NodeConfig.javaindex 439a922d1df..1dcdc896d35 100644--- a/solr/core/src/java/org/apache/solr/core/NodeConfig.java+++ b/solr/core/src/java/org/apache/solr/core/NodeConfig.java@@ -21,7 +21,6 @@ import java.lang.invoke.MethodHandles;import java.net.URL;import java.nio.file.Files;import java.nio.file.Path;-import java.nio.file.Paths;import java.util.Arrays;import java.util.Collections;import java.util.LinkedHashSet;@@ -307,7 +306,7 @@ public class NodeConfig {log.debug("solr.install.dir property not initialized.");return null;}- return Paths.get(prop);+ return Path.of(prop);}/**diff --git a/solr/core/src/java/org/apache/solr/core/SolrPaths.java b/solr/core/src/java/org/apache/solr/core/SolrPaths.javaindex 59aa0076437..daf63aeeb70 100644--- a/solr/core/src/java/org/apache/solr/core/SolrPaths.java+++ b/solr/core/src/java/org/apache/solr/core/SolrPaths.java@@ -20,7 +20,6 @@ package org.apache.solr.core;import java.lang.invoke.MethodHandles;import java.nio.file.FileSystems;import java.nio.file.Path;-import java.nio.file.Paths;import java.util.Collections;import java.util.HashSet;import java.util.Set;@@ -34,7 +33,7 @@ public final class SolrPaths {private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());/** Special path which means to accept all paths. */- public static final Path ALL_PATH = Paths.get("_ALL_");+ public static final Path ALL_PATH = Path.of("_ALL_");/** Special singleton path set containing only {@link #ALL_PATH}. */private static final Set<Path> ALL_PATHS = Collections.singleton(ALL_PATH);@@ -116,7 +115,7 @@ public final class SolrPaths {if (path.equals(WILDCARD_PATH)) {paths = ALL_PATHS;} else {- addPath(Paths.get(path));+ addPath(Path.of(path));}return this;}diff --git a/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java b/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.javaindex b8e0e6abc20..bcd08c55ac9 100644--- a/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java+++ b/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java@@ -40,7 +40,6 @@ import java.nio.charset.StandardCharsets;import java.nio.file.Files;import java.nio.file.NoSuchFileException;import java.nio.file.Path;-import java.nio.file.Paths;import java.util.ArrayList;import java.util.Collection;import java.util.Collections;@@ -514,7 +513,7 @@ public class ReplicationHandler extends RequestHandlerBase}}if ("file".equals(repo.createURI("x").getScheme())) {- core.getCoreContainer().assertPathAllowed(Paths.get(location));+ core.getCoreContainer().assertPathAllowed(Path.of(location));}URI locationUri = repo.createDirectoryURI(location);@@ -664,7 +663,7 @@ public class ReplicationHandler extends RequestHandlerBase}}if ("file".equals(repo.createURI("x").getScheme())) {- core.getCoreContainer().assertPathAllowed(Paths.get(location));+ core.getCoreContainer().assertPathAllowed(Path.of(location));}// small race here before the commit point is saveddiff --git a/solr/core/src/java/org/apache/solr/handler/SnapShooter.java b/solr/core/src/java/org/apache/solr/handler/SnapShooter.javaindex 9939f07ddf6..4fe1f0c7427 100644--- a/solr/core/src/java/org/apache/solr/handler/SnapShooter.java+++ b/solr/core/src/java/org/apache/solr/handler/SnapShooter.java@@ -21,7 +21,7 @@ import io.swagger.v3.oas.annotations.media.Schema;import java.io.IOException;import java.lang.invoke.MethodHandles;import java.net.URI;-import java.nio.file.Paths;+import java.nio.file.Path;import java.text.SimpleDateFormat;import java.time.Instant;import java.util.ArrayList;@@ -80,7 +80,7 @@ public class SnapShooter {core.getCoreDescriptor().getInstanceDir().resolve(location).normalize().toString();}initialize(- new LocalFileSystemRepository(), core, Paths.get(snapDirStr).toUri(), snapshotName, null);+ new LocalFileSystemRepository(), core, Path.of(snapDirStr).toUri(), snapshotName, null);}public SnapShooter(@@ -103,7 +103,7 @@ public class SnapShooter {this.baseSnapDirPath = location;this.snapshotName = snapshotName;if ("file".equals(location.getScheme())) {- solrCore.getCoreContainer().assertPathAllowed(Paths.get(location));+ solrCore.getCoreContainer().assertPathAllowed(Path.of(location));}if (snapshotName != null) {directoryName = "snapshot." + snapshotName;diff --git a/solr/core/src/java/org/apache/solr/handler/admin/IndexSizeEstimator.java b/solr/core/src/java/org/apache/solr/handler/admin/IndexSizeEstimator.javaindex f5e6bcf8c24..b88ae352e52 100644--- a/solr/core/src/java/org/apache/solr/handler/admin/IndexSizeEstimator.java+++ b/solr/core/src/java/org/apache/solr/handler/admin/IndexSizeEstimator.java@@ -18,7 +18,7 @@ package org.apache.solr.handler.admin;import java.io.IOException;import java.lang.invoke.MethodHandles;-import java.nio.file.Paths;+import java.nio.file.Path;import java.util.HashMap;import java.util.Iterator;import java.util.LinkedHashMap;@@ -813,7 +813,7 @@ public class IndexSizeEstimator {System.err.println("ERROR: <indexDir> argument is required.");System.exit(-2);}- Directory dir = FSDirectory.open(Paths.get(path));+ Directory dir = FSDirectory.open(Path.of(path));DirectoryReader reader = StandardDirectoryReader.open(dir);IndexSizeEstimator stats = new IndexSizeEstimator(reader, topN, maxLen, summary, details);System.out.println(Utils.toJSONString(stats.estimate()));diff --git a/solr/core/src/java/org/apache/solr/handler/admin/api/CreateCoreBackup.java b/solr/core/src/java/org/apache/solr/handler/admin/api/CreateCoreBackup.javaindex cab08b61e5c..9299657daf8 100644--- a/solr/core/src/java/org/apache/solr/handler/admin/api/CreateCoreBackup.java+++ b/solr/core/src/java/org/apache/solr/handler/admin/api/CreateCoreBackup.java@@ -20,7 +20,7 @@ import static org.apache.solr.security.PermissionNameProvider.Name.COLL_EDIT_PERimport jakarta.inject.Inject;import java.net.URI;-import java.nio.file.Paths;+import java.nio.file.Path;import java.util.Optional;import org.apache.solr.client.api.endpoint.CreateCoreBackupApi;import org.apache.solr.client.api.model.CreateCoreBackupRequestBody;@@ -78,7 +78,7 @@ public class CreateCoreBackup extends CoreAdminAPIBase implements CreateCoreBackif (Boolean.TRUE.equals(backupCoreRequestBody.incremental)) {if ("file".equals(locationUri.getScheme())) {- core.getCoreContainer().assertPathAllowed(Paths.get(locationUri));+ core.getCoreContainer().assertPathAllowed(Path.of(locationUri));}ensureRequiredParameterProvided("shardBackupId", backupCoreRequestBody.shardBackupId);final ShardBackupId shardBackupId =diff --git a/solr/core/src/java/org/apache/solr/handler/admin/api/MergeIndexes.java b/solr/core/src/java/org/apache/solr/handler/admin/api/MergeIndexes.javaindex 66c919f9648..73194ddb9de 100644--- a/solr/core/src/java/org/apache/solr/handler/admin/api/MergeIndexes.java+++ b/solr/core/src/java/org/apache/solr/handler/admin/api/MergeIndexes.java@@ -19,7 +19,7 @@ package org.apache.solr.handler.admin.api;import jakarta.inject.Inject;import java.io.IOException;import java.lang.invoke.MethodHandles;-import java.nio.file.Paths;+import java.nio.file.Path;import java.util.ArrayList;import java.util.HashMap;import java.util.List;@@ -126,7 +126,7 @@ public class MergeIndexes extends CoreAdminAPIBase implements MergeIndexesApi {// Validate each 'indexDir' input as validdirNames.stream().forEach(- indexDir -> core.getCoreContainer().assertPathAllowed(Paths.get(indexDir)));+ indexDir -> core.getCoreContainer().assertPathAllowed(Path.of(indexDir)));DirectoryFactory dirFactory = core.getDirectoryFactory();dirNames.stream().forEach(diff --git a/solr/core/src/java/org/apache/solr/handler/admin/api/ReplicationAPIBase.java b/solr/core/src/java/org/apache/solr/handler/admin/api/ReplicationAPIBase.javaindex 4ef50072bfc..28355f3876f 100644--- a/solr/core/src/java/org/apache/solr/handler/admin/api/ReplicationAPIBase.java+++ b/solr/core/src/java/org/apache/solr/handler/admin/api/ReplicationAPIBase.java@@ -27,7 +27,6 @@ import java.nio.ByteBuffer;import java.nio.channels.SeekableByteChannel;import java.nio.file.Files;import java.nio.file.Path;-import java.nio.file.Paths;import java.util.ArrayList;import java.util.Collections;import java.util.List;@@ -318,7 +317,7 @@ public abstract class ReplicationAPIBase extends JerseyResource {// Throw exception on directory traversal attemptsprotected String validateFilenameOrError(String fileName) {if (fileName != null) {- Path filePath = Paths.get(fileName);+ Path filePath = Path.of(fileName);filePath.forEach(subpath -> {if ("..".equals(subpath.toString())) {diff --git a/solr/core/src/java/org/apache/solr/packagemanager/RepositoryManager.java b/solr/core/src/java/org/apache/solr/packagemanager/RepositoryManager.javaindex 7c5306ceabc..fb8c03c7d0b 100644--- a/solr/core/src/java/org/apache/solr/packagemanager/RepositoryManager.java+++ b/solr/core/src/java/org/apache/solr/packagemanager/RepositoryManager.java@@ -30,7 +30,6 @@ import java.nio.ByteBuffer;import java.nio.charset.StandardCharsets;import java.nio.file.Files;import java.nio.file.Path;-import java.nio.file.Paths;import java.util.ArrayList;import java.util.Arrays;import java.util.Collections;@@ -150,7 +149,7 @@ public class RepositoryManager {// put the public key into package store's trusted key store and request a sync.String path = ClusterFileStore.KEYS_DIR + "/" + destinationKeyFilename;- PackageUtils.uploadKey(key, path, Paths.get(solrHome));+ PackageUtils.uploadKey(key, path, Path.of(solrHome));final var syncRequest = new FileStoreApi.SyncFile(path);final var syncResponse = syncRequest.process(solrClient).getParsed();final var status = syncResponse.responseHeader.status;diff --git a/solr/core/src/java/org/apache/solr/schema/ManagedIndexSchemaFactory.java b/solr/core/src/java/org/apache/solr/schema/ManagedIndexSchemaFactory.javaindex dce62c012e5..a67c11f6654 100644--- a/solr/core/src/java/org/apache/solr/schema/ManagedIndexSchemaFactory.java+++ b/solr/core/src/java/org/apache/solr/schema/ManagedIndexSchemaFactory.java@@ -22,7 +22,6 @@ import java.io.InputStream;import java.lang.invoke.MethodHandles;import java.nio.file.Files;import java.nio.file.Path;-import java.nio.file.Paths;import java.util.AbstractMap.SimpleImmutableEntry;import java.util.Map.Entry;import net.jcip.annotations.NotThreadSafe;@@ -147,12 +146,11 @@ public class ManagedIndexSchemaFactory extends IndexSchemaFactory implements Sol*/public Path lookupLocalManagedSchemaPath() {final Path legacyManagedSchemaPath =- Paths.get(- loader.getConfigPath().toString(),- ManagedIndexSchemaFactory.LEGACY_MANAGED_SCHEMA_RESOURCE_NAME);+ loader+ .getConfigPath()+ .resolve(ManagedIndexSchemaFactory.LEGACY_MANAGED_SCHEMA_RESOURCE_NAME);- Path managedSchemaPath =- Paths.get(loader.getConfigPath().toString(), managedSchemaResourceName);+ Path managedSchemaPath = loader.getConfigPath().resolve(managedSchemaResourceName);// check if we are using the legacy managed-schema file name.if (Files.exists(legacyManagedSchemaPath)) {diff --git a/solr/core/src/java/org/apache/solr/servlet/CoreContainerProvider.java b/solr/core/src/java/org/apache/solr/servlet/CoreContainerProvider.javaindex 5a2a053c090..a35dfc4d73f 100644--- a/solr/core/src/java/org/apache/solr/servlet/CoreContainerProvider.java+++ b/solr/core/src/java/org/apache/solr/servlet/CoreContainerProvider.java@@ -33,7 +33,6 @@ import java.lang.invoke.MethodHandles;import java.lang.management.ManagementFactory;import java.lang.management.RuntimeMXBean;import java.nio.file.Path;-import java.nio.file.Paths;import java.time.Instant;import java.util.Arrays;import java.util.Locale;@@ -390,7 +389,7 @@ public class CoreContainerProvider implements ServletContextListener {home = "solr/";source = "defaulted to '" + home + "' ... could not find system property or JNDI";}- final Path solrHome = Paths.get(home).toAbsolutePath().normalize();+ final Path solrHome = Path.of(home).toAbsolutePath().normalize();log.info("Solr Home: {} (source: {})", solrHome, source);return solrHome;diff --git a/solr/core/src/java/org/apache/solr/spelling/suggest/LookupFactory.java b/solr/core/src/java/org/apache/solr/spelling/suggest/LookupFactory.javaindex 39ebccb50c1..0a30a99afed 100644--- a/solr/core/src/java/org/apache/solr/spelling/suggest/LookupFactory.java+++ b/solr/core/src/java/org/apache/solr/spelling/suggest/LookupFactory.java@@ -17,7 +17,7 @@package org.apache.solr.spelling.suggest;import java.io.IOException;-import java.nio.file.Paths;+import java.nio.file.Path;import org.apache.lucene.search.suggest.Lookup;import org.apache.lucene.store.FSDirectory;import org.apache.solr.common.util.NamedList;@@ -50,7 +50,7 @@ public abstract class LookupFactory {throw new RuntimeException("Java has no temporary folder property (java.io.tmpdir)?");}try {- tmpBuildDir = FSDirectory.open(Paths.get(tempDirPath));+ tmpBuildDir = FSDirectory.open(Path.of(tempDirPath));} catch (IOException ioe) {throw new RuntimeException(ioe);}diff --git a/solr/core/src/test/org/apache/solr/cli/SolrCLIZkToolsTest.java b/solr/core/src/test/org/apache/solr/cli/SolrCLIZkToolsTest.javaindex 696d65329c9..35e2e019dbc 100644--- a/solr/core/src/test/org/apache/solr/cli/SolrCLIZkToolsTest.java+++ b/solr/core/src/test/org/apache/solr/cli/SolrCLIZkToolsTest.java@@ -475,7 +475,7 @@ public class SolrCLIZkToolsTest extends SolrCloudTestCase {int res = CLITestHelper.runTool(args, runtime, ZkLsTool.class);String content = runtime.getOutput();- assertEquals("List should have succeeded", res, 0);+ assertEquals("List should have succeeded", 0, res);assertTrue("Return should contain the conf directory", content.contains("lister"));assertFalse("Return should NOT contain a child node", content.contains("solrconfig.xml"));@@ -486,7 +486,7 @@ public class SolrCLIZkToolsTest extends SolrCloudTestCase {res = CLITestHelper.runTool(args, runtime, ZkLsTool.class);content = runtime.getOutput();- assertEquals("List should have succeeded", res, 0);+ assertEquals("List should have succeeded", 0, res);assertTrue("Return should contain the conf directory", content.contains("lister"));assertFalse("Return should NOT contain a child node", content.contains("solrconfig.xml"));@@ -497,7 +497,7 @@ public class SolrCLIZkToolsTest extends SolrCloudTestCase {res = CLITestHelper.runTool(args, runtime, ZkLsTool.class);content = runtime.getOutput();- assertEquals("List should have succeeded", res, 0);+ assertEquals("List should have succeeded", 0, res);assertTrue("Return should contain the conf directory", content.contains("lister"));assertTrue("Return should contain a child node", content.contains("solrconfig.xml"));@@ -508,7 +508,7 @@ public class SolrCLIZkToolsTest extends SolrCloudTestCase {res = CLITestHelper.runTool(args, runtime, ZkLsTool.class);content = runtime.getOutput();- assertEquals("List should have succeeded", res, 0);+ assertEquals("List should have succeeded", 0, res);assertTrue("Return should contain the conf directory", content.contains("lister"));assertTrue("Return should contain a child node", content.contains("solrconfig.xml"));@@ -517,7 +517,7 @@ public class SolrCLIZkToolsTest extends SolrCloudTestCase {runtime.clearOutput();res = CLITestHelper.runTool(args, runtime, ZkLsTool.class);content = runtime.getOutput();- assertEquals("List should have succeeded", res, 0);+ assertEquals("List should have succeeded", 0, res);assertFalse("Return should not contain /zookeeper", content.contains("/zookeeper"));// Saw a case where ending in slash didn't work, so test it.@@ -527,7 +527,7 @@ public class SolrCLIZkToolsTest extends SolrCloudTestCase {res = CLITestHelper.runTool(args, runtime, ZkLsTool.class);content = runtime.getOutput();- assertEquals("List should have succeeded", res, 0);+ assertEquals("List should have succeeded", 0, res);assertTrue("Return should contain the conf directory", content.contains("lister"));assertTrue("Return should contain a child node", content.contains("solrconfig.xml"));}@@ -563,7 +563,7 @@ public class SolrCLIZkToolsTest extends SolrCloudTestCase {args = new String[] {"rm", "--recursive", "--zk-host", zkAddr, "/configs/rm1"};res = CLITestHelper.runTool(args, ZkRmTool.class);- assertEquals("Should have removed node /configs/rm1", res, 0);+ assertEquals("Should have removed node /configs/rm1", 0, res);assertFalse("Znode /configs/toremove really should be gone", zkClient.exists("/configs/rm1", true));@@ -571,7 +571,7 @@ public class SolrCLIZkToolsTest extends SolrCloudTestCase {args = new String[] {"rm", "--recursive", "--zk-host", zkAddr, "zk:/configs/rm2"};res = CLITestHelper.runTool(args, ZkRmTool.class);- assertEquals("Should have removed node /configs/rm2", res, 0);+ assertEquals("Should have removed node /configs/rm2", 0, res);assertFalse("Znode /configs/toremove2 really should be gone", zkClient.exists("/configs/rm2", true));diff --git a/solr/core/src/test/org/apache/solr/cli/TestSolrCLIRunExample.java b/solr/core/src/test/org/apache/solr/cli/TestSolrCLIRunExample.javaindex a6b471df11d..90219220371 100644--- a/solr/core/src/test/org/apache/solr/cli/TestSolrCLIRunExample.java+++ b/solr/core/src/test/org/apache/solr/cli/TestSolrCLIRunExample.java@@ -26,7 +26,6 @@ import java.nio.charset.Charset;import java.nio.charset.StandardCharsets;import java.nio.file.Files;import java.nio.file.Path;-import java.nio.file.Paths;import java.util.ArrayList;import java.util.Arrays;import java.util.Collections;@@ -64,7 +63,7 @@ public class TestSolrCLIRunExample extends SolrTestCaseJ4 {public static void beforeClass() {assumeFalse("FIXME: This test does not work with whitespace in CWD (https://issues.apache.org/jira/browse/SOLR-8877)",- Paths.get(".").toAbsolutePath().toString().contains(" "));+ Path.of(".").toAbsolutePath().toString().contains(" "));// to be trueSystem.setProperty("solr.directoryFactory", "solr.NRTCachingDirectoryFactory");}@@ -112,10 +111,10 @@ public class TestSolrCLIRunExample extends SolrTestCaseJ4 {String solrHomeDir = getArg("--solr-home", args);int port = Integer.parseInt(getArg("-p", args));- Path solrXmlPath = Paths.get(solrHomeDir).resolve("solr.xml");+ Path solrXmlPath = Path.of(solrHomeDir).resolve("solr.xml");if (!Files.exists(solrXmlPath)) {String solrServerDir = getArg("--server-dir", args);- solrXmlPath = Paths.get(solrServerDir).resolve("solr").resolve("solr.xml");+ solrXmlPath = Path.of(solrServerDir).resolve("solr").resolve("solr.xml");}String solrxml = Files.readString(solrXmlPath, Charset.defaultCharset());diff --git a/solr/core/src/test/org/apache/solr/cloud/CollectionsAPISolrJTest.java b/solr/core/src/test/org/apache/solr/cloud/CollectionsAPISolrJTest.javaindex 591a25b5267..0742bf85115 100644--- a/solr/core/src/test/org/apache/solr/cloud/CollectionsAPISolrJTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/CollectionsAPISolrJTest.java@@ -29,7 +29,6 @@ import java.io.IOException;import java.lang.invoke.MethodHandles;import java.nio.charset.StandardCharsets;import java.nio.file.Path;-import java.nio.file.Paths;import java.time.Instant;import java.util.ArrayList;import java.util.Arrays;@@ -450,7 +449,7 @@ public class CollectionsAPISolrJTest extends SolrCloudTestCase {Replica replica1 = testCollection.getReplicas().iterator().next();final var coreStatus = getCoreStatus(replica1);- assertEquals(Paths.get(coreStatus.dataDir).toString(), dataDir.toString());+ assertEquals(Path.of(coreStatus.dataDir).toString(), dataDir.toString());}@Testdiff --git a/solr/core/src/test/org/apache/solr/cloud/DeleteReplicaTest.java b/solr/core/src/test/org/apache/solr/cloud/DeleteReplicaTest.javaindex b92b8006b76..bfa9a05c10c 100644--- a/solr/core/src/test/org/apache/solr/cloud/DeleteReplicaTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/DeleteReplicaTest.java@@ -21,7 +21,6 @@ import static org.apache.solr.common.cloud.Replica.State.DOWN;import java.lang.invoke.MethodHandles;import java.nio.file.Files;import java.nio.file.Path;-import java.nio.file.Paths;import java.util.EnumSet;import java.util.Set;import java.util.concurrent.Semaphore;@@ -97,7 +96,7 @@ public class DeleteReplicaTest extends SolrCloudTestCase {shard, (r) -> (r.getState() == Replica.State.ACTIVE && !r.equals(shard.getLeader())));final var coreStatus = getCoreStatus(replica);- Path dataDir = Paths.get(coreStatus.dataDir);+ Path dataDir = Path.of(coreStatus.dataDir);Exception e =expectThrows(@@ -164,8 +163,8 @@ public class DeleteReplicaTest extends SolrCloudTestCase {// Confirm that the instance and data directory existfinal var coreStatus = getCoreStatus(leader);- assertTrue("Instance directory doesn't exist", Files.exists(Paths.get(coreStatus.instanceDir)));- assertTrue("DataDirectory doesn't exist", Files.exists(Paths.get(coreStatus.dataDir)));+ assertTrue("Instance directory doesn't exist", Files.exists(Path.of(coreStatus.instanceDir)));+ assertTrue("DataDirectory doesn't exist", Files.exists(Path.of(coreStatus.dataDir)));CollectionAdminRequest.deleteReplica(collectionName, "shard1", leader.getName()).process(cluster.getSolrClient());@@ -175,8 +174,8 @@ public class DeleteReplicaTest extends SolrCloudTestCase {assertNotEquals(leader, newLeader);// Confirm that the instance and data directory were deleted by default- assertFalse("Instance directory still exists", Files.exists(Paths.get(coreStatus.instanceDir)));- assertFalse("DataDirectory still exists", Files.exists(Paths.get(coreStatus.dataDir)));+ assertFalse("Instance directory still exists", Files.exists(Path.of(coreStatus.instanceDir)));+ assertFalse("DataDirectory still exists", Files.exists(Path.of(coreStatus.dataDir)));}@Testdiff --git a/solr/core/src/test/org/apache/solr/cloud/LeaderFailureAfterFreshStartTest.java b/solr/core/src/test/org/apache/solr/cloud/LeaderFailureAfterFreshStartTest.javaindex 180f687abb3..5710f1a6624 100644--- a/solr/core/src/test/org/apache/solr/cloud/LeaderFailureAfterFreshStartTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/LeaderFailureAfterFreshStartTest.java@@ -23,7 +23,7 @@ import com.carrotsearch.randomizedtesting.generators.RandomStrings;import java.io.IOException;import java.lang.invoke.MethodHandles;import java.nio.file.Files;-import java.nio.file.Paths;+import java.nio.file.Path;import java.util.ArrayList;import java.util.Collection;import java.util.HashSet;@@ -144,9 +144,10 @@ public class LeaderFailureAfterFreshStartTest extends AbstractFullDistribZkTestB// start the freshNoderestartNodes(singletonList(freshNode));String coreName = freshNode.jetty.getCoreContainer().getCores().iterator().next().getName();- String replicationProperties =- freshNode.jetty.getSolrHome() + "/cores/" + coreName + "/data/replication.properties";- String md5 = DigestUtils.md5Hex(Files.readAllBytes(Paths.get(replicationProperties)));+ Path replicationProperties =+ Path.of(+ freshNode.jetty.getSolrHome(), "cores", coreName, "data", "replication.properties");+ String md5 = DigestUtils.md5Hex(Files.readAllBytes(replicationProperties));// shutdown the original leaderlog.info("Now shutting down initial leader");@@ -158,7 +159,7 @@ public class LeaderFailureAfterFreshStartTest extends AbstractFullDistribZkTestBassertEquals("Node went into replication",md5,- DigestUtils.md5Hex(Files.readAllBytes(Paths.get(replicationProperties))));+ DigestUtils.md5Hex(Files.readAllBytes(replicationProperties)));success = true;} finally {diff --git a/solr/core/src/test/org/apache/solr/cloud/PeerSyncReplicationTest.java b/solr/core/src/test/org/apache/solr/cloud/PeerSyncReplicationTest.javaindex b88dca262f9..5c29bc834fb 100644--- a/solr/core/src/test/org/apache/solr/cloud/PeerSyncReplicationTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/PeerSyncReplicationTest.java@@ -26,7 +26,7 @@ import com.codahale.metrics.MetricRegistry;import java.io.IOException;import java.lang.invoke.MethodHandles;import java.nio.file.Files;-import java.nio.file.Paths;+import java.nio.file.Path;import java.util.ArrayList;import java.util.Arrays;import java.util.Collection;@@ -325,7 +325,7 @@ public class PeerSyncReplicationTest extends AbstractFullDistribZkTestBase {+ "/data/replication.properties";assertTrue("PeerSync failed. Had to fail back to replication",- Files.notExists(Paths.get(replicationProperties)));+ Files.notExists(Path.of(replicationProperties)));}private void waitTillNodesActive() throws Exception {diff --git a/solr/core/src/test/org/apache/solr/core/CachingDirectoryFactoryTest.java b/solr/core/src/test/org/apache/solr/core/CachingDirectoryFactoryTest.javaindex e6dd56470be..c7ba1e9f299 100644--- a/solr/core/src/test/org/apache/solr/core/CachingDirectoryFactoryTest.java+++ b/solr/core/src/test/org/apache/solr/core/CachingDirectoryFactoryTest.java@@ -105,7 +105,7 @@ public class CachingDirectoryFactoryTest extends SolrTestCaseJ4 {df.remove(pathString, addIfTrue(deleteAfter, pathString, after));df.doneWithDirectory(d);df.release(d);- boolean exists = Path.of(pathString).toFile().exists();+ boolean exists = Files.exists(Path.of(pathString));if (after) {assertTrue("Path " + pathString + " should be removed after, but it no longer exists", exists);diff --git a/solr/core/src/test/org/apache/solr/core/DirectoryFactoryTest.java b/solr/core/src/test/org/apache/solr/core/DirectoryFactoryTest.javaindex d5431868d42..25112a16bea 100755--- a/solr/core/src/test/org/apache/solr/core/DirectoryFactoryTest.java+++ b/solr/core/src/test/org/apache/solr/core/DirectoryFactoryTest.java@@ -19,7 +19,6 @@ package org.apache.solr.core;import java.io.IOException;import java.io.InputStream;import java.nio.file.Path;-import java.nio.file.Paths;import java.util.Properties;import org.apache.lucene.tests.mockfile.FilterPath;import org.apache.solr.SolrTestCase;@@ -128,9 +127,8 @@ public class DirectoryFactoryTest extends SolrTestCase {throws IOException {String dataHome =df.getDataHome(- new CoreDescriptor(- "core_name", Paths.get(instanceDir).toAbsolutePath(), cc, properties));- assertEquals(Paths.get(expected).toAbsolutePath(), Paths.get(dataHome).toAbsolutePath());+ new CoreDescriptor("core_name", Path.of(instanceDir).toAbsolutePath(), cc, properties));+ assertEquals(Path.of(expected).toAbsolutePath(), Path.of(dataHome).toAbsolutePath());}private NodeConfig loadNodeConfig(String config) {diff --git a/solr/core/src/test/org/apache/solr/core/ResourceLoaderTest.java b/solr/core/src/test/org/apache/solr/core/ResourceLoaderTest.javaindex 39a992eb3ea..78d1f28a029 100644--- a/solr/core/src/test/org/apache/solr/core/ResourceLoaderTest.java+++ b/solr/core/src/test/org/apache/solr/core/ResourceLoaderTest.java@@ -26,7 +26,6 @@ import java.io.InputStream;import java.nio.charset.CharacterCodingException;import java.nio.file.Files;import java.nio.file.Path;-import java.nio.file.Paths;import java.util.Collections;import java.util.HashMap;import java.util.List;@@ -256,7 +255,7 @@ public class ResourceLoaderTest extends SolrTestCaseJ4 {@SuppressWarnings("deprecation")public void testLoadDeprecatedFactory() throws Exception {SolrResourceLoader loader =- new SolrResourceLoader(Paths.get("solr/collection1").toAbsolutePath());+ new SolrResourceLoader(Path.of("solr/collection1").toAbsolutePath());// ensure we get our exceptionloader.newInstance(DeprecatedTokenFilterFactory.class.getName(),diff --git a/solr/core/src/test/org/apache/solr/core/TestConfigSets.java b/solr/core/src/test/org/apache/solr/core/TestConfigSets.javaindex 34dc343fa2b..011102daa29 100644--- a/solr/core/src/test/org/apache/solr/core/TestConfigSets.java+++ b/solr/core/src/test/org/apache/solr/core/TestConfigSets.java@@ -25,7 +25,6 @@ import com.carrotsearch.randomizedtesting.rules.SystemPropertiesRestoreRule;import java.io.IOException;import java.nio.file.Files;import java.nio.file.Path;-import java.nio.file.Paths;import java.nio.file.StandardCopyOption;import java.util.Map;import org.apache.commons.io.file.PathUtils;@@ -55,21 +54,21 @@ public class TestConfigSets extends SolrTestCaseJ4 {@Testpublic void testDefaultConfigSetBasePathResolution() {- Path solrHome = Paths.get("/path/to/solr/home");+ Path solrHome = Path.of("/path/to/solr/home");NodeConfig config =SolrXmlConfig.fromString(solrHome, "<solr><str name=\"configSetBaseDir\">configsets</str></solr>");assertThat(config.getConfigSetBaseDirectory().toAbsolutePath(),- is(Paths.get("/path/to/solr/home/configsets").toAbsolutePath()));+ is(Path.of("/path/to/solr/home/configsets").toAbsolutePath()));NodeConfig absConfig =SolrXmlConfig.fromString(solrHome, "<solr><str name=\"configSetBaseDir\">/path/to/configsets</str></solr>");assertThat(absConfig.getConfigSetBaseDirectory().toAbsolutePath(),- is(Paths.get("/path/to/configsets").toAbsolutePath()));+ is(Path.of("/path/to/configsets").toAbsolutePath()));}@Test@@ -82,7 +81,7 @@ public class TestConfigSets extends SolrTestCaseJ4 {SolrCore core1 = container.create("core1", Map.of("configSet", "configset-2"));assertThat(core1.getCoreDescriptor().getName(), is("core1"));assertThat(- Paths.get(core1.getDataDir()).toString(),+ Path.of(core1.getDataDir()).toString(),is(solrHome.resolve("core1").resolve("data").toString()));} finally {if (container != null) container.shutdown();diff --git a/solr/core/src/test/org/apache/solr/core/TestCoreContainer.java b/solr/core/src/test/org/apache/solr/core/TestCoreContainer.javaindex d4fa3e6baab..471c024118d 100644--- a/solr/core/src/test/org/apache/solr/core/TestCoreContainer.java+++ b/solr/core/src/test/org/apache/solr/core/TestCoreContainer.java@@ -27,7 +27,6 @@ import java.io.FileOutputStream;import java.nio.charset.StandardCharsets;import java.nio.file.Files;import java.nio.file.Path;-import java.nio.file.Paths;import java.nio.file.StandardCopyOption;import java.util.ArrayList;import java.util.Collection;@@ -633,9 +632,9 @@ public class TestCoreContainer extends SolrTestCaseJ4 {Assume.assumeFalse(OS.isFamilyWindows());System.setProperty("solr.allowPaths", "/var/solr");CoreContainer cc = init(ALLOW_PATHS_SOLR_XML);- cc.assertPathAllowed(Paths.get("/var/solr/foo"));+ cc.assertPathAllowed(Path.of("/var/solr/foo"));try {- cc.assertPathAllowed(Paths.get("/tmp"));+ cc.assertPathAllowed(Path.of("/tmp"));fail("Path /tmp should not be allowed");} catch (SolrException e) {/* Ignore */@@ -650,9 +649,9 @@ public class TestCoreContainer extends SolrTestCaseJ4 {Assume.assumeTrue(OS.isFamilyWindows());System.setProperty("solr.allowPaths", "C:\\solr");CoreContainer cc = init(ALLOW_PATHS_SOLR_XML);- cc.assertPathAllowed(Paths.get("C:\\solr\\foo"));+ cc.assertPathAllowed(Path.of("C:\\solr\\foo"));try {- cc.assertPathAllowed(Paths.get("C:\\tmp"));+ cc.assertPathAllowed(Path.of("C:\\tmp"));fail("Path C:\\tmp should not be allowed");} catch (SolrException e) {/* Ignore */@@ -694,12 +693,12 @@ public class TestCoreContainer extends SolrTestCaseJ4 {Assume.assumeFalse(OS.isFamilyWindows());System.setProperty("solr.allowPaths", "/var/solr/../solr");CoreContainer cc = init(ALLOW_PATHS_SOLR_XML);- cc.assertPathAllowed(Paths.get("/var/solr/foo"));+ cc.assertPathAllowed(Path.of("/var/solr/foo"));assertThrows("Path /tmp should not be allowed",SolrException.class,() -> {- cc.assertPathAllowed(Paths.get("/tmp"));+ cc.assertPathAllowed(Path.of("/tmp"));});cc.shutdown();System.clearProperty("solr.allowPaths");@@ -710,12 +709,12 @@ public class TestCoreContainer extends SolrTestCaseJ4 {Assume.assumeTrue(OS.isFamilyWindows());System.setProperty("solr.allowPaths", "C:\\solr\\..\\solr");CoreContainer cc = init(ALLOW_PATHS_SOLR_XML);- cc.assertPathAllowed(Paths.get("C:\\solr\\foo"));+ cc.assertPathAllowed(Path.of("C:\\solr\\foo"));assertThrows("Path C:\\tmp should not be allowed",SolrException.class,() -> {- cc.assertPathAllowed(Paths.get("C:\\tmp"));+ cc.assertPathAllowed(Path.of("C:\\tmp"));});cc.shutdown();System.clearProperty("solr.allowPaths");diff --git a/solr/core/src/test/org/apache/solr/core/TestCoreDiscovery.java b/solr/core/src/test/org/apache/solr/core/TestCoreDiscovery.javaindex 600c4fd7e9a..09639b28839 100644--- a/solr/core/src/test/org/apache/solr/core/TestCoreDiscovery.java+++ b/solr/core/src/test/org/apache/solr/core/TestCoreDiscovery.java@@ -30,7 +30,6 @@ import java.nio.charset.StandardCharsets;import java.nio.file.FileSystems;import java.nio.file.Files;import java.nio.file.Path;-import java.nio.file.Paths;import java.nio.file.attribute.PosixFilePermission;import java.util.List;import java.util.Map;@@ -240,7 +239,7 @@ public class TestCoreDiscovery extends SolrTestCaseJ4 {// Sanity check that a core did get loadedaddCoreWithProps("corep2", makeCoreProperties("corep2", false, true));- Path coreP1PropFile = Paths.get(solrHomeDirectory.toString(), "corep1", "core.properties");+ Path coreP1PropFile = solrHomeDirectory.resolve("corep1").resolve("core.properties");assertTrue("Core.properties file should exist for before core load failure core corep1",Files.exists(coreP1PropFile));@@ -257,13 +256,13 @@ public class TestCoreDiscovery extends SolrTestCaseJ4 {"Core.properties file should still exist for core corep1", Files.exists(coreP1PropFile));// Creating a core successfully should create a core.properties file- Path corePropFile = Paths.get(solrHomeDirectory.toString(), "corep3", "core.properties");+ Path corePropFile = solrHomeDirectory.resolve("corep3").resolve("core.properties");assertFalse("Should not be a properties file yet", Files.exists(corePropFile));cc.create("corep3", Map.of("configSet", "minimal"));assertTrue("Should be a properties file for newly created core", Files.exists(corePropFile));// Failing to create a core should _not_ leave a core.properties file hanging around.- corePropFile = Paths.get(solrHomeDirectory.toString(), "corep4", "core.properties");+ corePropFile = solrHomeDirectory.resolve("corep4").resolve("core.properties");assertFalse("Should not be a properties file yet for corep4", Files.exists(corePropFile));thrown =@@ -286,7 +285,7 @@ public class TestCoreDiscovery extends SolrTestCaseJ4 {// Finally, let's determine that this create path operation also leaves a prop file.- corePropFile = Paths.get(solrHomeDirectory.toString(), "corep5", "core.properties");+ corePropFile = solrHomeDirectory.resolve("corep5").resolve("core.properties");assertFalse("Should not be a properties file yet for corep5", Files.exists(corePropFile));cc.create("corep5", Map.of("configSet", "minimal"));diff --git a/solr/core/src/test/org/apache/solr/core/snapshots/TestSolrCoreSnapshots.java b/solr/core/src/test/org/apache/solr/core/snapshots/TestSolrCoreSnapshots.javaindex 468919ac846..935f1d0bda0 100644--- a/solr/core/src/test/org/apache/solr/core/snapshots/TestSolrCoreSnapshots.java+++ b/solr/core/src/test/org/apache/solr/core/snapshots/TestSolrCoreSnapshots.java@@ -16,7 +16,7 @@*/package org.apache.solr.core.snapshots;-import java.nio.file.Paths;+import java.nio.file.Path;import java.util.ArrayList;import java.util.Collection;import java.util.Collections;@@ -338,7 +338,7 @@ public class TestSolrCoreSnapshots extends SolrCloudTestCase {}private List<IndexCommit> listCommits(String directory) throws Exception {- Directory dir = new NIOFSDirectory(Paths.get(directory));+ Directory dir = new NIOFSDirectory(Path.of(directory));try {return DirectoryReader.listCommits(dir);} catch (IndexNotFoundException ex) {diff --git a/solr/core/src/test/org/apache/solr/handler/TestIncrementalCoreBackup.java b/solr/core/src/test/org/apache/solr/handler/TestIncrementalCoreBackup.javaindex 1c303a1f6c5..4efc80ab3df 100644--- a/solr/core/src/test/org/apache/solr/handler/TestIncrementalCoreBackup.java+++ b/solr/core/src/test/org/apache/solr/handler/TestIncrementalCoreBackup.java@@ -19,7 +19,6 @@ package org.apache.solr.handler;import java.io.IOException;import java.net.URI;import java.nio.file.Path;-import java.nio.file.Paths;import java.util.Arrays;import org.apache.lucene.index.IndexCommit;import org.apache.lucene.tests.util.LuceneTestCase;@@ -70,7 +69,7 @@ public class TestIncrementalCoreBackup extends SolrTestCaseJ4 {final ShardBackupId shardBackupId = new ShardBackupId("shard1", BackupId.zero());final CoreContainer cores = h.getCoreContainer();- cores.getAllowPaths().add(Paths.get(locationUri));+ cores.getAllowPaths().add(Path.of(locationUri));try (final CoreAdminHandler admin = new CoreAdminHandler(cores)) {SolrQueryResponse resp = new SolrQueryResponse();admin.handleRequestBody(diff --git a/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java b/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.javaindex cb81b084cc0..29abe10f3e7 100644--- a/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java+++ b/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java@@ -30,7 +30,6 @@ import java.net.URI;import java.net.URL;import java.nio.file.Files;import java.nio.file.Path;-import java.nio.file.Paths;import java.util.Arrays;import java.util.Collection;import java.util.Date;@@ -1411,7 +1410,7 @@ public class TestReplicationHandler extends SolrTestCaseJ4 {leaderClient.close();leaderJetty.stop();- Directory dir = FSDirectory.open(Paths.get(dataDir).resolve("index"));+ Directory dir = FSDirectory.open(Path.of(dataDir).resolve("index"));String[] files = dir.listAll();long totalBytes = 0;for (String file : files) {@@ -1463,7 +1462,7 @@ public class TestReplicationHandler extends SolrTestCaseJ4 {public void doTestIllegalFilePaths() {// Loop through the file=, cf=, tlogFile= params and prove that it throws exception for path// traversal attempts- String absFile = Paths.get("foo").toAbsolutePath().toString();+ String absFile = Path.of("foo").toAbsolutePath().toString();List<String> illegalFilenames =Arrays.asList(absFile, "../dir/traversal", "illegal\rfile\nname\t");List<String> params =diff --git a/solr/core/src/test/org/apache/solr/handler/TestReplicationHandlerBackup.java b/solr/core/src/test/org/apache/solr/handler/TestReplicationHandlerBackup.javaindex b46627825ee..edf3ab19143 100644--- a/solr/core/src/test/org/apache/solr/handler/TestReplicationHandlerBackup.java+++ b/solr/core/src/test/org/apache/solr/handler/TestReplicationHandlerBackup.java@@ -24,7 +24,6 @@ import java.net.URL;import java.nio.file.DirectoryStream;import java.nio.file.Files;import java.nio.file.Path;-import java.nio.file.Paths;import java.util.ArrayList;import java.util.Iterator;import java.util.List;@@ -136,7 +135,7 @@ public class TestReplicationHandlerBackup extends SolrJettyTestBase {final String newBackupDir = backupStatus.waitForDifferentBackupDir(lastBackupDir, 30);// Validate- verify(Paths.get(leader.getDataDir(), newBackupDir), nDocs);+ verify(Path.of(leader.getDataDir(), newBackupDir), nDocs);}private void verify(Path backup, int nDocs) throws IOException {@@ -163,7 +162,7 @@ public class TestReplicationHandlerBackup extends SolrJettyTestBase {int nDocs = BackupRestoreUtils.indexDocs(leaderClient, DEFAULT_TEST_COLLECTION_NAME, docsSeed);lastBackupDir = backupStatus.waitForDifferentBackupDir(lastBackupDir, 30);- snapDir[0] = Paths.get(leader.getDataDir(), lastBackupDir);+ snapDir[0] = Path.of(leader.getDataDir(), lastBackupDir);final boolean namedBackup = random().nextBoolean();@@ -186,7 +185,7 @@ public class TestReplicationHandlerBackup extends SolrJettyTestBase {lastBackupDir = backupStatus.waitForBackupSuccess(backupName, 30);backupNames[i] = backupName;}- snapDir[i + 1] = Paths.get(leader.getDataDir(), lastBackupDir);+ snapDir[i + 1] = Path.of(leader.getDataDir(), lastBackupDir);verify(snapDir[i + 1], nDocs);}@@ -199,7 +198,7 @@ public class TestReplicationHandlerBackup extends SolrJettyTestBase {final List<String> remainingBackups = new ArrayList<>();try (DirectoryStream<Path> stream =- Files.newDirectoryStream(Paths.get(leader.getDataDir()), "snapshot*")) {+ Files.newDirectoryStream(Path.of(leader.getDataDir()), "snapshot*")) {Iterator<Path> iter = stream.iterator();while (iter.hasNext()) {remainingBackups.add(iter.next().getFileName().toString());@@ -236,7 +235,7 @@ public class TestReplicationHandlerBackup extends SolrJettyTestBase {final BackupStatusChecker backupStatus =new BackupStatusChecker(leaderClient, "/" + DEFAULT_TEST_CORENAME + "/replication");for (int i = 0; i < 2; i++) {- final Path p = Paths.get(leader.getDataDir(), "snapshot." + backupNames[i]);+ final Path p = Path.of(leader.getDataDir(), "snapshot." + backupNames[i]);assertTrue("WTF: Backup doesn't exist: " + p, Files.exists(p));runBackupCommand(leaderJetty, ReplicationHandler.CMD_DELETE_BACKUP, "&name=" + backupNames[i]);diff --git a/solr/core/src/test/org/apache/solr/handler/TestRestoreCore.java b/solr/core/src/test/org/apache/solr/handler/TestRestoreCore.javaindex e0d5a1a0110..4117af54a19 100644--- a/solr/core/src/test/org/apache/solr/handler/TestRestoreCore.java+++ b/solr/core/src/test/org/apache/solr/handler/TestRestoreCore.java@@ -22,7 +22,6 @@ import java.nio.charset.StandardCharsets;import java.nio.file.DirectoryStream;import java.nio.file.Files;import java.nio.file.Path;-import java.nio.file.Paths;import java.util.Properties;import java.util.concurrent.TimeUnit;import org.apache.lucene.index.IndexFileNames;@@ -219,7 +218,7 @@ public class TestRestoreCore extends SolrJettyTestBase {// Remove the segments_n file so that the backup index is corrupted.// Restore should fail, and it should automatically roll back to the original index.- final Path restoreIndexPath = Paths.get(location, backupDirName);+ final Path restoreIndexPath = Path.of(location, backupDirName);assertTrue("Does not exist: " + restoreIndexPath, Files.exists(restoreIndexPath));try (DirectoryStream<Path> stream =Files.newDirectoryStream(restoreIndexPath, IndexFileNames.SEGMENTS + "*")) {diff --git a/solr/core/src/test/org/apache/solr/handler/V2ApiIntegrationTest.java b/solr/core/src/test/org/apache/solr/handler/V2ApiIntegrationTest.javaindex 70ac4e89d8c..bd68337398e 100644--- a/solr/core/src/test/org/apache/solr/handler/V2ApiIntegrationTest.java+++ b/solr/core/src/test/org/apache/solr/handler/V2ApiIntegrationTest.java@@ -18,7 +18,7 @@package org.apache.solr.handler;import java.io.IOException;-import java.nio.file.Paths;+import java.nio.file.Path;import java.util.HashMap;import java.util.List;import java.util.Map;@@ -241,7 +241,7 @@ public class V2ApiIntegrationTest extends SolrCloudTestCase {backupParams.put("location", tempDir);cluster.getJettySolrRunners()- .forEach(j -> j.getCoreContainer().getAllowPaths().add(Paths.get(tempDir)));+ .forEach(j -> j.getCoreContainer().getAllowPaths().add(Path.of(tempDir)));client.request(new V2Request.Builder("/collections/" + COLL_NAME + "/backups/backup_test/versions").withMethod(SolrRequest.METHOD.POST)diff --git a/solr/core/src/test/org/apache/solr/handler/admin/CoreAdminHandlerTest.java b/solr/core/src/test/org/apache/solr/handler/admin/CoreAdminHandlerTest.javaindex fa895e7a842..4e96b051815 100644--- a/solr/core/src/test/org/apache/solr/handler/admin/CoreAdminHandlerTest.java+++ b/solr/core/src/test/org/apache/solr/handler/admin/CoreAdminHandlerTest.java@@ -23,7 +23,6 @@ import java.io.Reader;import java.nio.charset.StandardCharsets;import java.nio.file.Files;import java.nio.file.Path;-import java.nio.file.Paths;import java.nio.file.StandardCopyOption;import java.util.Map;import java.util.Properties;@@ -470,7 +469,7 @@ public class CoreAdminHandlerTest extends SolrTestCaseJ4 {try (SolrClient client = getHttpSolrClient(runner.getBaseUrl().toString())) {final var status = CoreAdminRequest.getCoreStatus("corex", true, client);String dataDirectory = status.dataDir;- dataDir = Paths.get(dataDirectory);+ dataDir = Path.of(dataDirectory);assertTrue(Files.exists(dataDir));}diff --git a/solr/core/src/test/org/apache/solr/handler/admin/TestApiFramework.java b/solr/core/src/test/org/apache/solr/handler/admin/TestApiFramework.javaindex 337a56205c8..d1c13ae73b4 100644--- a/solr/core/src/test/org/apache/solr/handler/admin/TestApiFramework.java+++ b/solr/core/src/test/org/apache/solr/handler/admin/TestApiFramework.java@@ -33,7 +33,6 @@ import static org.mockito.Mockito.when;import java.io.ByteArrayInputStream;import java.io.InputStream;import java.nio.file.Path;-import java.nio.file.Paths;import java.util.Collections;import java.util.HashMap;import java.util.HashSet;@@ -400,7 +399,7 @@ public class TestApiFramework extends SolrTestCaseJ4 {.when(mockCC).unload(any(String.class), anyBoolean(), anyBoolean(), anyBoolean());- when(mockCC.getCoreRootDirectory()).thenReturn(Paths.get("coreroot"));+ when(mockCC.getCoreRootDirectory()).thenReturn(Path.of("coreroot"));when(mockCC.getContainerProperties()).thenReturn(new Properties());when(mockCC.getRequestHandlers()).thenAnswer(invocationOnMock -> out.get("getRequestHandlers"));diff --git a/solr/core/src/test/org/apache/solr/handler/admin/api/BackupCoreAPITest.java b/solr/core/src/test/org/apache/solr/handler/admin/api/BackupCoreAPITest.javaindex b66fb6d04b9..2e5af32ff5d 100644--- a/solr/core/src/test/org/apache/solr/handler/admin/api/BackupCoreAPITest.java+++ b/solr/core/src/test/org/apache/solr/handler/admin/api/BackupCoreAPITest.java@@ -20,7 +20,6 @@ package org.apache.solr.handler.admin.api;import java.io.IOException;import java.net.URI;import java.nio.file.Path;-import java.nio.file.Paths;import org.apache.solr.SolrTestCaseJ4;import org.apache.solr.client.api.model.CreateCoreBackupRequestBody;import org.apache.solr.common.SolrException;@@ -170,7 +169,7 @@ public class BackupCoreAPITest extends SolrTestCaseJ4 {final Path locationPath = createBackupLocation();final URI locationUri = bootstrapBackupLocation(locationPath);final CoreContainer cores = h.getCoreContainer();- cores.getAllowPaths().add(Paths.get(locationUri));+ cores.getAllowPaths().add(Path.of(locationUri));final CreateCoreBackupRequestBody backupCoreRequestBody = new CreateCoreBackupRequestBody();backupCoreRequestBody.location = locationPath.toString();return backupCoreRequestBody;diff --git a/solr/core/src/test/org/apache/solr/handler/admin/api/MergeIndexesTest.java b/solr/core/src/test/org/apache/solr/handler/admin/api/MergeIndexesTest.javaindex 2165694e7d6..27fddaf1f86 100644--- a/solr/core/src/test/org/apache/solr/handler/admin/api/MergeIndexesTest.java+++ b/solr/core/src/test/org/apache/solr/handler/admin/api/MergeIndexesTest.java@@ -20,7 +20,7 @@ import static org.mockito.Mockito.doThrow;import static org.mockito.Mockito.mock;import static org.mockito.Mockito.when;-import java.nio.file.Paths;+import java.nio.file.Path;import java.util.Arrays;import org.apache.solr.SolrTestCaseJ4;import org.apache.solr.client.api.endpoint.MergeIndexesApi;@@ -103,7 +103,7 @@ public class MergeIndexesTest extends SolrTestCaseJ4 {when(mockSolrCore.getCoreContainer()).thenReturn(mockCoreContainer);doThrow(IndexOutOfBoundsException.class).when(mockCoreContainer)- .assertPathAllowed(Paths.get(path_not_allowed));+ .assertPathAllowed(Path.of(path_not_allowed));var exp =assertThrows(SolrException.class, () -> mergeIndexes.mergeIndexes(coreName, requestBody));}diff --git a/solr/core/src/test/org/apache/solr/rest/TestManagedResource.java b/solr/core/src/test/org/apache/solr/rest/TestManagedResource.javaindex 5b4338a4b99..bc9716055e3 100644--- a/solr/core/src/test/org/apache/solr/rest/TestManagedResource.java+++ b/solr/core/src/test/org/apache/solr/rest/TestManagedResource.java@@ -22,7 +22,7 @@ import java.io.InputStream;import java.io.ObjectInputStream;import java.io.ObjectOutputStream;import java.io.Serializable;-import java.nio.file.Paths;+import java.nio.file.Path;import java.util.ArrayList;import java.util.Arrays;import java.util.HashMap;@@ -217,7 +217,7 @@ public class TestManagedResource extends SolrTestCaseJ4 {storageIO.storage.put(storedResourceId, new BytesRef(json(storedJson)));ManagedTestResource res =- new ManagedTestResource(resourceId, new SolrResourceLoader(Paths.get("./")), storageIO);+ new ManagedTestResource(resourceId, new SolrResourceLoader(Path.of("./")), storageIO);res.loadManagedDataAndNotify(observers);assertTrue("Observer was not notified by ManagedResource!", observer.wasNotified);@@ -281,7 +281,7 @@ public class TestManagedResource extends SolrTestCaseJ4 {CustomStorageFormatResource res =new CustomStorageFormatResource(- resourceId, new SolrResourceLoader(Paths.get("./")), storageIO);+ resourceId, new SolrResourceLoader(Path.of("./")), storageIO);res.loadManagedDataAndNotify(observers);assertTrue("Observer was not notified by ManagedResource!", observer.wasNotified);diff --git a/solr/core/src/test/org/apache/solr/rest/TestRestManager.java b/solr/core/src/test/org/apache/solr/rest/TestRestManager.javaindex bda498b62e6..3d7f6707bcd 100644--- a/solr/core/src/test/org/apache/solr/rest/TestRestManager.java+++ b/solr/core/src/test/org/apache/solr/rest/TestRestManager.java@@ -19,7 +19,6 @@ package org.apache.solr.rest;import java.io.IOException;import java.nio.file.Files;import java.nio.file.Path;-import java.nio.file.Paths;import java.util.Arrays;import org.apache.solr.common.util.NamedList;import org.apache.solr.common.util.Utils;@@ -123,7 +122,7 @@ public class TestRestManager extends SolrRestletTestBase {@Testpublic void testReloadFromPersistentStorage() throws IOException {- SolrResourceLoader loader = new SolrResourceLoader(Paths.get("./"));+ SolrResourceLoader loader = new SolrResourceLoader(Path.of("./"));Path unitTestStorageDir = createTempDir("testRestManager");assertTrue(unitTestStorageDir + " is not a directory!", Files.isDirectory(unitTestStorageDir));assertTrue(Files.isReadable(unitTestStorageDir));diff --git a/solr/core/src/test/org/apache/solr/security/MultiDestinationAuditLoggerTest.java b/solr/core/src/test/org/apache/solr/security/MultiDestinationAuditLoggerTest.javaindex 84f46717f51..3b1ba2c4827 100644--- a/solr/core/src/test/org/apache/solr/security/MultiDestinationAuditLoggerTest.java+++ b/solr/core/src/test/org/apache/solr/security/MultiDestinationAuditLoggerTest.java@@ -17,7 +17,7 @@package org.apache.solr.security;import java.io.IOException;-import java.nio.file.Paths;+import java.nio.file.Path;import java.util.ArrayList;import java.util.Arrays;import java.util.HashMap;@@ -48,7 +48,7 @@ public class MultiDestinationAuditLoggerTest extends SolrTestCaseJ4 {plugins.add(conf2);config.put("plugins", plugins);- SolrResourceLoader loader = new SolrResourceLoader(Paths.get(""));+ SolrResourceLoader loader = new SolrResourceLoader(Path.of(""));al.inform(loader);al.init(config);diff --git a/solr/core/src/test/org/apache/solr/util/hll/IntegrationTestGenerator.java b/solr/core/src/test/org/apache/solr/util/hll/IntegrationTestGenerator.javaindex 8444b0f0cf6..1b062ea2db5 100644--- a/solr/core/src/test/org/apache/solr/util/hll/IntegrationTestGenerator.java+++ b/solr/core/src/test/org/apache/solr/util/hll/IntegrationTestGenerator.java@@ -25,7 +25,7 @@ import java.io.IOException;import java.io.Writer;import java.nio.charset.StandardCharsets;import java.nio.file.Files;-import java.nio.file.Paths;+import java.nio.file.Path;import java.util.Random;/**@@ -609,7 +609,7 @@ public class IntegrationTestGenerator {}final Writer output =- Files.newBufferedWriter(Paths.get(OUTPUT_DIRECTORY, filename), StandardCharsets.UTF_8);+ Files.newBufferedWriter(Path.of(OUTPUT_DIRECTORY, filename), StandardCharsets.UTF_8);output.write(header);output.flush();return output;diff --git a/solr/modules/extraction/src/test/org/apache/solr/handler/extraction/ParseContextConfigTest.java b/solr/modules/extraction/src/test/org/apache/solr/handler/extraction/ParseContextConfigTest.javaindex a8ce0cb74b2..7ea5df5471f 100644--- a/solr/modules/extraction/src/test/org/apache/solr/handler/extraction/ParseContextConfigTest.java+++ b/solr/modules/extraction/src/test/org/apache/solr/handler/extraction/ParseContextConfigTest.java@@ -16,7 +16,7 @@*/package org.apache.solr.handler.extraction;-import java.nio.file.Paths;+import java.nio.file.Path;import javax.xml.parsers.DocumentBuilderFactory;import org.apache.solr.SolrTestCaseJ4;import org.apache.solr.core.SolrResourceLoader;@@ -43,7 +43,7 @@ public class ParseContextConfigTest extends SolrTestCaseJ4 {entries.appendChild(entry);ParseContext parseContext =- new ParseContextConfig(new SolrResourceLoader(Paths.get(".")), entries).create();+ new ParseContextConfig(new SolrResourceLoader(Path.of(".")), entries).create();PDFParserConfig pdfParserConfig = parseContext.get(PDFParserConfig.class);diff --git a/solr/modules/jwt-auth/src/java/org/apache/solr/security/jwt/JWTAuthPlugin.java b/solr/modules/jwt-auth/src/java/org/apache/solr/security/jwt/JWTAuthPlugin.javaindex 5b9cdd42820..544540bf85e 100644--- a/solr/modules/jwt-auth/src/java/org/apache/solr/security/jwt/JWTAuthPlugin.java+++ b/solr/modules/jwt-auth/src/java/org/apache/solr/security/jwt/JWTAuthPlugin.java@@ -22,7 +22,6 @@ import java.lang.invoke.MethodHandles;import java.nio.charset.StandardCharsets;import java.nio.file.Files;import java.nio.file.Path;-import java.nio.file.Paths;import java.security.Principal;import java.security.cert.X509Certificate;import java.time.Instant;@@ -336,7 +335,7 @@ public class JWTAuthPlugin extends AuthenticationPlugin* @return list of certificates found in file*/Collection<? extends X509Certificate> parseCertsFromFile(String certFileName) throws IOException {- Path certFilePath = Paths.get(certFileName);+ Path certFilePath = Path.of(certFileName);if (coreContainer != null) {coreContainer.assertPathAllowed(certFilePath);}diff --git a/solr/modules/ltr/src/test/org/apache/solr/ltr/TestLTRReRankingPipeline.java b/solr/modules/ltr/src/test/org/apache/solr/ltr/TestLTRReRankingPipeline.javaindex 61e0fc91b07..041cfad6231 100644--- a/solr/modules/ltr/src/test/org/apache/solr/ltr/TestLTRReRankingPipeline.java+++ b/solr/modules/ltr/src/test/org/apache/solr/ltr/TestLTRReRankingPipeline.java@@ -18,7 +18,7 @@ package org.apache.solr.ltr;import java.io.IOException;import java.lang.invoke.MethodHandles;-import java.nio.file.Paths;+import java.nio.file.Path;import java.util.ArrayList;import java.util.Collections;import java.util.HashMap;@@ -56,7 +56,7 @@ public class TestLTRReRankingPipeline extends SolrTestCaseJ4 {private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());private static final SolrResourceLoader solrResourceLoader =- new SolrResourceLoader(Paths.get("").toAbsolutePath());+ new SolrResourceLoader(Path.of("").toAbsolutePath());@BeforeClasspublic static void setup() throws Exception {diff --git a/solr/modules/ltr/src/test/org/apache/solr/ltr/TestLTRScoringQuery.java b/solr/modules/ltr/src/test/org/apache/solr/ltr/TestLTRScoringQuery.javaindex 34612bc8b54..c5a582e69e3 100644--- a/solr/modules/ltr/src/test/org/apache/solr/ltr/TestLTRScoringQuery.java+++ b/solr/modules/ltr/src/test/org/apache/solr/ltr/TestLTRScoringQuery.java@@ -17,7 +17,7 @@package org.apache.solr.ltr;import java.io.IOException;-import java.nio.file.Paths;+import java.nio.file.Path;import java.util.ArrayList;import java.util.Collections;import java.util.HashMap;@@ -56,7 +56,7 @@ import org.junit.Test;public class TestLTRScoringQuery extends SolrTestCase {public static final SolrResourceLoader solrResourceLoader =- new SolrResourceLoader(Paths.get("").toAbsolutePath());+ new SolrResourceLoader(Path.of("").toAbsolutePath());private IndexSearcher getSearcher(IndexReader r) {final IndexSearcher searcher = newSearcher(r, false, false);diff --git a/solr/modules/ltr/src/test/org/apache/solr/ltr/norm/TestMinMaxNormalizer.java b/solr/modules/ltr/src/test/org/apache/solr/ltr/norm/TestMinMaxNormalizer.javaindex f112402075b..b51c4beab35 100644--- a/solr/modules/ltr/src/test/org/apache/solr/ltr/norm/TestMinMaxNormalizer.java+++ b/solr/modules/ltr/src/test/org/apache/solr/ltr/norm/TestMinMaxNormalizer.java@@ -16,7 +16,7 @@*/package org.apache.solr.ltr.norm;-import java.nio.file.Paths;+import java.nio.file.Path;import java.util.HashMap;import java.util.Map;import org.apache.solr.SolrTestCaseJ4;@@ -26,7 +26,7 @@ import org.junit.Test;public class TestMinMaxNormalizer extends SolrTestCaseJ4 {private final SolrResourceLoader solrResourceLoader =- new SolrResourceLoader(Paths.get("").toAbsolutePath());+ new SolrResourceLoader(Path.of("").toAbsolutePath());private Normalizer implTestMinMax(Map<String, Object> params, float expectedMin, float expectedMax) {@@ -111,7 +111,7 @@ public class TestMinMaxNormalizer extends SolrTestCaseJ4 {final MinMaxNormalizer n2 =(MinMaxNormalizer)Normalizer.getInstance(- new SolrResourceLoader(Paths.get("").toAbsolutePath()),+ new SolrResourceLoader(Path.of("").toAbsolutePath()),MinMaxNormalizer.class.getName(),params);assertEquals(n1.getMin(), n2.getMin(), 1e-6);diff --git a/solr/modules/ltr/src/test/org/apache/solr/ltr/norm/TestStandardNormalizer.java b/solr/modules/ltr/src/test/org/apache/solr/ltr/norm/TestStandardNormalizer.javaindex d040f763ba6..3693d365b31 100644--- a/solr/modules/ltr/src/test/org/apache/solr/ltr/norm/TestStandardNormalizer.java+++ b/solr/modules/ltr/src/test/org/apache/solr/ltr/norm/TestStandardNormalizer.java@@ -16,7 +16,7 @@*/package org.apache.solr.ltr.norm;-import java.nio.file.Paths;+import java.nio.file.Path;import java.util.HashMap;import java.util.Map;import org.apache.solr.SolrTestCaseJ4;@@ -26,7 +26,7 @@ import org.junit.Test;public class TestStandardNormalizer extends SolrTestCaseJ4 {private final SolrResourceLoader solrResourceLoader =- new SolrResourceLoader(Paths.get("").toAbsolutePath());+ new SolrResourceLoader(Path.of("").toAbsolutePath());private Normalizer implTestStandard(Map<String, Object> params, float expectedAvg, float expectedStd) {@@ -119,7 +119,7 @@ public class TestStandardNormalizer extends SolrTestCaseJ4 {final StandardNormalizer n2 =(StandardNormalizer)Normalizer.getInstance(- new SolrResourceLoader(Paths.get("").toAbsolutePath()),+ new SolrResourceLoader(Path.of("").toAbsolutePath()),StandardNormalizer.class.getName(),params);assertEquals(n1.getAvg(), n2.getAvg(), 1e-6);diff --git a/solr/prometheus-exporter/src/java/org/apache/solr/prometheus/exporter/SolrExporter.java b/solr/prometheus-exporter/src/java/org/apache/solr/prometheus/exporter/SolrExporter.javaindex d227a8b3b54..a1ae8cc1904 100644--- a/solr/prometheus-exporter/src/java/org/apache/solr/prometheus/exporter/SolrExporter.java+++ b/solr/prometheus-exporter/src/java/org/apache/solr/prometheus/exporter/SolrExporter.java@@ -21,7 +21,7 @@ import io.prometheus.client.exporter.HTTPServer;import java.io.IOException;import java.lang.invoke.MethodHandles;import java.net.InetSocketAddress;-import java.nio.file.Paths;+import java.nio.file.Path;import java.util.concurrent.ExecutorService;import org.apache.commons.cli.CommandLine;import org.apache.commons.cli.CommandLineParser;@@ -296,9 +296,9 @@ public class SolrExporter {log.info("SSL ENABLED");scrapeConfiguration.withSslConfiguration(- Paths.get(getSystemVariable("SOLR_SSL_KEY_STORE")),+ Path.of(getSystemVariable("SOLR_SSL_KEY_STORE")),getSystemVariable("SOLR_SSL_KEY_STORE_PASSWORD"),- Paths.get(getSystemVariable("SOLR_SSL_TRUST_STORE")),+ Path.of(getSystemVariable("SOLR_SSL_TRUST_STORE")),getSystemVariable("SOLR_SSL_TRUST_STORE_PASSWORD"));}diff --git a/solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/ZkMaintenanceUtils.java b/solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/ZkMaintenanceUtils.javaindex ee5c2fe393a..6e18e0d3e54 100644--- a/solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/ZkMaintenanceUtils.java+++ b/solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/ZkMaintenanceUtils.java@@ -23,7 +23,6 @@ import java.nio.file.FileSystems;import java.nio.file.FileVisitResult;import java.nio.file.Files;import java.nio.file.Path;-import java.nio.file.Paths;import java.nio.file.SimpleFileVisitor;import java.nio.file.attribute.BasicFileAttributes;import java.util.ArrayList;@@ -145,11 +144,9 @@ public class ZkMaintenanceUtils {throw new SolrServerException("Zookeeper node " + src + " has children and recursive is false");}- } else if (Files.isDirectory(Paths.get(src))) {+ } else if (Files.isDirectory(Path.of(src))) {throw new SolrServerException(- "Local path "- + Paths.get(src).toAbsolutePath()- + " is a directory and recurse is false");+ "Local path " + Path.of(src).toAbsolutePath() + " is a directory and recurse is false");}}@@ -166,7 +163,7 @@ public class ZkMaintenanceUtils {// local -> ZK copyif (dstIsZk) {- uploadToZK(zkClient, Paths.get(src), dst, null);+ uploadToZK(zkClient, Path.of(src), dst, null);return;}@@ -174,19 +171,19 @@ public class ZkMaintenanceUtils {// node has children. This is kind of a weak test for the notion of "directory" on Zookeeper. ZK// -> local copy where ZK is a parent nodeif (zkClient.getChildren(src, null, true).size() > 0) {- downloadFromZK(zkClient, src, Paths.get(dst));+ downloadFromZK(zkClient, src, Path.of(dst));return;}// Single file ZK -> local copy where ZK is a leaf node- if (Files.isDirectory(Paths.get(dst))) {+ if (Files.isDirectory(Path.of(dst))) {if (!dst.endsWith(FileSystems.getDefault().getSeparator())) {dst += FileSystems.getDefault().getSeparator();}dst = normalizeDest(src, dst, srcIsZk, dstIsZk);}byte[] data = zkClient.getData(src, null, null, true);- Path filename = Paths.get(dst);+ Path filename = Path.of(dst);Path parentDir = filename.getParent();if (parentDir != null) {Files.createDirectories(parentDir);@@ -201,7 +198,7 @@ public class ZkMaintenanceUtils {String srcName, String dstName, boolean srcIsZk, boolean dstIsZk) {// Special handling for "."if (dstName.equals(".")) {- return Paths.get(".").normalize().toAbsolutePath().toString();+ return Path.of(".").normalize().toAbsolutePath().toString();}String dstSeparator = (dstIsZk) ? "/" : FileSystems.getDefault().getSeparator();@@ -324,7 +321,7 @@ public class ZkMaintenanceUtils {path = path.substring(0, path.length() - 1);}- final Path rootPath = Paths.get(path);+ final Path rootPath = Path.of(path);if (!Files.exists(rootPath)) {throw new IOException("Path " + rootPath + " does not exist");diff --git a/solr/solrj-zookeeper/src/test/org/apache/solr/common/cloud/TestZkMaintenanceUtils.java b/solr/solrj-zookeeper/src/test/org/apache/solr/common/cloud/TestZkMaintenanceUtils.javaindex dae8bf88dba..20c3652d9d6 100644--- a/solr/solrj-zookeeper/src/test/org/apache/solr/common/cloud/TestZkMaintenanceUtils.java+++ b/solr/solrj-zookeeper/src/test/org/apache/solr/common/cloud/TestZkMaintenanceUtils.java@@ -178,7 +178,7 @@ public class TestZkMaintenanceUtils extends SolrTestCaseJ4 {try (FileInputStream fis = new FileInputStream(tmpDest.toFile())) {byte[] data = fis.readAllBytes();- assertEquals("Should have downloaded a one-byte file", data.length, 1);+ assertEquals("Should have downloaded a one-byte file", 1, data.length);assertEquals("contents of the one-byte file should be 0x30", 0x30, data[0]);}}diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/request/TestCoreAdmin.java b/solr/solrj/src/test/org/apache/solr/client/solrj/request/TestCoreAdmin.javaindex 86da8b2ab80..d0a52e9322b 100644--- a/solr/solrj/src/test/org/apache/solr/client/solrj/request/TestCoreAdmin.java+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/request/TestCoreAdmin.java@@ -23,7 +23,6 @@ import com.codahale.metrics.MetricRegistry;import java.io.IOException;import java.nio.file.Files;import java.nio.file.Path;-import java.nio.file.Paths;import java.util.Collection;import org.apache.commons.io.file.PathUtils;import org.apache.lucene.tests.util.LuceneTestCase;@@ -262,7 +261,7 @@ public class TestCoreAdmin extends AbstractEmbeddedSolrServerTestCase {cores = CoreContainer.createAndLoad(SOLR_HOME);String ddir = CoreAdminRequest.getCoreStatus("core0", getSolrCore0()).dataDir;- Path data = Paths.get(ddir, "index");+ Path data = Path.of(ddir, "index");assumeTrue("test can't handle relative data directory paths (yet?)", data.isAbsolute());getSolrCore0().add(new SolrInputDocument("id", "core0-1"));diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/response/QueryResponseTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/response/QueryResponseTest.javaindex 40602b73ea6..3ead4328b3e 100644--- a/solr/solrj/src/test/org/apache/solr/client/solrj/response/QueryResponseTest.java+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/response/QueryResponseTest.java@@ -21,7 +21,7 @@ import java.io.InputStream;import java.io.InputStreamReader;import java.io.Reader;import java.nio.charset.StandardCharsets;-import java.nio.file.Paths;+import java.nio.file.Path;import java.time.Instant;import java.util.Date;import java.util.List;@@ -46,7 +46,7 @@ public class QueryResponseTest extends SolrTestCase {public void testRangeFacets() throws Exception {XMLResponseParser parser = new XMLResponseParser();NamedList<Object> response = null;- try (SolrResourceLoader loader = new SolrResourceLoader(Paths.get("").toAbsolutePath());+ try (SolrResourceLoader loader = new SolrResourceLoader(Path.of("").toAbsolutePath());InputStream is = loader.openResource("solrj/sampleRangeFacetResponse.xml")) {assertNotNull(is);@@ -111,7 +111,7 @@ public class QueryResponseTest extends SolrTestCase {public void testGroupResponse() throws Exception {XMLResponseParser parser = new XMLResponseParser();NamedList<Object> response = null;- try (SolrResourceLoader loader = new SolrResourceLoader(Paths.get("").toAbsolutePath());+ try (SolrResourceLoader loader = new SolrResourceLoader(Path.of("").toAbsolutePath());InputStream is = loader.openResource("solrj/sampleGroupResponse.xml")) {assertNotNull(is);try (Reader in = new InputStreamReader(is, StandardCharsets.UTF_8)) {@@ -217,7 +217,7 @@ public class QueryResponseTest extends SolrTestCase {XMLResponseParser parser = new XMLResponseParser();NamedList<Object> response = null;- try (SolrResourceLoader loader = new SolrResourceLoader(Paths.get("").toAbsolutePath());+ try (SolrResourceLoader loader = new SolrResourceLoader(Path.of("").toAbsolutePath());InputStream is = loader.openResource("solrj/sampleSimpleGroupResponse.xml")) {assertNotNull(is);try (Reader in = new InputStreamReader(is, StandardCharsets.UTF_8)) {@@ -260,7 +260,7 @@ public class QueryResponseTest extends SolrTestCase {@Testpublic void testIntervalFacetsResponse() throws Exception {XMLResponseParser parser = new XMLResponseParser();- try (SolrResourceLoader loader = new SolrResourceLoader(Paths.get("").toAbsolutePath())) {+ try (SolrResourceLoader loader = new SolrResourceLoader(Path.of("").toAbsolutePath())) {InputStream is = loader.openResource("solrj/sampleIntervalFacetsResponse.xml");assertNotNull(is);Reader in = new InputStreamReader(is, StandardCharsets.UTF_8);@@ -303,7 +303,7 @@ public class QueryResponseTest extends SolrTestCase {XMLResponseParser parser = new XMLResponseParser();NamedList<Object> response;- try (SolrResourceLoader loader = new SolrResourceLoader(Paths.get("").toAbsolutePath());+ try (SolrResourceLoader loader = new SolrResourceLoader(Path.of("").toAbsolutePath());InputStream is = loader.openResource("solrj/sampleDebugResponse.xml")) {assertNotNull(is);try (Reader in = new InputStreamReader(is, StandardCharsets.UTF_8)) {diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/response/TestClusteringResponse.java b/solr/solrj/src/test/org/apache/solr/client/solrj/response/TestClusteringResponse.javaindex caed38d12f1..f89aef42c38 100644--- a/solr/solrj/src/test/org/apache/solr/client/solrj/response/TestClusteringResponse.java+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/response/TestClusteringResponse.java@@ -20,7 +20,7 @@ import java.io.InputStream;import java.io.InputStreamReader;import java.io.Reader;import java.nio.charset.StandardCharsets;-import java.nio.file.Paths;+import java.nio.file.Path;import java.util.Arrays;import java.util.List;import org.apache.solr.SolrJettyTestBase;@@ -38,7 +38,7 @@ public class TestClusteringResponse extends SolrJettyTestBase {NamedList<Object> response = null;/*Load a simple XML with the clustering response encoded in an XML format*/- try (SolrResourceLoader loader = new SolrResourceLoader(Paths.get("").toAbsolutePath());+ try (SolrResourceLoader loader = new SolrResourceLoader(Path.of("").toAbsolutePath());InputStream is = loader.openResource("solrj/sampleClusteringResponse.xml")) {assertNotNull(is);try (Reader in = new InputStreamReader(is, StandardCharsets.UTF_8)) {diff --git a/solr/solrj/src/test/org/apache/solr/common/util/ContentStreamTest.java b/solr/solrj/src/test/org/apache/solr/common/util/ContentStreamTest.javaindex 4d31019bba0..fe04cd2aac3 100644--- a/solr/solrj/src/test/org/apache/solr/common/util/ContentStreamTest.java+++ b/solr/solrj/src/test/org/apache/solr/common/util/ContentStreamTest.java@@ -24,7 +24,6 @@ import java.io.Reader;import java.nio.charset.StandardCharsets;import java.nio.file.Files;import java.nio.file.Path;-import java.nio.file.Paths;import java.util.zip.GZIPInputStream;import java.util.zip.GZIPOutputStream;import org.apache.commons.io.IOUtils;@@ -44,7 +43,7 @@ public class ContentStreamTest extends SolrTestCaseJ4 {public void testFileStream() throws IOException {Path file = createTempDir().resolve("README");- try (SolrResourceLoader srl = new SolrResourceLoader(Paths.get("").toAbsolutePath());+ try (SolrResourceLoader srl = new SolrResourceLoader(Path.of("").toAbsolutePath());InputStream is = srl.openResource("solrj/README");OutputStream os = Files.newOutputStream(file)) {assertNotNull(is);@@ -68,7 +67,7 @@ public class ContentStreamTest extends SolrTestCaseJ4 {public void testFileStreamGZIP() throws IOException {Path file = createTempDir().resolve("README.gz");- try (SolrResourceLoader srl = new SolrResourceLoader(Paths.get("").toAbsolutePath());+ try (SolrResourceLoader srl = new SolrResourceLoader(Path.of("").toAbsolutePath());InputStream is = srl.openResource("solrj/README");OutputStream os = Files.newOutputStream(file);GZIPOutputStream zos = new GZIPOutputStream(os)) {@@ -94,7 +93,7 @@ public class ContentStreamTest extends SolrTestCaseJ4 {public void testURLStream() throws IOException {Path file = createTempDir().resolve("README");- try (SolrResourceLoader srl = new SolrResourceLoader(Paths.get("").toAbsolutePath());+ try (SolrResourceLoader srl = new SolrResourceLoader(Path.of("").toAbsolutePath());InputStream is = srl.openResource("solrj/README");OutputStream os = Files.newOutputStream(file)) {is.transferTo(os);@@ -124,7 +123,7 @@ public class ContentStreamTest extends SolrTestCaseJ4 {public void testURLStreamGZIP() throws IOException {Path file = createTempDir().resolve("README.gz");- try (SolrResourceLoader srl = new SolrResourceLoader(Paths.get("").toAbsolutePath());+ try (SolrResourceLoader srl = new SolrResourceLoader(Path.of("").toAbsolutePath());InputStream is = srl.openResource("solrj/README");OutputStream os = Files.newOutputStream(file);GZIPOutputStream zos = new GZIPOutputStream(os)) {@@ -150,7 +149,7 @@ public class ContentStreamTest extends SolrTestCaseJ4 {public void testURLStreamCSVGZIPExtension() throws IOException {Path file = createTempDir().resolve("README.CSV.gz");- try (SolrResourceLoader srl = new SolrResourceLoader(Paths.get("").toAbsolutePath());+ try (SolrResourceLoader srl = new SolrResourceLoader(Path.of("").toAbsolutePath());InputStream is = srl.openResource("solrj/README");OutputStream os = Files.newOutputStream(file);GZIPOutputStream zos = new GZIPOutputStream(os)) {@@ -176,7 +175,7 @@ public class ContentStreamTest extends SolrTestCaseJ4 {public void testURLStreamJSONGZIPExtension() throws IOException {Path file = createTempDir().resolve("README.json.gzip");- try (SolrResourceLoader srl = new SolrResourceLoader(Paths.get("").toAbsolutePath());+ try (SolrResourceLoader srl = new SolrResourceLoader(Path.of("").toAbsolutePath());InputStream is = srl.openResource("solrj/README");OutputStream os = Files.newOutputStream(file);GZIPOutputStream zos = new GZIPOutputStream(os)) {diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/api/collections/AbstractCollectionsAPIDistributedZkTestBase.java b/solr/test-framework/src/java/org/apache/solr/cloud/api/collections/AbstractCollectionsAPIDistributedZkTestBase.javaindex 0cc34c59d72..0a2a7ae6099 100644--- a/solr/test-framework/src/java/org/apache/solr/cloud/api/collections/AbstractCollectionsAPIDistributedZkTestBase.java+++ b/solr/test-framework/src/java/org/apache/solr/cloud/api/collections/AbstractCollectionsAPIDistributedZkTestBase.java@@ -24,7 +24,6 @@ import java.lang.invoke.MethodHandles;import java.lang.management.ManagementFactory;import java.nio.file.Files;import java.nio.file.Path;-import java.nio.file.Paths;import java.util.ArrayList;import java.util.Collection;import java.util.Collections;@@ -523,7 +522,7 @@ public abstract class AbstractCollectionsAPIDistributedZkTestBase extends SolrCl"Could not find expected core.properties file",Files.exists(instancedir.resolve("core.properties")));- Path expected = Paths.get(jetty.getSolrHome()).resolve(core.getName());+ Path expected = Path.of(jetty.getSolrHome()).resolve(core.getName());assertTrue("Expected: " + expected + "\nFrom core stats: " + instancedir,diff --git a/solr/test-framework/src/java/org/apache/solr/util/MockCoreContainer.java b/solr/test-framework/src/java/org/apache/solr/util/MockCoreContainer.javaindex 000905208ee..06fcc1796be 100644--- a/solr/test-framework/src/java/org/apache/solr/util/MockCoreContainer.java+++ b/solr/test-framework/src/java/org/apache/solr/util/MockCoreContainer.java@@ -17,7 +17,6 @@package org.apache.solr.util;import java.nio.file.Path;-import java.nio.file.Paths;import java.util.Collections;import org.apache.solr.core.CoreContainer;import org.apache.solr.core.CoreDescriptor;@@ -25,7 +24,7 @@ import org.apache.solr.core.CoreDescriptor;public class MockCoreContainer extends CoreContainer {public static class MockCoreDescriptor extends CoreDescriptor {public MockCoreDescriptor() {- super("mock", Paths.get("path").toAbsolutePath(), Collections.emptyMap(), null, null);+ super("mock", Path.of("path").toAbsolutePath(), Collections.emptyMap(), null, null);}}@@ -35,6 +34,6 @@ public class MockCoreContainer extends CoreContainer {@Overridepublic Path getCoreRootDirectory() {- return Paths.get("coreroot");+ return Path.of("coreroot");}}diff --git a/solr/test-framework/src/java/org/apache/solr/util/TestHarness.java b/solr/test-framework/src/java/org/apache/solr/util/TestHarness.javaindex 87d53af970a..2e18bf4c33b 100644--- a/solr/test-framework/src/java/org/apache/solr/util/TestHarness.java+++ b/solr/test-framework/src/java/org/apache/solr/util/TestHarness.java@@ -18,7 +18,6 @@ package org.apache.solr.util;import java.io.IOException;import java.nio.file.Path;-import java.nio.file.Paths;import java.util.HashMap;import java.util.List;import java.util.Map;@@ -139,7 +138,7 @@ public class TestHarness extends BaseTestHarness {+ SOLR_HOME+ " sys prop to be set by test first");}- return Paths.get(home).toAbsolutePath().normalize();+ return Path.of(home).toAbsolutePath().normalize();}/**diff --git a/solr/test-framework/src/test/org/apache/solr/cloud/MiniSolrCloudClusterTest.java b/solr/test-framework/src/test/org/apache/solr/cloud/MiniSolrCloudClusterTest.javaindex f5454b59657..8c8243e172c 100644--- a/solr/test-framework/src/test/org/apache/solr/cloud/MiniSolrCloudClusterTest.java+++ b/solr/test-framework/src/test/org/apache/solr/cloud/MiniSolrCloudClusterTest.java@@ -23,7 +23,6 @@ import java.io.IOException;import java.nio.charset.StandardCharsets;import java.nio.file.Files;import java.nio.file.Path;-import java.nio.file.Paths;import java.util.Properties;import java.util.concurrent.atomic.AtomicInteger;import org.apache.lucene.tests.util.LuceneTestCase;@@ -119,8 +118,8 @@ public class MiniSolrCloudClusterTest extends SolrTestCaseJ4 {System.setProperty(SOLR_HOME_PROP, fakeSolrHome);// mock FS from createTempDir don't play nice using 'startsWith' when the solr stack- // reconsistutes the path from string so we have to go the string route here as well...- final Path workDir = Paths.get(createTempDir().toAbsolutePath().toString());+ // reconstitutes the path from string so we have to go the string route here as well...+ final Path workDir = Path.of(createTempDir().toAbsolutePath().toString());final MiniSolrCloudCluster cluster =new MiniSolrCloudCluster(1, workDir, JettyConfig.builder().build());