You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cs...@apache.org on 2020/10/08 11:56:09 UTC
[felix-dev] branch master updated: FELIX-6344 - Also catch
Throwable to make sure the future is always removed
This is an automated email from the ASF dual-hosted git repository.
cschneider pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/felix-dev.git
The following commit(s) were added to refs/heads/master by this push:
new 03288b9 FELIX-6344 - Also catch Throwable to make sure the future is always removed
03288b9 is described below
commit 03288b9a7e666327845216840ece7e3ef9d6f5b3
Author: Christian Schneider <cs...@adobe.com>
AuthorDate: Thu Oct 8 13:55:28 2020 +0200
FELIX-6344 - Also catch Throwable to make sure the future is always removed
---
.../felix/hc/core/impl/executor/HealthCheckFuture.java | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/healthcheck/core/src/main/java/org/apache/felix/hc/core/impl/executor/HealthCheckFuture.java b/healthcheck/core/src/main/java/org/apache/felix/hc/core/impl/executor/HealthCheckFuture.java
index c5083b2..6ae5574 100644
--- a/healthcheck/core/src/main/java/org/apache/felix/hc/core/impl/executor/HealthCheckFuture.java
+++ b/healthcheck/core/src/main/java/org/apache/felix/hc/core/impl/executor/HealthCheckFuture.java
@@ -46,7 +46,12 @@ public class HealthCheckFuture extends FutureTask<ExecutionResult> {
private final static Logger LOG = LoggerFactory.getLogger(HealthCheckFuture.class);
- private final HealthCheckMetadata metadata;
+ private static Result createResult(final HealthCheckMetadata metadata, Exception e) {
+ return new Result(Result.Status.HEALTH_CHECK_ERROR,
+ "Exception during execution of '" + metadata.getName() + "'", e);
+ }
+
+ private final HealthCheckMetadata metadata;
private final Date createdTime;
public HealthCheckFuture(final HealthCheckMetadata metadata, final BundleContext bundleContext, final Callback callback) {
@@ -71,10 +76,11 @@ public class HealthCheckFuture extends FutureTask<ExecutionResult> {
} else {
throw new IllegalStateException("Service cannot be retrieved - probably activate() failed or there are unsatisfied references");
}
-
} catch (final Exception e) {
- resultFromHealthCheck = new Result(Result.Status.HEALTH_CHECK_ERROR,
- "Exception during execution of '" + metadata.getName() + "'", e);
+ resultFromHealthCheck = createResult(metadata, e);
+ } catch (final Throwable t) {
+ Exception e = new RuntimeException("System error during health check execution", t);
+ resultFromHealthCheck = createResult(metadata, e);
} finally {
// unget service ref
bundleContext.ungetService(metadata.getServiceReference());