diff --git a/build.gradle b/build.gradle index 901f2a5..174444c 100644 --- a/build.gradle +++ b/build.gradle @@ -4,10 +4,10 @@ plugins { id "pmd" id 'maven-publish' id 'signing' - id "io.github.gradle-nexus.publish-plugin" version "1.3.0" - id "com.github.spotbugs" version "5.0.14" - id "org.cyclonedx.bom" version "1.7.2" - id "org.xbib.gradle.plugin.asciidoctor" version "2.5.2.2" + id "io.github.gradle-nexus.publish-plugin" version "2.0.0-rc-1" + id "com.github.spotbugs" version "6.0.0-beta.3" + id "org.cyclonedx.bom" version "1.7.4" + id "org.xbib.gradle.plugin.asciidoctor" version "3.0.0" } wrapper { @@ -38,7 +38,7 @@ subprojects { apply from: rootProject.file('gradle/documentation/asciidoc.gradle') apply from: rootProject.file('gradle/quality/checkstyle.gradle') apply from: rootProject.file('gradle/quality/pmd.gradle') - apply from: rootProject.file('gradle/quality/spotbugs.gradle') + //apply from: rootProject.file('gradle/quality/spotbugs.gradle') apply from: rootProject.file('gradle/publish/maven.gradle') } apply from: rootProject.file('gradle/publish/sonatype.gradle') diff --git a/gradle.properties b/gradle.properties index abc1dda..c84789c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ group = org.xbib name = net -version = 3.3.4 +version = 4.0.0 org.gradle.warning.mode = ALL diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index c1962a7..7f93135 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 8707e8b..e30733a 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-rc-1-all.zip networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index aeb74cb..1aa94a4 100755 --- a/gradlew +++ b/gradlew @@ -83,7 +83,8 @@ done # This is normally unused # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -130,10 +131,13 @@ location of your Java installation." fi else JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. @@ -141,7 +145,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac @@ -149,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then '' | soft) :;; #( *) # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -198,11 +202,11 @@ fi # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ diff --git a/net-path/src/main/java/org/xbib/net/path/PathDecoder.java b/net-path/src/main/java/org/xbib/net/path/PathDecoder.java index 11e9a7e..89dc5ac 100644 --- a/net-path/src/main/java/org/xbib/net/path/PathDecoder.java +++ b/net-path/src/main/java/org/xbib/net/path/PathDecoder.java @@ -23,10 +23,10 @@ public class PathDecoder { this.path = PathNormalizer.normalize(path); this.params = Parameter.builder().domain(Parameter.Domain.PATH).enablePercentDecoding(); if (query != null) { - parse(query); + this.params.add(query); } if (queryString != null) { - parse(queryString); + this.params.add(queryString); } } diff --git a/net-path/src/main/java/org/xbib/net/path/simple/PathMatcher.java b/net-path/src/main/java/org/xbib/net/path/simple/PathMatcher.java index dccfb57..3fc8b8f 100644 --- a/net-path/src/main/java/org/xbib/net/path/simple/PathMatcher.java +++ b/net-path/src/main/java/org/xbib/net/path/simple/PathMatcher.java @@ -30,11 +30,16 @@ public class PathMatcher { } public PathMatcher(String pathSeparator) { - setPathSeparator(pathSeparator); + this.pathSeparator = pathSeparator; + update(); } public void setPathSeparator(String pathSeparator) { - this.pathSeparator = pathSeparator != null ? pathSeparator : DEFAULT_PATH_SEPARATOR; + this.pathSeparator = pathSeparator; + update(); + } + + private void update() { this.endsOnWildCard = this.pathSeparator + "*"; this.endsOnDoubleWildCard = this.pathSeparator + "**"; this.caseSensitive = true; diff --git a/net-path/src/main/java/org/xbib/net/path/spring/element/RegexPathElement.java b/net-path/src/main/java/org/xbib/net/path/spring/element/RegexPathElement.java index d46e017..34a45f6 100644 --- a/net-path/src/main/java/org/xbib/net/path/spring/element/RegexPathElement.java +++ b/net-path/src/main/java/org/xbib/net/path/spring/element/RegexPathElement.java @@ -38,8 +38,7 @@ public class RegexPathElement extends PathElement { this.pattern = buildPattern(regex, completePattern); } - - public Pattern buildPattern(char[] regex, char[] completePattern) { + private Pattern buildPattern(char[] regex, char[] completePattern) { StringBuilder patternBuilder = new StringBuilder(); String text = new String(regex); Matcher matcher = GLOB_PATTERN.matcher(text); diff --git a/net-path/src/main/java/org/xbib/net/path/structure/Path.java b/net-path/src/main/java/org/xbib/net/path/structure/Path.java index 0a4091d..b7c9f5d 100644 --- a/net-path/src/main/java/org/xbib/net/path/structure/Path.java +++ b/net-path/src/main/java/org/xbib/net/path/structure/Path.java @@ -52,7 +52,7 @@ public class Path { return new Path(pathSpec); } - public void init(String pathSpec, String pathSeparator, boolean trimTokens, boolean caseSensitive) { + protected final void init(String pathSpec, String pathSeparator, boolean trimTokens, boolean caseSensitive) { this.pathSpec = PathNormalizer.normalize(pathSpec); this.pathSeparator = pathSeparator; this.trimTokens = trimTokens; @@ -140,11 +140,11 @@ public class Path { return Objects.hash(pathSpec, parameterCount, singleWildcards, doubleWildcards, catchAllPattern, prefixPattern, length); } - public List tokenize(String string) { + protected final List tokenize(String string) { return tokenize(string, pathSeparator, trimTokens, caseSensitive); } - public static List tokenize(String string, String pathSeparator, boolean trimTokens, boolean caseSensitive) { + protected static List tokenize(String string, String pathSeparator, boolean trimTokens, boolean caseSensitive) { List pathSegments = new ArrayList<>(); if (string == null) { return pathSegments; @@ -155,7 +155,7 @@ public class Path { if (trimTokens) { token = token.trim(); } - if (token.length() > 0) { + if (!token.isEmpty()) { if (!caseSensitive) { token = token.toLowerCase(Locale.ROOT); } diff --git a/net-resource/src/main/java/org/xbib/net/resource/IRI.java b/net-resource/src/main/java/org/xbib/net/resource/IRI.java index 6764f7e..ad993e5 100644 --- a/net-resource/src/main/java/org/xbib/net/resource/IRI.java +++ b/net-resource/src/main/java/org/xbib/net/resource/IRI.java @@ -1538,43 +1538,29 @@ public final class IRI extends ResourceIdentifier * or if some other error occurred while constructing the URL */ public URL toURL() throws MalformedURLException { - return fromURI(this); - } - - /** - * Creates a URL from an IRI, as if by invoking {@code iri.toURL()}. - * - */ - static URL fromURI(IRI uri) throws MalformedURLException { - if (!uri.isAbsolute()) { + if (!isAbsolute()) { throw new IllegalArgumentException("URI is not absolute"); } - String protocol = uri.getScheme(); - + String protocol = getScheme(); // In general we need to go via Handler.parseURL, but for the jrt // protocol we enforce that the Handler is not overrideable and can // optimize URI to URL conversion. - // // Case-sensitive comparison for performance; malformed protocols will // be handled correctly by the slow path. - if (protocol.equals("jrt") && !uri.isOpaque() - && uri.getRawFragment() == null) { - - String query = uri.getRawQuery(); - String path = uri.getRawPath(); + if (protocol.equals("jrt") && !isOpaque() + && getRawFragment() == null) { + String query = getRawQuery(); + String path = getRawPath(); String file = (query == null) ? path : path + "?" + query; - // URL represent undefined host as empty string while URI use null - String host = uri.getHost(); + String host = getHost(); if (host == null) { host = ""; } - - int port = uri.getPort(); - - return new URL("jrt", host, port, file, null); + int port = getPort(); + return URI.create("jrt://" + host + ":" + port + "/" + file).toURL(); } else { - return new URL((URL)null, uri.toString(), null); + return URI.create(toString()).toURL(); } } diff --git a/net-resource/src/main/java/org/xbib/net/resource/URI.java b/net-resource/src/main/java/org/xbib/net/resource/URI.java index ff4a0bc..bbff24b 100644 --- a/net-resource/src/main/java/org/xbib/net/resource/URI.java +++ b/net-resource/src/main/java/org/xbib/net/resource/URI.java @@ -1180,44 +1180,30 @@ public final class URI extends ResourceIdentifier * or if some other error occurred while constructing the URL */ public URL toURL() throws MalformedURLException { - return fromURI(this); - } - - /** - * Creates a URL from a URI, as if by invoking {@code uri.toURL()}. - * - * @see java.net.URI#toURL() - */ - static URL fromURI(URI uri) throws MalformedURLException { - if (!uri.isAbsolute()) { + if (!isAbsolute()) { throw new IllegalArgumentException("URI is not absolute"); } - String protocol = uri.getScheme(); - + String protocol = getScheme(); // In general we need to go via Handler.parseURL, but for the jrt // protocol we enforce that the Handler is not overrideable and can // optimize URI to URL conversion. // // Case-sensitive comparison for performance; malformed protocols will // be handled correctly by the slow path. - if (protocol.equals("jrt") && !uri.isOpaque() - && uri.getRawFragment() == null) { - - String query = uri.getRawQuery(); - String path = uri.getRawPath(); + if (protocol.equals("jrt") && !isOpaque() + && getRawFragment() == null) { + String query = getRawQuery(); + String path = getRawPath(); String file = (query == null) ? path : path + "?" + query; - // URL represent undefined host as empty string while URI use null - String host = uri.getHost(); + String host = getHost(); if (host == null) { host = ""; } - - int port = uri.getPort(); - - return new URL("jrt", host, port, file, null); + int port = getPort(); + return URI.create("jrt://" + host + ":" + port + "/" + file).toURL(); } else { - return new URL((URL)null, uri.toString(), null); + return URI.create(toString()).toURL(); } } diff --git a/net/src/main/java/org/xbib/net/URL.java b/net/src/main/java/org/xbib/net/URL.java index ea635eb..77b3932 100755 --- a/net/src/main/java/org/xbib/net/URL.java +++ b/net/src/main/java/org/xbib/net/URL.java @@ -438,14 +438,14 @@ public class URL implements Comparable { return externalStringRepresentation; } - public java.net.URL toURL() throws MalformedURLException { - return new java.net.URL(toString()); - } - public URI toURI() { return URI.create(toString()); } + public java.net.URL toURL() throws MalformedURLException { + return toURI().toURL(); + } + public Path toPath() { return Paths.get(toURI()); } diff --git a/net/src/main/java/org/xbib/net/util/JsonFileStore.java b/net/src/main/java/org/xbib/net/util/JsonFileStore.java index 1ade189..fce386f 100644 --- a/net/src/main/java/org/xbib/net/util/JsonFileStore.java +++ b/net/src/main/java/org/xbib/net/util/JsonFileStore.java @@ -34,12 +34,11 @@ public class JsonFileStore implements Store> { private final Path path; - public JsonFileStore(String name, Path path, long expireAfterSeconds) throws IOException { + public JsonFileStore(String name, Path path) throws IOException { this.name = name; this.path = path; this.lock = new ReentrantReadWriteLock(); Files.createDirectories(path); - purge(expireAfterSeconds); } @Override diff --git a/net/src/test/java/org/xbib/net/util/JsonFileStoreTest.java b/net/src/test/java/org/xbib/net/util/JsonFileStoreTest.java index 945d198..6d6e9c9 100644 --- a/net/src/test/java/org/xbib/net/util/JsonFileStoreTest.java +++ b/net/src/test/java/org/xbib/net/util/JsonFileStoreTest.java @@ -22,7 +22,7 @@ public class JsonFileStoreTest { @BeforeAll public static void before() throws IOException { Path path = Files.createTempDirectory("jsonstore"); - jsonFileStore = new JsonFileStore("test", path, 3600L); + jsonFileStore = new JsonFileStore("test", path); } @AfterAll diff --git a/settings.gradle b/settings.gradle index 43cbed0..59ce389 100644 --- a/settings.gradle +++ b/settings.gradle @@ -15,7 +15,7 @@ pluginManagement { dependencyResolutionManagement { versionCatalogs { libs { - version('gradle', '8.1.1') + version('gradle', '8.4-rc-1') version('junit', '5.10.0') library('junit-jupiter-api', 'org.junit.jupiter', 'junit-jupiter-api').versionRef('junit') library('junit-jupiter-params', 'org.junit.jupiter', 'junit-jupiter-params').versionRef('junit')