Skip to content

Commit 103e9f3

Browse files
committed
ARIES-2166: Fix web url handler in org.eclipse.osgi > 3.17.0
1 parent fc00275 commit 103e9f3

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

web/web-itests/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
<org.apache.aries.util.version>1.2.0-SNAPSHOT</org.apache.aries.util.version>
4949
<org.apache.aries.web.urlhandler.version>1.0.1-SNAPSHOT</org.apache.aries.web.urlhandler.version>
5050
<org.apache.felix.configadmin.version>1.9.26</org.apache.felix.configadmin.version>
51-
<org.eclipse.osgi.version>3.17.0</org.eclipse.osgi.version>
51+
<org.eclipse.osgi.version>3.22.0</org.eclipse.osgi.version>
5252
<tinybundles.version>2.1.1</tinybundles.version>
5353
<url.version>2.5.3</url.version>
5454
</properties>

web/web-urlhandler/src/main/java/org/apache/aries/web/url/WAR_URLServiceHandler.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,12 @@
1818
*/
1919
package org.apache.aries.web.url;
2020

21+
import java.io.File;
2122
import java.io.IOException;
2223
import java.net.URL;
2324
import java.net.URLConnection;
25+
import java.nio.file.Files;
26+
import java.nio.file.StandardCopyOption;
2427
import java.util.Dictionary;
2528
import java.util.Hashtable;
2629
import java.util.StringTokenizer;
@@ -69,8 +72,14 @@ public URLConnection openConnection(URL url) throws IOException
6972
firstProperty = false;
7073
}
7174
}
72-
73-
return new WARConnection(new URL(url.getPath()), properties);
75+
WARConnection warConnection = new WARConnection(new URL(url.getPath()), properties);
76+
// in new version of org.eclipse.osgi > 3.17.0 we cannot return war connection
77+
// since when its protocol is file then generated input stream is ignored
78+
// and framework reads file again
79+
// https://github.com/eclipse-equinox/equinox/blob/e35221a86afd24ee21b7b9d02db298a90ace1bc0/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java#L1158-L1181
80+
File webbundle = File.createTempFile("webbundle", ".wab");
81+
Files.copy(warConnection.getInputStream(), webbundle.toPath(), StandardCopyOption.REPLACE_EXISTING);
82+
return webbundle.getAbsoluteFile().toURI().toURL().openConnection();
7483
}
7584

7685
@Override

0 commit comments

Comments
 (0)