@Override
    public void handleGlobalFailure(Throwable cause) {
        final FailureEnricher.Context ctx =
                DefaultFailureEnricherContext.forGlobalFailure(
                        jobInfo, jobManagerJobMetricGroup, ioExecutor, userCodeClassLoader);
        final CompletableFuture<Map<String, String>> failureLabels =
                FailureEnricherUtils.labelFailure(
                        cause, ctx, getMainThreadExecutor(), failureEnrichers);
        state.handleGlobalFailure(cause, failureLabels);
    }
@Test
    void testExceptionHistoryWithTaskConcurrentGlobalFailure() throws Exception {
        final Exception expectedException1 = new Exception("Expected Global Exception 1");
        final Exception expectedException2 = new Exception("Expected Global Exception 2");
        final BiConsumer<AdaptiveScheduler, List<ExecutionAttemptID>> testLogic =
                (scheduler, attemptIds) -> {
                    scheduler.handleGlobalFailure(expectedException1);
                    scheduler.handleGlobalFailure(expectedException2);
                };

        final Iterable<RootExceptionHistoryEntry> entries =
                new ExceptionHistoryTester(singleThreadMainThreadExecutor)
                        .withTestLogic(testLogic)
                        .run();
        assertThat(entries).hasSize(1);
        final RootExceptionHistoryEntry failure = entries.iterator().next();
        assertThat(failure.getException().deserializeError(classLoader))
                .isEqualTo(expectedException1);
        final Iterable<ExceptionHistoryEntry> concurrentExceptions =
                failure.getConcurrentExceptions();
        final List<Throwable> foundExceptions =
                IterableUtils.toStream(concurrentExceptions)
                        .map(ExceptionHistoryEntry::getException)
                        .map(exception -> exception.deserializeError(classLoader))
                        .collect(Collectors.toList());

        assertThat(foundExceptions).containsExactly(expectedException2);
    }