diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index fcd12445..aa21d361 100755 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -3,10 +3,10 @@ id: 47e8e950-a454-4ebb-9f78-86fda7dfa0c2 management: docChecksum: a34bd1c885aa42eb3175940494581f67 docVersion: 0.2.0 - speakeasyVersion: 1.352.2 - generationVersion: 2.385.2 - releaseVersion: 1.5.2 - configChecksum: 8fa1830a31c492ff0715e1868931d248 + speakeasyVersion: 1.354.0 + generationVersion: 2.386.2 + releaseVersion: 1.5.3 + configChecksum: 64798e8dfb7f95ceef7c914140804cea repoURL: https://github.com/StyraInc/opa-java.git published: true features: diff --git a/.speakeasy/gen.yaml b/.speakeasy/gen.yaml index fd3fc707..6e377c3b 100755 --- a/.speakeasy/gen.yaml +++ b/.speakeasy/gen.yaml @@ -12,7 +12,7 @@ generation: auth: oAuth2ClientCredentialsEnabled: false java: - version: 1.5.2 + version: 1.5.3 additionalDependencies: - testImplementation:org.junit.jupiter:junit-jupiter-api:5.8.2 - runtimeOnly:org.junit.jupiter:junit-jupiter-engine:5.8.2 diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index 70b69f91..a34fe2d7 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -1,17 +1,17 @@ -speakeasyVersion: 1.352.2 +speakeasyVersion: 1.354.0 sources: openapi: sourceNamespace: openapi - sourceRevisionDigest: sha256:0386accf30f12bb3bb50144694f3ab35ee68b21a3ed88c12e18a2b88dd15a3e0 - sourceBlobDigest: sha256:bf9fe4dd822245aa01ce8a97b40ca6b70149d77015e0e26540a3ce94e5fc2700 + sourceRevisionDigest: sha256:cdedb966379a4fcac12704efa03907a7529e5fe7d9497ce97571efe8bb06194d + sourceBlobDigest: sha256:0a582b34b60d45468d7211a21ded7a26384d8a6a8d07c7277bd34e3b37b3674a tags: - latest targets: opa: source: openapi sourceNamespace: openapi - sourceRevisionDigest: sha256:0386accf30f12bb3bb50144694f3ab35ee68b21a3ed88c12e18a2b88dd15a3e0 - sourceBlobDigest: sha256:bf9fe4dd822245aa01ce8a97b40ca6b70149d77015e0e26540a3ce94e5fc2700 + sourceRevisionDigest: sha256:cdedb966379a4fcac12704efa03907a7529e5fe7d9497ce97571efe8bb06194d + sourceBlobDigest: sha256:0a582b34b60d45468d7211a21ded7a26384d8a6a8d07c7277bd34e3b37b3674a outLocation: /Users/cad/f/src/opa-java workflow: workflowVersion: 1.0.0 diff --git a/CHANGELOG.md b/CHANGELOG.md index ceba08b1..3110162c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # OPA Java SDK Changelog +## v1.5.3 + +* Marked jackson-databind as an `api` dependency in addition to jackson-core. +* Fixed a bug where `OPALatencyMeasuringHTTPClient` would report results in ns rather than ms. + ## v1.5.2 * Fixed a bug where instantiating `OPALatencyMeasuringHTTPClient` with the default constructor could result in a null pointer exception while formatting messages. diff --git a/RELEASES.md b/RELEASES.md index adf7897d..5d822149 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -318,3 +318,13 @@ Based on: - [java v1.5.2] . ### Releases - [Maven Central v1.5.2] https://central.sonatype.com/artifact/com.styra.opa/openapi/1.5.2 - . + +## 2024-08-06 16:35:00 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.354.0 (2.361.10) https://github.com/speakeasy-api/speakeasy +### Generated +- [java v1.5.3] . +### Releases +- [Maven Central v1.5.3] https://central.sonatype.com/artifact/com.styra.opa/openapi/1.5.3 - . diff --git a/build.gradle b/build.gradle index ab398976..73737ef3 100644 --- a/build.gradle +++ b/build.gradle @@ -78,7 +78,7 @@ publishing { maven(MavenPublication) { groupId = 'com.styra' artifactId = 'opa' - version = '1.5.2' + version = '1.5.3' from components.java diff --git a/src/main/java/com/styra/opa/openapi/SDKConfiguration.java b/src/main/java/com/styra/opa/openapi/SDKConfiguration.java index d720ccc3..67a0fe96 100644 --- a/src/main/java/com/styra/opa/openapi/SDKConfiguration.java +++ b/src/main/java/com/styra/opa/openapi/SDKConfiguration.java @@ -21,9 +21,9 @@ public Optional securitySource() { public int serverIdx = 0; public String language = "java"; public String openapiDocVersion = "0.2.0"; - public String sdkVersion = "1.5.2"; - public String genVersion = "2.385.2"; - public String userAgent = "speakeasy-sdk/java 1.5.2 2.385.2 0.2.0 com.styra.opa.openapi"; + public String sdkVersion = "1.5.3"; + public String genVersion = "2.386.2"; + public String userAgent = "speakeasy-sdk/java 1.5.3 2.386.2 0.2.0 com.styra.opa.openapi"; private com.styra.opa.openapi.utils.Hooks _hooks = createHooks(); diff --git a/src/main/java/com/styra/opa/utils/OPALatencyMeasuringHTTPClient.java b/src/main/java/com/styra/opa/utils/OPALatencyMeasuringHTTPClient.java index 743c16e3..c4b90523 100644 --- a/src/main/java/com/styra/opa/utils/OPALatencyMeasuringHTTPClient.java +++ b/src/main/java/com/styra/opa/utils/OPALatencyMeasuringHTTPClient.java @@ -19,6 +19,10 @@ */ public class OPALatencyMeasuringHTTPClient extends OPAHTTPClient { + // Checkstyle wants this to not be a hard-coded magic number. You never + // know, maybe the length of a second will change one day? + private static final double MS_PER_NS = 0.000001; + private static Logger logger = Logger.getLogger(OPALatencyMeasuringHTTPClient.class.getName()); private String latencyMeasurementFormatString = "path=''{1}'' latency={0,number,#}ms"; @@ -80,9 +84,10 @@ public HttpResponse send(HttpRequest request) HttpResponse response = super.send(request); long endTime = System.nanoTime(); - long sendLatency = endTime - startTime; + // convert ns -> ms + double sendLatency = (((double) endTime) - ((double) startTime)) * MS_PER_NS; - Object[] logArgs = {sendLatency, path}; + Object[] logArgs = {(long) sendLatency, path}; logger.log(latencyMeasurementLogLevel, fmt.format(logArgs)); diff --git a/src/test/java/com/styra/opa/OPATest.java b/src/test/java/com/styra/opa/OPATest.java index 26308a8b..031be18d 100644 --- a/src/test/java/com/styra/opa/OPATest.java +++ b/src/test/java/com/styra/opa/OPATest.java @@ -43,6 +43,8 @@ class OPATest { private int testIntegerA = 8; private int testIntegerB = 16; private double testDoubleA = 3.14159; + private long msInZeroSeconds; // implicit initialization to 0 + private long msInOneSeconds = 1000; private String address; private String altAddress; @@ -299,6 +301,12 @@ public void testLatencyMeasurement() { for (String msg : logs) { System.out.printf("DEBUG: log line: %s\n", msg); assertTrue(msg.matches("^INFO LATENCY MEASUREMENT #[0-9]+#/v1/data/policy/echo#$")); + + // Sanity check that the measurement value is > 0 and < 1s. Even in + // CI, it shouldn't take over 1s to do a simple localhost request. + String latency = msg.replaceFirst("\\D*(\\d*).*", "$1"); + assertTrue(Integer.parseInt(latency) > msInZeroSeconds); + assertTrue(Integer.parseInt(latency) < msInOneSeconds); } }