#29 No initialization check in ExtensionMimeDetector

open
nobody
None
5
2010-08-17
2010-08-17
Anonymous
No

ExtensionMimeDetector uses a static variable which is intialized by the constructor, but there is no check to see if the static variable is already initialized. That can cause a ConcurrentModificationException if two threads are asking for a new ExtensionMimeDetector, they will both tried to set the extMimeTypes static variable at the same time...

proposed solution: don't call the init method if already initialized

public ExtensionMimeDetector() {
//check if already initialized, if yes do nothing
if (extMimeTypes == null) {
ExtensionMimeDetector.initMimeTypes();
}
}

Discussion