Skip to content

Commit

Permalink
Remove automatic detection of MP Health 2.0 readiness path and add pu…
Browse files Browse the repository at this point in the history
…blic constant instead
  • Loading branch information
aguibert committed Nov 11, 2019
1 parent 0fe865c commit 2692f61
Showing 1 changed file with 10 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,13 @@
*/
public class MicroProfileApplication extends GenericContainer<MicroProfileApplication> {

private static final String MP_HEALTH_READINESS_PATH = "/health/ready";
/**
* A path representing the MicroProfile Health 2.0 readiness check
*/
public static final String MP_HEALTH_READINESS_PATH = "/health/ready";

private static final Logger LOGGER = LoggerFactory.getLogger(MicroProfileApplication.class);
private static final boolean mpHealth20Available;
private static final boolean isHollow = isHollow();
static {
Class<?> readinessClass = null;
try {
readinessClass = Class.forName("org.eclipse.microprofile.health.Readiness");
} catch (ClassNotFoundException e) {
}
mpHealth20Available = readinessClass != null;
}

private String appContextRoot;
private ServerAdapter serverAdapter;
Expand Down Expand Up @@ -232,13 +227,12 @@ protected void configure() {
super.configure();
// If the readiness path was not set explicitly, default it to:
// A) The value defined by ServerAdapter.getReadinessPath(), if any
// B) The standard MP Health 2.0 readiness endpoint (if available)
// C) the app context root
// B) the app context root
if (!readinessPathSet) {
if (serverAdapter != null && serverAdapter.getReadinessPath().isPresent() && !serverAdapter.getReadinessPath().get().trim().isEmpty()) {
if (serverAdapter != null && serverAdapter.getReadinessPath().isPresent()) {
withReadinessPath(serverAdapter.getReadinessPath().get());
} else {
withReadinessPath(mpHealth20Available ? MP_HEALTH_READINESS_PATH : appContextRoot);
withReadinessPath(appContextRoot);
}
}
}
Expand Down Expand Up @@ -322,11 +316,7 @@ public MicroProfileApplication withAppContextRoot(String appContextRoot) {
/**
* Sets the path to be used to determine container readiness. The readiness check will
* timeout after a sensible amount of time has elapsed.
* If unspecified, the readiness path with defailt to either:
* <ol><li>The MicroProfile Health 2.0 readiness endpoint <code>/health/readiness</code>,
* if MP Health 2.0 API is accessible</li>
* <li>Otherwise, the application context root</li>
* </ol>
* If unspecified, the readiness path with defailt to the application context root
*
* @param readinessUrl The HTTP endpoint to be polled for readiness. Once the endpoint
* returns HTTP 200 (OK), the container is considered to be ready.
Expand All @@ -340,11 +330,7 @@ public MicroProfileApplication withReadinessPath(String readinessUrl) {
/**
* Sets the path to be used to determine container readiness. The readiness check will
* timeout after a sensible amount of time has elapsed.
* If unspecified, the readiness path with defailt to either:
* <ol><li>The MicroProfile Health 2.0 readiness endpoint <code>/health/readiness</code>,
* if MP Health 2.0 API is accessible</li>
* <li>Otherwise, the application context root</li>
* </ol>
* If unspecified, the readiness path with defailt to the application context root
*
* @param readinessUrl The HTTP endpoint to be polled for readiness. Once the endpoint
* returns HTTP 200 (OK), the container is considered to be ready.
Expand Down

0 comments on commit 2692f61

Please sign in to comment.