Skip to content

Commit

Permalink
do not suppress exceptions from invalidateCache()
Browse files Browse the repository at this point in the history
  • Loading branch information
m-trieu committed Sep 26, 2024
1 parent d6db7c8 commit ec286e8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ public final void executeWork(
* cannot be reused.
*/
public final void invalidate() {
context().invalidateCache();
try {
context().invalidateCache();
workExecutor().close();
} catch (Exception e) {
LOG.warn("Failed to invalidate ComputationWorkExecutor: ", e);
LOG.warn("Failed to close map task executor: ", e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verifyNoInteractions;

import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.beam.runners.core.metrics.ExecutionStateTracker;
Expand Down Expand Up @@ -50,11 +49,13 @@ public void setUp() {
}

@Test
public void testInvalidate_handlesException() {
NullPointerException npe = new NullPointerException("something bad happened");
doThrow(npe).when(context).invalidateCache();
public void testInvalidate_withoutCallToStart() {
// Call to invalidate w/o a call to start should not fail.
computationWorkExecutor.invalidate();
verifyNoInteractions(dataflowWorkExecutor);
}

@Test
public void testInvalidate_handlesException() {
AtomicBoolean verifyContextInvalidated = new AtomicBoolean(false);
Throwable e = new RuntimeException("something bad happened 2");
doThrow(e).when(dataflowWorkExecutor).close();
Expand Down

0 comments on commit ec286e8

Please sign in to comment.