Sonarqube - “InterruptedException“ should not be ignored

简介: Sonarqube - “InterruptedException“ should not be ignored

解决方案

log.error("InterruptedException: ", e);
Thread.currentThread().interrupt();

Ps:这里主要对第二行代码解释,平时我们应该没这个习惯来写该行代码。


中断线程

线程的thread.interrupt()方法是中断线程,将会设置该线程的中断状态位,即设置为true,中断的结果线程是死亡、还是等待新的任务或是继续运行至下一步,就取决于这个程序本身。线程会不时地检测这个中断标示位,以判断线程是否应该被中断(中断标示值是否为true)。它并不像stop方法那样会中断一个正在运行的线程。


目录
相关文章
|
6月前
|
SQL 开发框架 安全
【译】You probably should stop using a custom TaskScheduler
以更明确的方式控制并发 我认为并发控制(又称速率限制)是应用程序非常重要的方面,重要的方面应该是明确的。 TaskScheduler 相当低级别的工具,我宁愿拥有更高级别的工具。如果工作是 CPU 密集型的,那么 PLINQ 或类似 ActionBlock TPL DataFlow 的东西可能是更好的选择。 如果工作主要是 IO 绑定和异步的,那么可以使用 Parallel.ForEachAsync 或 Polly.RateLimiting 基于 的 SemaphoreSlim 自定义帮助程序类。 结论
57 3
|
Java Maven 微服务
To see the full stack trace of the errors, re-run Maven with the -e switch.
问题描述 微服务项目中其它模块不能依赖common模块中的依赖 而common中是有依赖的
958 1
To see the full stack trace of the errors, re-run Maven with the -e switch.
|
Oracle Java 关系型数据库
JDK/JAVA Exception NSWindow drag regions should only be invalidated on the Main Thread
JDK/JAVA Exception NSWindow drag regions should only be invalidated on the Main Thread
155 0
|
Java Maven
maven teavm-idea-artifacts: Command execution failed.: Process exited with an error: 1 Exit value: 1
maven teavm-idea-artifacts: Command execution failed.: Process exited with an error: 1 Exit value: 1
408 0
|
Java Spring
default constructor not found 异常解决方法
default constructor not found 异常解决方法
2182 0
|
Java Shell Linux
[ERROR] Result: { execute timeout }异常解决
记一次AlibabaCloudToolKit插件使用过程中云助手执行脚本时,脚本超时的异常的解决方案.
10561 0
|
JavaScript 安全 前端开发
What Is ElectronJS and Why Should You Use It?
In this three-part tutorial, we will explore how to create a fully functional invoice application using ElectronJS and ApsaraDB for MongoDB.
2664 0
What Is ElectronJS and Why Should You Use It?
|
Java 数据库连接
hibernate exception (cannot simultaneously fetch multiple bags)
      org.hibernate.loader.MultipleBagFetchException: cannot simultaneously fetch multiple bags at org.
1588 0
|
Android开发 Go
Gradle sync failed: The first result from the daemon was empty. Most likely the process died immediately after connection
Gradle sync failed: The first result from the daemon was empty. Most likely the process died immediately after connection solv...
3171 0