remember if close() happens
package org.apache.uima.internal.util;
import java.io.File;
+import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
@@ -50,6 +51,8 @@ public class UIMAClassLoader extends URLClassLoader {
// not static
final private Object[] syncLocks = new Object[nbrLocks];
+ private boolean isClosed = false;
+
/**
* Transforms the string classpath to a URL array based classpath.
*
@@ -204,6 +207,8 @@ public class UIMAClassLoader extends URLClassLoader {
*/
@Override
public URL getResource(String name) {
+
+ synchronized (syncLocks[name.hashCode() & (nbrLocks - 1)]) { // https://issues.apache.org/jira/browse/UIMA-5741
URL url = findResource(name);
if (null == url) {
@@ -211,5 +216,28 @@ public class UIMAClassLoader extends URLClassLoader {
}
return url;
}
+ }
+
+ /**
+ * The UIMA Class Loader extends URLClassLoader. This kind of classloader supports
+ * the close() method.
+ *
+ * When this class loader is closed, it remembers this.
+ *
+ * @return true if this class loader has been closed.
+ */
+ public boolean isClosed() {
+ return isClosed;
+ }
+
+ /* (non-Javadoc)
+ * @see java.net.URLClassLoader#close()
+ */
+ @Override
+ public void close() throws IOException {
+ isClosed = true;
+ super.close();
+ }
+
}
