javax.naming.InitialContext
和 javax.naming.NamingEnumeration
。
默认情况下,该检查假定资源可以由名称中带有 'close' 或 'cleanup' 的任何方法关闭。
示例:
Object findObject(Properties properties, String name) throws NamingException {
Context context = new InitialContext(properties); //上下文未关闭
return context.lookup(name);
}
使用以下选项配置检查:
try
块内打开 JNDI 资源。
这种样式不太合意,因为它比在 try
块前面打开资源更冗长。