This is an automated email from the ASF dual-hosted git repository.

mibo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/olingo-odata2.git

commit 24ce21927e635259479bac1cfd5e806a8eee832d
Author: mibo <[email protected]>
AuthorDate: Sun Mar 6 21:26:53 2022 +0100

    [OLINGO-1398] Improved jar file handling
---
 .../odata2/annotation/processor/core/util/ClassHelper.java   | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git 
a/odata2-annotation-processor/annotation-processor-core/src/main/java/org/apache/olingo/odata2/annotation/processor/core/util/ClassHelper.java
 
b/odata2-annotation-processor/annotation-processor-core/src/main/java/org/apache/olingo/odata2/annotation/processor/core/util/ClassHelper.java
index 6a0dc3e..3162dad 100644
--- 
a/odata2-annotation-processor/annotation-processor-core/src/main/java/org/apache/olingo/odata2/annotation/processor/core/util/ClassHelper.java
+++ 
b/odata2-annotation-processor/annotation-processor-core/src/main/java/org/apache/olingo/odata2/annotation/processor/core/util/ClassHelper.java
@@ -24,6 +24,7 @@ import java.io.FilenameFilter;
 import java.io.IOException;
 import java.lang.reflect.Field;
 import java.lang.reflect.ParameterizedType;
+import java.net.JarURLConnection;
 import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URISyntaxException;
@@ -146,17 +147,18 @@ public class ClassHelper {
 
   private static Collection<String> getClassFqnFromJar(final URI uri, final 
String packageToScan) {
     final String jarFilePath;
-    String filepath = uri.getSchemeSpecificPart().substring(5);
+    String filepath = uri.toString();
     String[] split = filepath.split(JAR_RESOURCE_SEPARATOR);
-    if (split.length == 2) {
-      jarFilePath = split[0];
+    if (split.length > 1) {
+         jarFilePath = filepath.substring(0, filepath.lastIndexOf("!")+2);
     } else {
       throw new IllegalArgumentException("Illegal jar file path '" + filepath 
+ "'.");
     }
-
     JarFile jarFile = null;
     try {
-      jarFile = new JarFile(jarFilePath);
+      URL url = new URL(jarFilePath);
+      JarURLConnection connection = (JarURLConnection) url.openConnection();
+      jarFile = connection.getJarFile();
       List<String> classFileNames = new ArrayList<String>();
       Enumeration<JarEntry> entries = jarFile.entries();
 

Reply via email to