- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我有这样的代码:
public static MyObject forId(long myObjectId, Connection cxn) throws SQLException {
try (PreparedStatement stmt = cxn.prepareStatement(selectMyObjectById))) {
stmt.setLong(1, myObjectId);
try (ResultSet res = stmt.executeQuery()) {
res.next();
return MyObject.fromResultSet(res);
}
}
}
对于 JDBC 语句对象,SpotBugs 将其标识为 OBL_UNSATISFIED_OBLIGATION
。这是误报吗?我的印象是 try-with-resources 将确保这些资源在所有情况下都能正确关闭。
最佳答案
正如您正确声明的那样,您的 ResultSet 和 PreparedStatement 受到保护。
如果您的连接也在相关范围内得到适当处理,那么是的,这是误报。
关于java - SpotBugs 是否报告了未在此处关闭资源的误报?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47776786/
import lombok.Data; @Data public class Filter { private Operator operator; private Object va
我刚刚在 SonarQube 中发现了一个误导性问题,我们的代码如下(JS) {…} function test(searchQuery, role) { console.log("inputs: "
我想我发现了误报: const items = document.querySelectorAll(selectors); for (const item of items) { if(item)
这是我第一次尝试编写实现简单形式的堆栈跟踪的自定义异常类。 这是.h: class error { public: error (); error (const
我正在尝试构建我的第一个 XML 模式 validator 作为我的代码库和许多项目中的可重用组件。我花了一整天的时间尝试遵循示例并对其进行编码,现在已经启动并运行了概念验证。 唯一的问题是,它给了我
我的数据库中有一个表,其中有一个名为“tags”的字段,例如iOS、Android、Java、JavaScript 等。我想选择此表中的所有项目,这些项目与某些标签相匹配,例如 id | name |
我刚刚开始在一个现有的中型项目中试验 .NET 4 中的 CodeContracts,令我惊讶的是静态检查器向我发出有关以下代码片段的编译时警告: public class Foo { priv
我不知道为什么,但我以前没有问题,现在突然之间,我很久以前写的这个非常古老、可怕的新手程序触发了 Malwarebytes... :( 这个问题不是重复的,因为有问题的程序是在 (ANSI) C 而不
在 Ubuntu 9.10 下启动了一个 Git 存储库。终于升级到10.04。当前的 Git 是 1.7.0.4。 现在,当我编辑升级前最后更改的文件(使用 gedit)然后提交时,提交中充满了误报
在设置 mod_security 后,我收到了很多误报 [??]。我只是在检测中运行它,所以还没有问题,但是一旦我需要它上线,这些过滤器就会开始阻止请求。 恐怕我不能 100% 理解这些过滤器的重要性
引用 Valgrind 教程: Optimized code can cause valgrind to wrongly report uninitialized value errors. The
Sonar 是否有可能在分支之间传输“误报”? 这是我们的工作流程:我们在分支 1 中进行开发,我们对此分支进行 Sonar 检查,当分支 1 发布时,我们将其合并到主干中,然后我们从主干创建分支 2
我的代码库中有一个静态函数的实现,并且在运行 clang-tidy 时在它上面,我注意到当我很确定代码正确时,静态分析器指向可能的内存泄漏。 (我已经用 sanitizer 验证过)。我认为这很可能是
Coverity 标记了一个我无法理解的问题。 我有一个初始化器: 1686 arrayOfNodeIds componentRefs = (arrayOfNodeIds) { 1687 .s
react.js 发生了一些奇怪的事情 Top-Level API . 这是我的mocha 测试的摘录: it.only('should identify a ReactElement', funct
大家好,我在使用 Apple 的可达性代码时遇到了一些问题。我发现,即使设备正确连接到互联网,最初可达性代码也会发出 1 个错误通知(Networkstatus = NotReachable),然后是
我一直在尝试运行 Insure++使用一些科学代码并报告许多错误,尽管公平地说它正式不支持 K&R C,而且我不知道大量 K&R 函数对其评估过程有何影响。它正在测试的 C 和 C++ 代码正在从 W
当我尝试调用 CFileFind.FindFile(_T("D://Folder//*.txt")) 时,当唯一的文件是“foobar.txta”时,该方法返回 true . 但是,我不希望文件 fo
在我之前的问题 ( "Pylint E0202 False Positive?" ) 之后,这里是另一个问题(我想很具体) 我们正在使用模块子流程来执行子流程。 创建示例代码会产生以下结果: "Exa
我有一个包含 2,865,044 个条目和 3 级 MultiIndex 的数据框 MultiIndex.levels.names = ['year', 'country', 'productcode
我是一名优秀的程序员,十分优秀!