|
53 | 53 | import org.junit.jupiter.api.extension.ExtensionConfigurationException;
|
54 | 54 | import org.junit.jupiter.api.extension.ExtensionContext;
|
55 | 55 | import org.junit.jupiter.api.extension.ExtensionContext.Namespace;
|
| 56 | +import org.junit.jupiter.api.extension.ExtensionContext.Store; |
56 | 57 | import org.junit.jupiter.api.extension.ParameterContext;
|
57 | 58 | import org.junit.jupiter.api.extension.ParameterResolver;
|
58 | 59 | import org.junit.jupiter.api.io.CleanupMode;
|
@@ -134,12 +135,7 @@ private static void installFailureTracker(ExtensionContext context) {
|
134 | 135 | }
|
135 | 136 |
|
136 | 137 | private static void installFailureTracker(ExtensionContext context, ExtensionContext parentContext) {
|
137 |
| - context.getStore(NAMESPACE).put(FAILURE_TRACKER, (AutoCloseable) () -> context.getParent() // |
138 |
| - .ifPresent(parentContext -> { |
139 |
| - if (selfOrChildFailed(context)) { |
140 |
| - parentContext.getStore(NAMESPACE).put(CHILD_FAILED, true); |
141 |
| - } |
142 |
| - })); |
| 138 | + context.getStore(NAMESPACE).put(FAILURE_TRACKER, new FailureTracker(context, parentContext)); |
143 | 139 | }
|
144 | 140 |
|
145 | 141 | private void injectStaticFields(ExtensionContext context, Class<?> testClass) {
|
@@ -298,7 +294,8 @@ private static ExtensionContext.Store getContextSpecificStore(ExtensionContext c
|
298 | 294 | return context.getStore(NAMESPACE.append(context));
|
299 | 295 | }
|
300 | 296 |
|
301 |
| - static class CloseablePath implements AutoCloseable { |
| 297 | + @SuppressWarnings("deprecation") |
| 298 | + static class CloseablePath implements Store.CloseableResource, AutoCloseable { |
302 | 299 |
|
303 | 300 | private static final Logger LOGGER = LoggerFactory.getLogger(CloseablePath.class);
|
304 | 301 |
|
@@ -613,4 +610,23 @@ public String toString() {
|
613 | 610 |
|
614 | 611 | }
|
615 | 612 |
|
| 613 | + @SuppressWarnings("deprecation") |
| 614 | + private static class FailureTracker implements Store.CloseableResource, AutoCloseable { |
| 615 | + |
| 616 | + private final ExtensionContext context; |
| 617 | + private final ExtensionContext parentContext; |
| 618 | + |
| 619 | + private FailureTracker(ExtensionContext context, ExtensionContext parentContext) { |
| 620 | + this.context = context; |
| 621 | + this.parentContext = parentContext; |
| 622 | + } |
| 623 | + |
| 624 | + @Override |
| 625 | + public void close() { |
| 626 | + if (selfOrChildFailed(context)) { |
| 627 | + getContextSpecificStore(parentContext).put(CHILD_FAILED, true); |
| 628 | + } |
| 629 | + } |
| 630 | + } |
| 631 | + |
616 | 632 | }
|
0 commit comments