apilloud commented on a change in pull request #13448:
URL: https://github.com/apache/beam/pull/13448#discussion_r533606642
##########
File path:
runners/java-fn-execution/src/test/java/org/apache/beam/runners/fnexecution/control/DefaultJobBundleFactoryTest.java
##########
@@ -459,27 +461,28 @@ public void loadBalancesBundles() throws Exception {
verify(envFactory, Mockito.times(2)).createEnvironment(eq(environment),
any());
long tms = System.currentTimeMillis();
- AtomicBoolean closed = new AtomicBoolean();
- // close to free up environment for another bundle
- TimerTask closeBundleTask =
- new TimerTask() {
- @Override
- public void run() {
- try {
- b2.close();
- closed.set(true);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
- };
- new Timer().schedule(closeBundleTask, 100);
-
+ ScheduledExecutorService executor =
Executors.newSingleThreadScheduledExecutor();
+ ScheduledFuture<Optional<Exception>> closingFuture =
+ executor.schedule(
+ () -> {
+ try {
+ b2.close();
+ return Optional.empty();
+ } catch (Exception e) {
Review comment:
Yes only unchecked exceptions. It is odd to me that the Java
`AutoCloseable` interface defines it as throwing `Exception`, but it does.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]