You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwebbeans.apache.org by st...@apache.org on 2020/06/13 19:26:03 UTC

[openwebbeans] branch master updated: OWB-1328 remove Exception and file.exists()

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

struberg pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openwebbeans.git


The following commit(s) were added to refs/heads/master by this push:
     new 638f8bc  OWB-1328 remove Exception and file.exists()
638f8bc is described below

commit 638f8bc98ad1b8ec4ef90104625cd91ecca0f95b
Author: Mark Struberg <st...@apache.org>
AuthorDate: Sat Jun 13 21:22:59 2020 +0200

    OWB-1328 remove Exception and file.exists()
    
    The handling for unknown protocols must not be handled in this very method.
    Also we like to avoid as many file operations as possible.
    Remember: this whole else-branch is a rather dirty performance hack anyway.
---
 .../corespi/scanner/AbstractMetaDataDiscovery.java | 25 +++++++++-------------
 1 file changed, 10 insertions(+), 15 deletions(-)

diff --git a/webbeans-impl/src/main/java/org/apache/webbeans/corespi/scanner/AbstractMetaDataDiscovery.java b/webbeans-impl/src/main/java/org/apache/webbeans/corespi/scanner/AbstractMetaDataDiscovery.java
index 700435c..210556e 100644
--- a/webbeans-impl/src/main/java/org/apache/webbeans/corespi/scanner/AbstractMetaDataDiscovery.java
+++ b/webbeans-impl/src/main/java/org/apache/webbeans/corespi/scanner/AbstractMetaDataDiscovery.java
@@ -284,24 +284,19 @@ public abstract class AbstractMetaDataDiscovery implements BdaScannerService
             }
             else
             {
-                // we could check for META-INF/maven/org.apache.geronimo.specs presence there but this is faster
-                File file = Files.toFile(url);
-                if (file == null)
+                if (path.contains("geronimo-"))
                 {
-                    throw new IllegalArgumentException(
-                            "URL not supported (only jar and file are supported by this impl): " + url + ". " +
-                            "Ensure to use a compatible implementation of " +
-                            BdaScannerService.class.getName() + " or " +
-                            "add the url to org.apache.webbeans.scanExclusionPaths in openwebbeans.properties.");
-                }
-                if (file.exists())
-                {
-                    final String filename = file.getName();
-                    if (filename.startsWith("geronimo-") && filename.contains("_spec"))
+                    // we could check for META-INF/maven/org.apache.geronimo.specs presence there but this is faster
+                    final File file = Files.toFile(url);
+                    if (file != null)
                     {
-                        it.remove();
+                        final String filename = file.getName();
+                        if (filename.startsWith("geronimo-") && filename.contains("_spec"))
+                        {
+                            it.remove();
+                        }
                     }
-                }                
+                }
             }
         }
     }