You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here's a version that does not spot any of this problems:
packageorg.neo4j.examples.jvm.helidon.se.reactive.support;
importjavax.enterprise.context.ApplicationScoped;
importjavax.inject.Inject;
importorg.eclipse.microprofile.health.HealthCheck;
importorg.eclipse.microprofile.health.HealthCheckResponse;
importorg.eclipse.microprofile.health.HealthCheckResponseBuilder;
importorg.eclipse.microprofile.health.Readiness;
importorg.neo4j.driver.Driver;
importorg.neo4j.driver.Session;
@Readiness@ApplicationScopedpublicclassNeo4jHealthCheckimplementsHealthCheck {
/** * The Cypher statement used to verify Neo4j is up. */staticfinalStringCYPHER = "CALL dbms.components() YIELD name, edition WHERE name = 'Neo4j Kernel' RETURN edition";
privatefinalDriverdriver;
@InjectNeo4jHealthCheck(Driverdriver) {
this.driver = driver;
}
publicstaticNeo4jHealthCheckcreate(Driverdriver) {
returnnewNeo4jHealthCheck(driver);
}
privateHealthCheckResponserunHealthCheckQuery(HealthCheckResponseBuilderbuilder) {
// We use WRITE here to make sure UP is returned for a server that supports// all possible workloads.// We also use a transactional function so that we retry this in case the cluster// is down.try (Sessionsession = this.driver.session()) {
returnsession.writeTransaction(tx -> {
varresult = tx.run(CYPHER);
varedition = result.single().get("edition").asString();
varresultSummary = result.consume();
varserverInfo = resultSummary.server();
varresponseBuilder = builder
.withData("server", serverInfo.version() + "@" + serverInfo.address())
.withData("edition", edition);
vardatabaseInfo = resultSummary.database();
if (!databaseInfo.name().trim().isBlank()) {
responseBuilder.withData("database", databaseInfo.name().trim());
}
returnresponseBuilder.up().build();
});
}
}
@OverridepublicHealthCheckResponsecall() {
varbuilder = HealthCheckResponse.named("Neo4j connection health check");
try {
returnrunHealthCheckQuery(builder);
} catch (Exceptionex) {
returnbuilder.down().withData("reason", ex.getMessage()).build();
}
}
}
I have signed the CLA, you can take this basically as is.
The text was updated successfully, but these errors were encountered:
Environment Details
openjdk 11.0.11 2021-04-20
OpenJDK Runtime Environment GraalVM CE 21.1.0 (build 11.0.11+8-jvmci-21.1-b05)
OpenJDK 64-Bit Server VM GraalVM CE 21.1.0 (build 11.0.11+8-jvmci-21.1-b05, mixed mode, sharing)
Problem Description
When trying to use the provided Neo4jHealthCheck in an SE application, the application cannot be build natively.
Steps to reproduce
Put the integration on the class path, do somewhere in your SE application
Reason: The static config here:
https://github.com/oracle/helidon/blob/master/integrations/neo4j/health/src/main/java/io/helidon/integrations/neo4j/health/Neo4jHealthCheck.java#L48-L50
Also, that session will be dangling around:
https://github.com/oracle/helidon/blob/master/integrations/neo4j/health/src/main/java/io/helidon/integrations/neo4j/health/Neo4jHealthCheck.java#L113
Here's a version that does not spot any of this problems:
I have signed the CLA, you can take this basically as is.
The text was updated successfully, but these errors were encountered: