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

Java Libs Project requires Java 1.8, but uses packages introduced in Java 11 #1149

Open
alecdesjardins opened this issue Dec 20, 2023 · 1 comment
Labels
lib/java Java client library

Comments

@alecdesjardins
Copy link

alecdesjardins commented Dec 20, 2023

Bug Report

Description

java.net.http was introduced to Java with 11, not 1.8. Therefore, the java libs project will not compile.

I tried this code:

./gradlew build

I expected to see this happen: build successfully

Instead, this happened: Webhook.java:3 error: package java.net.http does not exist import java.net.http.HttpHeaders;

@jameshiew
Copy link
Contributor

I'm able to import and use the library in a Java 8 project to interact with the Svix webhook service API in general, but can't use this Webhook class. This looks to be the only application code which is using Java 11+ features (e.g. java.net.http.HttpHeaders class).

public void verify(final String payload, final HttpHeaders headers) throws WebhookVerificationException {
Optional<String> msgId = headers.firstValue(SVIX_MSG_ID_KEY);
Optional<String> msgSignature = headers.firstValue(SVIX_MSG_SIGNATURE_KEY);
Optional<String> msgTimestamp = headers.firstValue(SVIX_MSG_TIMESTAMP_KEY);
if (msgId.isEmpty() || msgSignature.isEmpty() || msgTimestamp.isEmpty()) {
// fallback to unbranded
msgId = headers.firstValue(UNBRANDED_MSG_ID_KEY);
msgSignature = headers.firstValue(UNBRANDED_MSG_SIGNATURE_KEY);
msgTimestamp = headers.firstValue(UNBRANDED_MSG_TIMESTAMP_KEY);
if (msgId.isEmpty() || msgSignature.isEmpty() || msgTimestamp.isEmpty()) {
throw new WebhookVerificationException("Missing required headers");
}
}

Could potentially either bump the minimum supported Java version to 11, or update this class and tests to be Java 8 compatible - though unsure of what would be the best way to do that without affecting existing downstream users of the verify() method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lib/java Java client library
Projects
None yet
Development

No branches or pull requests

4 participants