Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Java 21 #995

Merged
merged 46 commits into from
Jul 23, 2024
Merged

Upgrade to Java 21 #995

merged 46 commits into from
Jul 23, 2024

Conversation

usmansaleem
Copy link
Contributor

@usmansaleem usmansaleem commented Jun 3, 2024

PR Description

Upgrade build and runtime to Java 21. Following changes are also made to achieve this:

  • Upgraded to Gradle 8.9
  • Various plugin versions updated
  • Various dependencies versions updated
    • Besu and Teku
  • Owasp suppressions updated
  • Removed gatling performance test because it is not compatible with latest Gradle.

Logs after upgrading to Java 21:

Web3SignerApp | Version = web3signer/v24.2.0+20-gb2fe8d6/linux-aarch_64/-eclipseadoptium-openjdk64bitservervm-java-21

Fixed Issue(s)

fixes #1013

Documentation

  • I thought about documentation and added the doc-change-required label to this PR if updates are required.

Changelog

  • I thought about adding a changelog entry, and added one if I deemed necessary.

Testing

  • I thought about testing these changes in a realistic/non-local environment.

Copy link
Contributor

@jframe jframe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need give some notice about the breaking change of requiring Java 21 before merging this in. So for this upcoming release we can place a notice in our changelog and the announcement about the upcoming change and next monthly release change to using Java 21.

@usmansaleem usmansaleem marked this pull request as draft June 4, 2024 05:43
@usmansaleem usmansaleem changed the title Upgrade to Java 21 *DO NOT MERGE* - Upgrade to Java 21 Jun 6, 2024
@usmansaleem usmansaleem changed the title *DO NOT MERGE* - Upgrade to Java 21 Upgrade to Java 21 Jul 17, 2024
@usmansaleem usmansaleem marked this pull request as ready for review July 17, 2024 05:58
@usmansaleem usmansaleem added the doc-change-required Indicates an issue or PR that requires doc to be updated label Jul 17, 2024
@usmansaleem usmansaleem self-assigned this Jul 17, 2024
@usmansaleem usmansaleem requested a review from jframe July 18, 2024 03:10
.circleci/config.yml Outdated Show resolved Hide resolved
acceptance-tests/build.gradle Outdated Show resolved Hide resolved
}

task downloadBesu(type: Download) {
src {
// see gradle.properties for Besu URL
return new SimpleTemplateEngine().createTemplate(besuDistroUrl).make(["besuVersion":"$besuVersion"]).toString()
}
dest new File(buildDir, "besu-${besuVersion}.tar.gz")
dest layout.buildDirectory.file("downloads/besu-${besuVersion}.tar.gz")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the downloads directory get created if doesn't exist? And will work on Windows with the hardcoded / directory separator?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works on nix without any problems. Need to check our whole build on Windows environment.

build.gradle Show resolved Hide resolved
requestUri = failureContext.request().absoluteURI();
} catch (final NullPointerException e) {
// absoluteURI can throw an NPE if host or port is missing
requestUri = "Error in calculating request URI";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More descriptive error would be nicer here along line of invalid URI due to missing host or port.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure. This NPE happens when invalid host header is involved from the client. Latest vertx has started throwing an NPE. I'll update the error description.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refactored it a bit.

final Response response =
given().baseUri(getMetricsUrl()).contentType(ContentType.JSON).when().get(METRICS_ENDPOINT);

final List<String> lines =
Arrays.asList(response.getBody().asString().split(String.format("%n")).clone());
return convertToLines(response.getBody().asString()).stream()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be simplified to:
response.getBody().asString().lines()

Removing the need for convertToLines

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice suggestion, updated.

CHANGELOG.md Show resolved Hide resolved
@@ -204,16 +204,29 @@ public static String signPath(final KeyType keyType) {
return keyType == BLS ? ETH2_SIGN_ENDPOINT : ETH1_SIGN_ENDPOINT;
}

public Set<String> getMetricsMatching(final List<String> metricsOfInterest) {
public Map<String, String> getMatchedMetrics(final Set<String> metricsOfInterest) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: IMHO the previous name was clearer

build.gradle Outdated
}
removeUnusedImports()
// removeUnusedImports() // conflicts with googleJavaFormat for 7.0.0.BETA1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove commented line

// Let the next matching route or error handler deal with the error, we only handle logging
failureContext.next();
} else {
LOG.warn("Error handler triggered without any propagated failure");
}
}

private static String getRequestUri(RoutingContext failureContext) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the method name isn't quite right as the error case it doesn't return a requestUri. Would be better to return an empty and just include that error message in the handle method.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed. Updated the method to return Optional.

@usmansaleem usmansaleem requested a review from jframe July 22, 2024 06:01
LOG.error(
String.format("Failed request: %s", failureContext.request().absoluteURI()),
failureContext.failure());
final String requestUri =
Copy link
Contributor

@jframe jframe Jul 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not going to block on this, but the variable name is a bit misleading as sometimes it is an error message and sometimes it's the requestUri.

@usmansaleem usmansaleem merged commit 3dafc7b into Consensys:master Jul 23, 2024
6 checks passed
@usmansaleem usmansaleem deleted the java_21 branch July 23, 2024 06:00
@joaniefromtheblock joaniefromtheblock removed the doc-change-required Indicates an issue or PR that requires doc to be updated label Aug 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrate Web3Signer build requirements to Java 21
3 participants