From 6cec0187c30a501e83a235cab21e1e773b4cd4de Mon Sep 17 00:00:00 2001 From: Moritz Halbritter Date: Mon, 16 Jan 2023 14:08:28 +0100 Subject: [PATCH] Include exception message in condition result when docker is unavailable Closes gh-20582 --- .../DisabledIfDockerUnavailableCondition.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/testcontainers/DisabledIfDockerUnavailableCondition.java b/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/testcontainers/DisabledIfDockerUnavailableCondition.java index 4b6b332538..de1e52d7de 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/testcontainers/DisabledIfDockerUnavailableCondition.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/testcontainers/DisabledIfDockerUnavailableCondition.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,6 +26,7 @@ import org.testcontainers.DockerClientFactory; * * @author Andy Wilkinson * @author Phillip Webb + * @author Moritz Halbritter */ class DisabledIfDockerUnavailableCondition implements ExecutionCondition { @@ -33,8 +34,6 @@ class DisabledIfDockerUnavailableCondition implements ExecutionCondition { private static final ConditionEvaluationResult ENABLED = ConditionEvaluationResult.enabled("Docker available"); - private static final ConditionEvaluationResult DISABLED = ConditionEvaluationResult.disabled("Docker unavailable"); - @Override public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) { String originalSilenceValue = System.getProperty(SILENCE_PROPERTY); @@ -43,7 +42,7 @@ class DisabledIfDockerUnavailableCondition implements ExecutionCondition { return ENABLED; } catch (Throwable ex) { - return DISABLED; + return ConditionEvaluationResult.disabled("Docker unavailable", ex.getMessage()); } finally { if (originalSilenceValue != null) {