You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by rm...@apache.org on 2015/05/06 10:01:44 UTC
tomee git commit: tesing classpath searcher cleanup of url set
Repository: tomee
Updated Branches:
refs/heads/master ddc521585 -> 1381e2fa7
tesing classpath searcher cleanup of url set
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/1381e2fa
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/1381e2fa
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/1381e2fa
Branch: refs/heads/master
Commit: 1381e2fa7007a8dab5198687f6c5f518fe66f4a5
Parents: ddc5215
Author: Romain Manni-Bucau <rm...@apache.org>
Authored: Wed May 6 10:01:34 2015 +0200
Committer: Romain Manni-Bucau <rm...@apache.org>
Committed: Wed May 6 10:01:34 2015 +0200
----------------------------------------------------------------------
.../openejb/config/DeploymentsResolver.java | 2 +-
.../openejb/config/DeploymentsResolverTest.java | 72 ++++++++++++++++++++
2 files changed, 73 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/1381e2fa/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentsResolver.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentsResolver.java b/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentsResolver.java
index 73d783e..d045a23 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentsResolver.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentsResolver.java
@@ -409,7 +409,7 @@ public class DeploymentsResolver implements DeploymentFilterable {
final List<URL> copy = set.getUrls();
for (final URL url : set.getUrls()) {
try {
- if ("file".equals(url.getProtocol()) && copy.contains(new URL("jar:" + url.toExternalForm() + "!"))) {
+ if ("file".equals(url.getProtocol()) && copy.contains(new URL("jar:" + url.toExternalForm() + "!/"))) {
copy.remove(url);
}
} catch (final MalformedURLException e) {
http://git-wip-us.apache.org/repos/asf/tomee/blob/1381e2fa/container/openejb-core/src/test/java/org/apache/openejb/config/DeploymentsResolverTest.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/test/java/org/apache/openejb/config/DeploymentsResolverTest.java b/container/openejb-core/src/test/java/org/apache/openejb/config/DeploymentsResolverTest.java
new file mode 100644
index 0000000..ee3d4a5
--- /dev/null
+++ b/container/openejb-core/src/test/java/org/apache/openejb/config/DeploymentsResolverTest.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.openejb.config;
+
+import org.junit.Test;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.Enumeration;
+
+import static java.util.Collections.emptyEnumeration;
+import static java.util.Collections.enumeration;
+import static java.util.Collections.singleton;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+public class DeploymentsResolverTest {
+ @Test
+ public void avoidDuplicatedJars() throws MalformedURLException {
+ final File metaInf = new File("target/DeploymentsResolverTest/avoidDuplicatedJars/META-INF");
+ metaInf.getParentFile().mkdirs();
+
+ final URL url = metaInf.getParentFile().toURI().toURL();
+ final ClassLoader loader = new URLClassLoader(new URL[] {url}, new ClassLoader() {
+ @Override
+ protected Class<?> loadClass(final String name, final boolean resolve) throws ClassNotFoundException {
+ throw new ClassNotFoundException();
+ }
+
+ @Override
+ public Enumeration<URL> getResources(final String name) throws IOException {
+ return emptyEnumeration();
+ }
+ }) {
+ @Override
+ public Enumeration<URL> getResources(final String name) throws IOException {
+ if ("META-INF".equals(name)) {
+ return emptyEnumeration();
+ }
+ return enumeration(singleton(new URL("jar:file:/tmp/app.jar!/")));
+ }
+
+ @Override
+ public URL[] getURLs() {
+ try {
+ return new URL[] { new URL("file:/tmp/app.jar") };
+ } catch (final MalformedURLException e) {
+ fail();
+ throw new IllegalStateException(e);
+ }
+ }
+ };
+ assertEquals(1, new DeploymentsResolver.ClasspathSearcher().loadUrls(loader).getUrls().size());
+ }
+}