当前位置: 代码迷 >> 综合 >> 【Bug】Either re-interrupt this method or rethrow the InterruptedException
  详细解决方案

【Bug】Either re-interrupt this method or rethrow the InterruptedException

热度:86   发布时间:2023-12-08 17:19:29.0

使用sonar扫描项目代码时提示如下信息:

Either re-interrupt this method or rethrow the "InterruptedException"

问题代码如下:

try {
    Thread.sleep(1000);
} catch (InterruptedException e) {
    logger.error("休眠1秒失败,请核查", e);
}

解决:

try {
    Thread.sleep(1000);
} catch (InterruptedException e) {
    logger.error("休眠1秒失败,请核查", e);Thread.currentThread().interrupt();
}
  相关解决方案