Skip to content

Commit

Permalink
Upgrading modernizer-maven-plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
ilgrosso committed Dec 30, 2024
1 parent e9bcfad commit 25b5939
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -42,7 +43,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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,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.HashSet;
import java.util.List;
import java.util.Set;
Expand Down Expand Up @@ -93,7 +93,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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@
*/
package org.apache.syncope.core.provisioning.api.utils;

import java.io.File;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.Path;

public final class URIUtils {

Expand Down Expand Up @@ -51,7 +50,7 @@ public static URI buildForConnId(final String location) throws MalformedURLExcep

URI uri;
if (candidate.startsWith("file:")) {
uri = new File(new URL(candidate).getFile()).getAbsoluteFile().toURI();
uri = Path.of(new URI(candidate)).toAbsolutePath().toFile().toURI();
} else {
uri = new URI(candidate);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -239,7 +240,7 @@ public Set<AttributeDelta> updateDelta(
if (connInstance.getCapabilities().contains(ConnectorCapability.UPDATE_DELTA)) {
propagationAttempted.set(true);

Future<Set<AttributeDelta>> future =
Future<Set<AttributeDelta>> future =
asyncFacade.updateDelta(connector, objectClass, uid, modifications, options);

try {
Expand Down Expand Up @@ -520,7 +521,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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.CertificateException;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
Expand Down Expand Up @@ -83,7 +84,7 @@ public List<URI> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
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.time.OffsetDateTime;
import java.util.HashSet;
Expand Down Expand Up @@ -472,11 +471,11 @@ public void customAuditAppender() throws IOException, InterruptedException {
Properties props = new Properties();
props.load(propStream);

Path auditFilePath = Paths.get(props.getProperty("test.log.dir")
Path auditFilePath = Path.of(props.getProperty("test.log.dir")
+ File.separator + "audit_for_Master_file.log");
Files.write(auditFilePath, new byte[0], StandardOpenOption.TRUNCATE_EXISTING);

Path auditNoRewriteFilePath = Paths.get(props.getProperty("test.log.dir")
Path auditNoRewriteFilePath = Path.of(props.getProperty("test.log.dir")
+ File.separator + "audit_for_Master_norewrite_file.log");
Files.write(auditNoRewriteFilePath, new byte[0], StandardOpenOption.TRUNCATE_EXISTING);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
import static org.junit.jupiter.api.Assertions.fail;
import static org.junit.jupiter.api.Assumptions.assumeFalse;

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.Collections;
import java.util.Date;
Expand Down Expand Up @@ -237,29 +237,16 @@ public void fromCSV() throws Exception {

// Attemp to reset CSV content
Properties props = new Properties();
InputStream propStream = null;
InputStream srcStream = null;
OutputStream dstStream = null;
try {
propStream = getClass().getResourceAsStream("/test.properties");
try (InputStream propStream = getClass().getResourceAsStream("/test.properties")) {
props.load(propStream);

srcStream = new FileInputStream(props.getProperty("test.csv.src"));
dstStream = 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(srcStream, dstStream);
} catch (IOException e) {
fail(e::getMessage);
} finally {
if (propStream != null) {
propStream.close();
}
if (srcStream != null) {
srcStream.close();
}
if (dstStream != null) {
dstStream.close();
IOUtils.copy(src, dst);
}
} catch (IOException e) {
fail(e.getMessage(), e);
}

// -----------------------------
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1834,7 +1834,7 @@ under the License.
<plugin>
<groupId>org.gaul</groupId>
<artifactId>modernizer-maven-plugin</artifactId>
<version>2.9.0</version>
<version>3.0.0</version>
<configuration>
<javaVersion>${targetJdk}</javaVersion>
<ignorePackages>
Expand Down

0 comments on commit 25b5939

Please sign in to comment.