question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Exceptions and Errors ignored due to unchecked Futures

See original GitHub issue

Describe the bug @keith-turner reported an issue where he had the wrong accumulo-core jar file deployed to a cluster and the TabletServer continued to run. When he changed the code to catch Throwable instead of catch Exception, this stacktrace was captured:

java.lang.NoSuchFieldError: TSERV_WAL_BUFFER
        at org.apache.accumulo.tserver.log.DfsLogger.open(DfsLogger.java:425) ~[accumulo-tserver-2.1.0-SNAPSHOT.jar:2.1.0-SNAPSHOT]
        at org.apache.accumulo.tserver.log.TabletServerLogger$2.run(TabletServerLogger.java:277) ~[accumulo-tserver-2.1.0-SNAPSHOT.jar:2.1.0-SNAPSHOT]
        at org.apache.accumulo.core.trace.TraceWrappedRunnable.run(TraceWrappedRunnable.java:52) ~[accumulo-core-2.1.0-SNAPSHOT.jar:2.1.0-SNAPSHOT]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) ~[?:?]
        at java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[?:?]
        at org.apache.accumulo.core.trace.TraceWrappedRunnable.run(TraceWrappedRunnable.java:52) ~[accumulo-core-2.1.0-SNAPSHOT.jar:2.1.0-SNAPSHOT]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[?:?]
        at org.apache.accumulo.core.trace.TraceWrappedRunnable.run(TraceWrappedRunnable.java:52) ~[accumulo-core-2.1.0-SNAPSHOT.jar:2.1.0-SNAPSHOT]
        at java.lang.Thread.run(Thread.java:829) [?:?]

It turns out that the issue here is that ExecutorService.submit was being called and the Future result object was not being checked. When he changed the code to use ExecutorService.execute instead, then the AccumuloUncaughtExceptionHandler was invoked, the Error printed in the log, and the VM halted. When using submit, the TabletServer remained up, but in a Zombie non-functional state.

It appears that Futures are capturing Exceptions and Errors, so the UncaughtExceptionHandler is not being invoked. It would be nice if SpotBugs had a rule for this. The closest I found is https://github.com/spotbugs/spotbugs/issues/950, but it’s still open.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:12 (12 by maintainers)

github_iconTop GitHub Comments

2reactions
dlmarioncommented, Feb 23, 2022

I added the following to the errorprone profile in the parent pom

                   -Xep:FutureReturnValueIgnored:ERROR \

It found 16 errors in the tserver module when I ran mvn -pl server/tserver -Perrorprone clean package -DskipTests

1reaction
jmark99commented, Feb 23, 2022

Removing the DisableAllWarnings is fine, but ErrorProne is fairly aggressive so there will be a lot of SuppressWarning annotations to add. Of course once all warnings are parsed you can always update the pom to ignore warnings we do not care about.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Future.wait() not catching exceptions (Dart) - Stack Overflow
I think you are a bit mislead by the Future.wait() naming. Future.wait() returns another future that will have a List of elements returned ......
Read more >
New bad-practice rule for missing exception handling ... - GitHub
When you are using CompletableFutures (or CompletionStages) and do not do explicit exception handling, you are effectively ignoring ...
Read more >
Exceptions vs Errors in Java - Scaler
Exceptions that occur at the time of the program execution, i.e., at runtime, are known as Unchecked Exceptions. These exceptions are ignored at ......
Read more >
3 Ways to Handle Exception In Completable Future
Since normal result (success) is not important, ignoring it brings additional benefit: it simplifies the input arguments, and the if-statement ...
Read more >
FutureReturnValueIgnored - Error Prone
Return value of methods returning Future must be checked. Ignoring returned Futures suppresses exceptions thrown from the code that completes the Future.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found