THRIFT-3140 ConcurrentModificationException is thrown by JavaScript test server
diff --git a/lib/js/test/src/test/Httpd.java b/lib/js/test/src/test/Httpd.java
index f1291d8..e4fc0cc 100644
--- a/lib/js/test/src/test/Httpd.java
+++ b/lib/js/test/src/test/Httpd.java
@@ -183,16 +183,18 @@
} else {
- String mimeType = "application/octet-stream";
- MimeUtil2 mimeUtil = new MimeUtil2();
- mimeUtil.registerMimeDetector(ExtensionMimeDetector.class.getName());
- Collection<MimeType> collection = mimeUtil.getMimeTypes(file);
- Iterator<MimeType> iterator = collection.iterator();
- while(iterator.hasNext()) {
- MimeType mt = iterator.next();
- mimeType = mt.getMediaType() + "/" + mt.getSubType();
- break;
- }
+ String mimeType = "application/octet-stream";
+ MimeUtil2 mimeUtil = new MimeUtil2();
+ synchronized (this) {
+ mimeUtil.registerMimeDetector(ExtensionMimeDetector.class.getName());
+ }
+ Collection<MimeType> collection = mimeUtil.getMimeTypes(file);
+ Iterator<MimeType> iterator = collection.iterator();
+ while(iterator.hasNext()) {
+ MimeType mt = iterator.next();
+ mimeType = mt.getMediaType() + "/" + mt.getSubType();
+ break;
+ }
response.setStatusCode(HttpStatus.SC_OK);
FileEntity body = new FileEntity(file, mimeType);