Skip to content

Commit

Permalink
ARIES-2166: Fix web url handler in org.eclipse.osgi > 3.17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
alien11689 committed Feb 14, 2025
1 parent e702eb8 commit 929fc67
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion web/web-itests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<org.apache.aries.util.version>1.2.0-SNAPSHOT</org.apache.aries.util.version>
<org.apache.aries.web.urlhandler.version>1.0.1-SNAPSHOT</org.apache.aries.web.urlhandler.version>
<org.apache.felix.configadmin.version>1.9.26</org.apache.felix.configadmin.version>
<org.eclipse.osgi.version>3.17.0</org.eclipse.osgi.version>
<org.eclipse.osgi.version>3.22.0</org.eclipse.osgi.version>
<tinybundles.version>2.1.1</tinybundles.version>
<url.version>2.5.3</url.version>
</properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@
*/
package org.apache.aries.web.url;

import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.net.URLConnection;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.util.Dictionary;
import java.util.Hashtable;
import java.util.StringTokenizer;
Expand Down Expand Up @@ -69,8 +72,14 @@ public URLConnection openConnection(URL url) throws IOException
firstProperty = false;
}
}

return new WARConnection(new URL(url.getPath()), properties);
WARConnection warConnection = new WARConnection(new URL(url.getPath()), properties);
// in new version of org.eclipse.osgi > 3.17.0 we cannot return war connection
// since when its protocol is file then generated input stream is ignored
// and framework reads file again
// https://github.com/eclipse-equinox/equinox/blob/e35221a86afd24ee21b7b9d02db298a90ace1bc0/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java#L1158-L1181
File webbundle = File.createTempFile("webbundle", ".wab");
Files.copy(warConnection.getInputStream(), webbundle.toPath(), StandardCopyOption.REPLACE_EXISTING);
return webbundle.getAbsoluteFile().toURI().toURL().openConnection();
}

@Override
Expand Down

0 comments on commit 929fc67

Please sign in to comment.