Skip to content

Commit

Permalink
Upgrade to Java 17 (#713)
Browse files Browse the repository at this point in the history
  • Loading branch information
dwalluck authored Nov 7, 2024
1 parent b305d5b commit a992a5b
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 70 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
strategy:
matrix:
os: [ ubuntu-latest, macOS-latest, windows-latest ]
java: [ 11, 17 ]
java: [ 17, 21 ]
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
Expand Down
10 changes: 0 additions & 10 deletions maven-version-rules.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,6 @@
<ignoreVersion type="regex">[^2]\..+</ignoreVersion>
</ignoreVersions>
</rule>
<rule groupId="net.revelc.code" artifactId="impsort-maven-plugin" comparisonMethod="maven">
<ignoreVersions>
<ignoreVersion type="regex">([^1]\..+|1\.[^9].*)</ignoreVersion>
</ignoreVersions>
</rule>
<rule groupId="net.revelc.code.formatter" comparisonMethod="maven">
<ignoreVersions>
<ignoreVersion type="regex">([^2]\..+|2\.[^2].*|2\.2[^3].*)</ignoreVersion>
</ignoreVersions>
</rule>
<rule groupId="org.infinispan" comparisonMethod="maven">
<ignoreVersions>
<ignoreVersion type="regex">([2-9]+|1[^4].*)</ignoreVersion>
Expand Down
10 changes: 5 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@
<properties>
<maven.build.timestamp.format>yyyy-MM-dd'T'HH:mm:ss'Z'</maven.build.timestamp.format>
<maven.compiler.parameters>true</maven.compiler.parameters>
<maven.compiler.release>11</maven.compiler.release>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.release>17</maven.compiler.release>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<mavenVersion>3.6.3</mavenVersion>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
Expand All @@ -72,8 +72,8 @@
<version.com.puppycrawl.tools>10.20.0</version.com.puppycrawl.tools>
<version.git-commit-id-plugin>4.9.10</version.git-commit-id-plugin>
<version.io.quarkus>2.16.12.Final</version.io.quarkus>
<version.net.revelc.code.formatter.formatter-maven-plugin>2.23.0</version.net.revelc.code.formatter.formatter-maven-plugin>
<version.net.revelc.code.impsort-maven-plugin>1.9.0</version.net.revelc.code.impsort-maven-plugin>
<version.net.revelc.code.formatter.formatter-maven-plugin>2.24.1</version.net.revelc.code.formatter.formatter-maven-plugin>
<version.net.revelc.code.impsort-maven-plugin>1.12.0</version.net.revelc.code.impsort-maven-plugin>
<version.net.sourceforge.pmd>7.7.0</version.net.sourceforge.pmd>
<version.org.apache.commons.collections4>4.4</version.org.apache.commons.collections4>
<version.org.apache.maven.plugins.maven-antrun-plugin>3.1.0</version.org.apache.maven.plugins.maven-antrun-plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.jboss.pnc.deliverablesanalyzer;

import java.io.Serial;
import java.time.Duration;
import java.util.concurrent.ConcurrentHashMap;

Expand All @@ -25,6 +26,7 @@

@Singleton
public class BuildConfigCache<K, V> extends PassiveExpiringMap<K, V> {
@Serial
private static final long serialVersionUID = -3473704377200486238L;

private static final long TIME_TO_LIVE_MILLIS = Duration.ofDays(1L).toMillis();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,16 @@ private static void ensureConfigurationDirectoryExists() throws IOException {
*/
@Produces
public BasicCacheContainer initCaches() throws IOException {
switch (infinispanMode) {
case EMBEDDED:
return switch (infinispanMode) {
case EMBEDDED -> {
LOGGER.info("Using Embedded Infinispan cache");
return setupEmbeddedCacheManager();
case REMOTE:
yield setupEmbeddedCacheManager();
}
case REMOTE -> {
LOGGER.info("Using Remote Infinispan cache");
return setupDistributedCacheManager();
default:
throw new RuntimeException("This infinispan mode has no cache manager");
}
yield setupDistributedCacheManager();
}
};
}

public void close(@Disposes BasicCacheContainer cacheManager) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.jboss.pnc.deliverablesanalyzer;

import java.io.Serial;
import java.time.Duration;
import java.util.concurrent.ConcurrentHashMap;

Expand All @@ -25,6 +26,7 @@

@Singleton
public class StatusCache<K, V> extends PassiveExpiringMap<K, V> {
@Serial
private static final long serialVersionUID = -5602712310506571554L;

private static final long TIME_TO_LIVE_MILLIS = Duration.ofDays(1L).toMillis();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.jboss.pnc.deliverablesanalyzer.model;

import java.io.Serial;
import java.io.Serializable;

import org.jboss.pnc.api.dto.Request;
Expand All @@ -24,6 +25,7 @@
*/
public class AnalyzeResponse implements Serializable {

@Serial
private static final long serialVersionUID = 1L;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ private static Set<Artifact> getNotFoundArtifacts(Map<BuildSystemInteger, KojiBu
}

List<KojiLocalArchive> localArchives = buildZero.getArchives();
if (localArchives == null || localArchives.size() == 0) {
if (localArchives == null || localArchives.isEmpty()) {
return Collections.unmodifiableSet(new LinkedHashSet<>());
}

Expand Down Expand Up @@ -237,17 +237,10 @@ private static Artifact createArtifact(KojiLocalArchive localArchive, BuildSyste
ArtifactBuilder<?, ?> builder;

switch (buildType) {
case GRADLE:
case MAVEN:
case SBT:
builder = createMavenArtifact(archiveInfo);
break;
case NPM:
builder = createNpmArtifact(archiveInfo);
break;
default:
throw new BadRequestException(
"Archive " + archiveInfo.getArtifactId() + " had unhandled artifact type: " + buildType);
case GRADLE, MAVEN, SBT -> builder = createMavenArtifact(archiveInfo);
case NPM -> builder = createNpmArtifact(archiveInfo);
default -> throw new BadRequestException(
"Archive " + archiveInfo.getArtifactId() + " had unhandled artifact type: " + buildType);
}

switch (buildSystem) {
Expand Down Expand Up @@ -335,15 +328,9 @@ private static Set<Build> getFoundBuilds(Map<BuildSystemInteger, KojiBuild> buil
private static String getIdentifier(BuildSystemType buildSystemType, Long brewId, String pncId) {
String identifier;
switch (buildSystemType) {
case BREW:
identifier = "Brew#" + Objects.requireNonNullElse(brewId, "-1");
break;
case PNC:
identifier = "PNC#" + pncId;
break;
default:
identifier = "Unknown#-1";
break;
case BREW -> identifier = "Brew#" + Objects.requireNonNullElse(brewId, "-1");
case PNC -> identifier = "PNC#" + pncId;
default -> identifier = "Unknown#-1";
}
return identifier;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Positive;
Expand Down Expand Up @@ -52,26 +51,21 @@ public ErrorMessage(Exception exception) {
this.exception = exception;
Response.Status status = Response.Status.INTERNAL_SERVER_ERROR;

if (exception instanceof WebApplicationException) {
WebApplicationException e = (WebApplicationException) exception;

if (exception instanceof WebApplicationException e) {
try (Response response = e.getResponse()) {
status = response.getStatusInfo().toEnum();
}
}

if (exception.getCause() != null) {
causeStackTrace.addAll(
Arrays.stream(exception.getCause().getStackTrace())
.map(StackTraceElement::toString)
.collect(Collectors.toList()));
Arrays.stream(exception.getCause().getStackTrace()).map(StackTraceElement::toString).toList());
}

message = exception.getMessage();
reason = status.getReasonPhrase();
code = status.getStatusCode();
stackTrace.addAll(
Arrays.stream(exception.getStackTrace()).map(StackTraceElement::toString).collect(Collectors.toList()));
stackTrace.addAll(Arrays.stream(exception.getStackTrace()).map(StackTraceElement::toString).toList());
}

@JsonIgnore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,21 +133,6 @@ public void testAdvancedPerformHttpRequest() throws Exception {
.withRequestBody(equalToJson("{\"a\" : 1, \"b\" : \"str\"}")));
}

static class TestPayload {
private final Integer a;
private final String b;

TestPayload(Integer a, String b) {
this.a = a;
this.b = b;
}

public Integer getA() {
return a;
}

public String getB() {
return b;
}
record TestPayload(Integer a, String b) {
}
}

0 comments on commit a992a5b

Please sign in to comment.