英文:
Findbugs: RV_RETURN_VALUE_IGNORED_BAD_PRACTICE using ExecutorService
问题
I'm using Findbugs and I'm getting the RV_RETURN_VALUE_IGNORED_BAD_PRACTICE next error, this is my code:
ExecutorService executor = Executors.newSingleThreadExecutor();
try {
executor.submit(() -> {
LOGGER.info(
".............",
Some Code.....
});
executor.shutdown();
executor.awaitTermination(5, TimeUnit.SECONDS);
}
catch (InterruptedException e) {
LOGGER.info(".........);
}
finally {
if (!executor.isTerminated()) {
LOGGER.info(.....);
}
executor.shutdownNow();
LOGGER.info(.........);
}
The issue is in the line: executor.submit(() -> {
Any ideas?
英文:
I'm using Findbugs and I'm getting the RV_RETURN_VALUE_IGNORED_BAD_PRACTICE next error, this is my code:
ExecutorService executor = Executors.newSingleThreadExecutor();
      try {
        executor.submit(() -> {
          LOGGER.info(
              ".............",
              Some Code.....
        });
        executor.shutdown();
        executor.awaitTermination(5, TimeUnit.SECONDS);
      }
      catch (InterruptedException e) {
        LOGGER.info(".........);
      }
      finally {
        if (!executor.isTerminated()) {
          LOGGER.info(.....);
        }
        executor.shutdownNow();
        LOGGER.info(.........);
      }
The issue is in the line: executor.submit(() -> {
Any ideas?
答案1
得分: 4
如果您真的不关心执行结果,应该使用 executor.execute(()-> {LOGGER.info(...)});。
英文:
If you really don't care about the result of the execution, you should use executor.execute(()-> {LOGGER.info(...)}); instead.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论