summaryrefslogtreecommitdiff
path: root/plugins/ingest-attachment
diff options
context:
space:
mode:
authorRyan Ernst <ryan@iernst.net>2017-03-21 12:12:16 -0700
committerGitHub <noreply@github.com>2017-03-21 12:12:16 -0700
commitf8453aca57a8151c586d0e14e87932ba7bc82d52 (patch)
tree37f2e97273c673ec2e1c530d9ef3ed7947cc890c /plugins/ingest-attachment
parent105bc0ee1fd6ef50cc80d5fa2b00cc8a0e904c70 (diff)
Packaging: Remove classpath ordering hack (#23596)
After the removal of the joda time hack we used to have, we can cleanup the codebase handling in security, jarhell and plugins to be more picky about uniqueness. This was originally in #18959 which was never merged. closes #18959
Diffstat (limited to 'plugins/ingest-attachment')
-rw-r--r--plugins/ingest-attachment/src/main/java/org/elasticsearch/ingest/attachment/TikaImpl.java11
1 files changed, 9 insertions, 2 deletions
diff --git a/plugins/ingest-attachment/src/main/java/org/elasticsearch/ingest/attachment/TikaImpl.java b/plugins/ingest-attachment/src/main/java/org/elasticsearch/ingest/attachment/TikaImpl.java
index c7ffe4f287..3c0f3b0433 100644
--- a/plugins/ingest-attachment/src/main/java/org/elasticsearch/ingest/attachment/TikaImpl.java
+++ b/plugins/ingest-attachment/src/main/java/org/elasticsearch/ingest/attachment/TikaImpl.java
@@ -47,7 +47,9 @@ import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.security.ProtectionDomain;
import java.security.SecurityPermission;
+import java.util.Arrays;
import java.util.Collections;
+import java.util.LinkedHashSet;
import java.util.PropertyPermission;
import java.util.Set;
@@ -128,7 +130,12 @@ final class TikaImpl {
addReadPermissions(perms, JarHell.parseClassPath());
// plugin jars
if (TikaImpl.class.getClassLoader() instanceof URLClassLoader) {
- addReadPermissions(perms, ((URLClassLoader)TikaImpl.class.getClassLoader()).getURLs());
+ URL[] urls = ((URLClassLoader)TikaImpl.class.getClassLoader()).getURLs();
+ Set<URL> set = new LinkedHashSet<>(Arrays.asList(urls));
+ if (set.size() != urls.length) {
+ throw new AssertionError("duplicate jars: " + Arrays.toString(urls));
+ }
+ addReadPermissions(perms, set);
}
// jvm's java.io.tmpdir (needs read/write)
perms.add(new FilePermission(System.getProperty("java.io.tmpdir") + System.getProperty("file.separator") + "-",
@@ -145,7 +152,7 @@ final class TikaImpl {
// add resources to (what is typically) a jar, but might not be (e.g. in tests/IDE)
@SuppressForbidden(reason = "adds access to jar resources")
- static void addReadPermissions(Permissions perms, URL resources[]) {
+ static void addReadPermissions(Permissions perms, Set<URL> resources) {
try {
for (URL url : resources) {
Path path = PathUtils.get(url.toURI());