potential resource leak (unassigned Closeable) with a HashMap
问题 I have one static HashMap for my entire system which contains some object's references; let's call it myHash . The objects are only instantiated once I needed them such as private static HashMap<String, lucene.store.Directory> directories; public static Object getFoo(String key) { if (directories == null) { directories = new HashMap<String, Directory>(); } if (directories.get(key) == null) { directories.put(key, new RAMDirectory()); } return directories.get(key); // warning } Now, Eclipse is