diff --git a/core/idrepo/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/JavaDocUtils.java b/core/idrepo/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/JavaDocUtils.java index f1899f6432..010ea190f5 100644 --- a/core/idrepo/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/JavaDocUtils.java +++ b/core/idrepo/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/JavaDocUtils.java @@ -23,6 +23,7 @@ import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; +import java.nio.file.Path; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -41,7 +42,7 @@ public final class JavaDocUtils { private static URL toURL(final String classPathEntry) { try { - return new File(classPathEntry).toURI().toURL(); + return Path.of(classPathEntry).toUri().toURL(); } catch (MalformedURLException e) { throw new IllegalArgumentException("URL could not be created from '" + classPathEntry + "'", e); } diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/utils/URIUtils.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/utils/URIUtils.java index ad85519b3a..44668f290a 100644 --- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/utils/URIUtils.java +++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/utils/URIUtils.java @@ -18,10 +18,10 @@ */ package org.apache.syncope.core.persistence.api.utils; -import java.io.File; import java.net.MalformedURLException; import java.net.URI; import java.net.URISyntaxException; +import java.nio.file.Path; public final class URIUtils { @@ -50,7 +50,7 @@ public static URI buildForConnId(final String location) throws MalformedURLExcep URI uri; if (candidate.startsWith("file:")) { - uri = new File(new URI(candidate).toURL().getFile()).getAbsoluteFile().toURI(); + uri = Path.of(new URI(candidate)).toAbsolutePath().toFile().toURI(); } else { uri = new URI(candidate); } diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/ConnInstanceTest.java b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/ConnInstanceTest.java index 48341d28bd..159b4a0c4f 100644 --- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/ConnInstanceTest.java +++ b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/ConnInstanceTest.java @@ -24,7 +24,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; -import java.io.File; +import java.nio.file.Path; import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; @@ -91,7 +91,7 @@ public void findById() { public void save() throws ClassNotFoundException { ConnInstance connInstance = entityFactory.newEntity(ConnInstance.class); - connInstance.setLocation(new File(System.getProperty("java.io.tmpdir")).toURI().toString()); + connInstance.setLocation(Path.of(System.getProperty("java.io.tmpdir")).toUri().toString()); // set connector version connInstance.setVersion("1.0"); diff --git a/core/persistence-neo4j/src/test/java/org/apache/syncope/core/persistence/neo4j/inner/ConnInstanceTest.java b/core/persistence-neo4j/src/test/java/org/apache/syncope/core/persistence/neo4j/inner/ConnInstanceTest.java index 29ca773e65..91b2c16b1f 100644 --- a/core/persistence-neo4j/src/test/java/org/apache/syncope/core/persistence/neo4j/inner/ConnInstanceTest.java +++ b/core/persistence-neo4j/src/test/java/org/apache/syncope/core/persistence/neo4j/inner/ConnInstanceTest.java @@ -24,7 +24,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; -import java.io.File; +import java.nio.file.Path; import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; @@ -91,7 +91,7 @@ public void findById() { public void save() throws ClassNotFoundException { ConnInstance connInstance = entityFactory.newEntity(ConnInstance.class); - connInstance.setLocation(new File(System.getProperty("java.io.tmpdir")).toURI().toString()); + connInstance.setLocation(Path.of(System.getProperty("java.io.tmpdir")).toUri().toString()); // set connector version connInstance.setVersion("1.0"); diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/ConnectorFacadeProxy.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/ConnectorFacadeProxy.java index b2f147b7af..9aafd47da9 100644 --- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/ConnectorFacadeProxy.java +++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/ConnectorFacadeProxy.java @@ -20,6 +20,7 @@ import java.io.File; import java.net.URI; +import java.nio.file.Path; import java.util.List; import java.util.Set; import java.util.concurrent.Future; @@ -539,7 +540,7 @@ private static Object getPropertyValue(final String propType, final List valu } else if (URI.class.equals(propertySchemaClass)) { value = URI.create(values.get(0).toString()); } else if (File.class.equals(propertySchemaClass)) { - value = new File(values.get(0).toString()); + value = Path.of(values.get(0).toString()).toFile(); } else if (String[].class.equals(propertySchemaClass)) { value = values.toArray(String[]::new); } else { diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/DefaultConnIdBundleManager.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/DefaultConnIdBundleManager.java index 5da3886abc..85cb1477c4 100644 --- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/DefaultConnIdBundleManager.java +++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/DefaultConnIdBundleManager.java @@ -22,6 +22,7 @@ import java.io.IOException; import java.net.URI; import java.net.URL; +import java.nio.file.Path; import java.security.cert.X509Certificate; import java.util.ArrayList; import java.util.Collections; @@ -82,7 +83,7 @@ public List getLocations() { protected void initLocal(final URI location) { // 1. Find bundles inside local directory - File bundleDirectory = new File(location); + File bundleDirectory = Path.of(location).toFile(); String[] bundleFiles = bundleDirectory.list(); if (bundleFiles == null) { throw new NotFoundException("Local bundles directory " + location); @@ -91,7 +92,7 @@ protected void initLocal(final URI location) { List bundleFileURLs = new ArrayList<>(); for (String file : bundleFiles) { try { - bundleFileURLs.add(IOUtil.makeURL(bundleDirectory, file)); + bundleFileURLs.add(IOUtil.makeURL(bundleDirectory.toPath(), file)); } catch (IOException ignore) { // ignore exception and don't add bundle LOG.debug("{}/{} is not a valid connector bundle", bundleDirectory.toString(), file, ignore); @@ -221,7 +222,7 @@ public Pair getConnectorInfo(final ConnInstance connInstance if (LOG.isDebugEnabled()) { LOG.debug("\nBundle name: {}\nBundle version: {}\nBundle class: {}", - key.getBundleName(), key.getBundleVersion(), key.getConnectorName()); + key.getBundleName(), key.getBundleVersion(), key.getConnectorName()); } // get the specified connector diff --git a/fit/core-reference/src/main/java/org/apache/syncope/fit/core/reference/TestFileAuditProcessor.java b/fit/core-reference/src/main/java/org/apache/syncope/fit/core/reference/TestFileAuditProcessor.java index 790c2a0edd..9554d8ce8d 100644 --- a/fit/core-reference/src/main/java/org/apache/syncope/fit/core/reference/TestFileAuditProcessor.java +++ b/fit/core-reference/src/main/java/org/apache/syncope/fit/core/reference/TestFileAuditProcessor.java @@ -19,7 +19,7 @@ package org.apache.syncope.fit.core.reference; import java.nio.file.Files; -import java.nio.file.Paths; +import java.nio.file.Path; import java.nio.file.StandardOpenOption; import java.util.Set; import org.apache.syncope.common.lib.types.OpEvent; @@ -67,7 +67,7 @@ public void process(final String domain, final AuditEvent event) { String content = POJOHelper.serialize(auditEventDAO.toAuditEventTO(event)) + '\n'; try { Files.writeString( - Paths.get(fileName), + Path.of(fileName), content, StandardOpenOption.CREATE, StandardOpenOption.APPEND); } catch (Exception e) { diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/AuditITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/AuditITCase.java index 6bcf7e128e..6b8cfb7edd 100644 --- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/AuditITCase.java +++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/AuditITCase.java @@ -35,7 +35,6 @@ import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; import java.time.OffsetDateTime; import java.util.HashSet; import java.util.List; @@ -453,8 +452,7 @@ public void auditEventProcessor() throws IOException, InterruptedException { Properties props = new Properties(); props.load(propStream); - Path auditFilePath = Paths.get(props.getProperty("test.log.dir") - + File.separator + "audit_for_Master_file"); + Path auditFilePath = Path.of(props.getProperty("test.log.dir") + File.separator + "audit_for_Master_file"); // check that resource update is transformed and logged onto an audit file. ResourceTO resource = RESOURCE_SERVICE.read(RESOURCE_NAME_CSV); diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/PullTaskITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/PullTaskITCase.java index 807214cf91..73d990d33b 100644 --- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/PullTaskITCase.java +++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/PullTaskITCase.java @@ -29,11 +29,12 @@ import static org.junit.jupiter.api.Assumptions.assumeFalse; import jakarta.ws.rs.core.Response; -import java.io.FileInputStream; -import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; +import java.io.OutputStream; import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; import java.time.OffsetDateTime; import java.util.ArrayList; import java.util.Collections; @@ -282,8 +283,8 @@ public void fromCSV() throws Exception { try (InputStream propStream = getClass().getResourceAsStream("/test.properties")) { props.load(propStream); - try (InputStream src = new FileInputStream(props.getProperty("test.csv.src")); - FileOutputStream dst = new FileOutputStream(props.getProperty("test.csv.dst"))) { + try (InputStream src = Files.newInputStream(Path.of(props.getProperty("test.csv.src"))); + OutputStream dst = Files.newOutputStream(Path.of(props.getProperty("test.csv.dst")))) { IOUtils.copy(src, dst); } diff --git a/pom.xml b/pom.xml index 593c6e9577..8cfeed9fef 100644 --- a/pom.xml +++ b/pom.xml @@ -395,10 +395,10 @@ under the License. 2024-12-27T11:02:14Z ${project.version} - 1.6.0.0-RC3 - 1.5.0-RC2 - 1.1.0-RC2 - 2.4.0-RC1 + 1.6.0.0-SNAPSHOT + 1.5.0-SNAPSHOT + 1.1.0-SNAPSHOT + 2.4.0-SNAPSHOT 0.8.9 1.5.9 1.3.9 @@ -1752,7 +1752,7 @@ under the License. org.gaul modernizer-maven-plugin - 2.9.0 + 3.0.0 ${targetJdk} @@ -2263,6 +2263,7 @@ under the License. none true true + true true