diff options
author | Tomasz Zarna | 2013-09-18 11:39:17 +0000 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org | 2013-10-17 04:01:08 +0000 |
commit | 29bab1d77c5c8997b40b66a16897497d077cc7f9 (patch) | |
tree | a7210e252a8aeac4f4153bcb1eca858650b8e159 | |
parent | d0fea6d8c375c9a92388d4410eff486dcaf9177c (diff) | |
download | rt.equinox.p2-29bab1d77c5c8997b40b66a16897497d077cc7f9.tar.gz rt.equinox.p2-29bab1d77c5c8997b40b66a16897497d077cc7f9.tar.xz rt.equinox.p2-29bab1d77c5c8997b40b66a16897497d077cc7f9.zip |
Bug 417458: Remote bundle discovery is broken on JDK 7u40I20131023-2000I20131022-1300I20131022-0800
Change-Id: I8112dd677bb97b3ce2bdb7880054ff15815b80c0
Signed-off-by: Tomasz Zarna <tomasz.zarna@tasktop.com>
4 files changed, 53 insertions, 5 deletions
diff --git a/bundles/org.eclipse.equinox.p2.discovery.compatibility/src/org/eclipse/equinox/internal/p2/discovery/compatibility/RemoteBundleDiscoveryStrategy.java b/bundles/org.eclipse.equinox.p2.discovery.compatibility/src/org/eclipse/equinox/internal/p2/discovery/compatibility/RemoteBundleDiscoveryStrategy.java index 3af499c7e..2c02cb01e 100644 --- a/bundles/org.eclipse.equinox.p2.discovery.compatibility/src/org/eclipse/equinox/internal/p2/discovery/compatibility/RemoteBundleDiscoveryStrategy.java +++ b/bundles/org.eclipse.equinox.p2.discovery.compatibility/src/org/eclipse/equinox/internal/p2/discovery/compatibility/RemoteBundleDiscoveryStrategy.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2011 Tasktop Technologies and others. + * Copyright (c) 2009, 2013 Tasktop Technologies and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -193,8 +193,7 @@ public class RemoteBundleDiscoveryStrategy extends BundleDiscoveryStrategy { String bundleUrl = entry.getLocation(); for (int attemptCount = 0; attemptCount < maxDiscoveryJarDownloadAttempts; ++attemptCount) { try { - String lastPathElement = bundleUrl.lastIndexOf('/') == -1 ? bundleUrl : bundleUrl.substring(bundleUrl.lastIndexOf('/')); - File target = File.createTempFile(lastPathElement.replaceAll("^[a-zA-Z0-9_.]", "_") + "_", ".jar", temporaryStorage); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$ + File target = File.createTempFile(TransportUtil.getFileNameFor(bundleUrl) + "_", ".jar", temporaryStorage); //$NON-NLS-1$ //$NON-NLS-2$ if (monitor.isCanceled()) { break; diff --git a/bundles/org.eclipse.equinox.p2.discovery.compatibility/src/org/eclipse/equinox/internal/p2/discovery/compatibility/util/TransportUtil.java b/bundles/org.eclipse.equinox.p2.discovery.compatibility/src/org/eclipse/equinox/internal/p2/discovery/compatibility/util/TransportUtil.java index 06968dfff..61e16563e 100644 --- a/bundles/org.eclipse.equinox.p2.discovery.compatibility/src/org/eclipse/equinox/internal/p2/discovery/compatibility/util/TransportUtil.java +++ b/bundles/org.eclipse.equinox.p2.discovery.compatibility/src/org/eclipse/equinox/internal/p2/discovery/compatibility/util/TransportUtil.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2011 Tasktop Technologies and others. + * Copyright (c) 2009, 2013 Tasktop Technologies and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -147,4 +147,14 @@ public class TransportUtil { return countFound == locations.size(); } + public static String getFileNameFor(String bundleUrl) { + if (bundleUrl.charAt(bundleUrl.length() - 1) == '/') { + bundleUrl = bundleUrl.substring(0, bundleUrl.length() - 1); + } + if (bundleUrl.lastIndexOf('/') != -1) { + bundleUrl = bundleUrl.substring(bundleUrl.lastIndexOf('/') + 1); + } + return bundleUrl.replaceAll("[^a-zA-Z0-9_\\.]", "_"); //$NON-NLS-1$ //$NON-NLS-2$ + } + } diff --git a/bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests/AllDiscoveryTests.java b/bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests/AllDiscoveryTests.java index 7d925b6eb..3eb3845ac 100644 --- a/bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests/AllDiscoveryTests.java +++ b/bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests/AllDiscoveryTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Tasktop Technologies and others. + * Copyright (c) 2009, 2013 Tasktop Technologies and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -14,6 +14,7 @@ package org.eclipse.equinox.p2.discovery.tests; import junit.framework.Test; import junit.framework.TestSuite; import org.eclipse.equinox.p2.discovery.tests.core.*; +import org.eclipse.equinox.p2.discovery.tests.core.util.TransportUtilTest; /** * @author Steffen Pingel @@ -27,6 +28,7 @@ public class AllDiscoveryTests { suite.addTestSuite(BundleDiscoveryStrategyTest.class); //suite.addTestSuite(RemoteBundleDiscoveryStrategyTest.class); //suite.addTestSuite(ConnectorDiscoveryRemoteTest.class); + suite.addTestSuite(TransportUtilTest.class); return suite; } diff --git a/bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests/core/util/TransportUtilTest.java b/bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests/core/util/TransportUtilTest.java new file mode 100644 index 000000000..725581720 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests/core/util/TransportUtilTest.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * Copyright (c) 2013 Tasktop Technologies and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Tasktop Technologies - initial API and implementation + *******************************************************************************/ +package org.eclipse.equinox.p2.discovery.tests.core.util; + +import junit.framework.TestCase; +import org.eclipse.equinox.internal.p2.discovery.compatibility.util.TransportUtil; + +public class TransportUtilTest extends TestCase { + + public void testGetFileNameForJar() throws Exception { + assertEquals("lib_1.0.jar", TransportUtil.getFileNameFor("lib-1.0.jar")); //$NON-NLS-1$ //$NON-NLS-2$ + } + + public void testGetFileNameForUrl() throws Exception { + assertEquals("lib_1.0.jar", TransportUtil.getFileNameFor("http://www.eclipse.org/downloads/download.php?file=/discovery/lib-1.0.jar")); //$NON-NLS-1$ //$NON-NLS-2$ + } + + public void testGetFileNameForUrlWithQuery() throws Exception { + assertEquals("lib_1.0.jar_r_1_protocol_http", TransportUtil.getFileNameFor("http://www.eclipse.org/downloads/download.php?file=/discovery/lib-1.0.jar&r=1&protocol=http")); //$NON-NLS-1$ //$NON-NLS-2$ + } + + public void testGetFileNameForUrlEndingWithSlash() throws Exception { + assertEquals("a.jar", TransportUtil.getFileNameFor("a.jar/")); //$NON-NLS-1$ //$NON-NLS-2$ + } + + public void testGetFileNameForUrlWithFilesystemReservedCharacters() throws Exception { + assertEquals("1_2_3_4_5_6_7_8_9_", TransportUtil.getFileNameFor("1<2>3:4\"5\\6|7?8*9+")); //$NON-NLS-1$ //$NON-NLS-2$ + } +}
\ No newline at end of file |