You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by jl...@apache.org on 2017/07/10 11:39:18 UTC

[2/5] tomee git commit: Fix TomEE-2085

Fix TomEE-2085

Fix the sorting issue, by removing the sorting operation. We are not interested in the order of the elements, but only in the smallest element.


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/11b8f6d7
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/11b8f6d7
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/11b8f6d7

Branch: refs/heads/master
Commit: 11b8f6d746b09a82f46201a2cb077c211f8dc527
Parents: 97b606b
Author: Svetlin Zarev <sv...@sap.com>
Authored: Tue Jul 4 11:14:46 2017 +0300
Committer: Svetlin Zarev <sv...@sap.com>
Committed: Tue Jul 4 11:14:46 2017 +0300

----------------------------------------------------------------------
 .../java/org/apache/openejb/config/AutoConfig.java     | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/11b8f6d7/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfig.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfig.java b/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfig.java
index 5639b36..1494bc0 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfig.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfig.java
@@ -2073,8 +2073,12 @@ public class AutoConfig implements DynamicDeployer, JndiConstants {
     }
 
     private String firstMatching(final String prefix, final String type, final Properties required, final AppResources appResources) {
-        final List<String> resourceIds = new ArrayList<String>(getResourceIds(appResources, type, required));
-        Collections.sort(resourceIds, new Comparator<String>() { // sort from webapp to global resources
+        final List<String> resourceIds = getResourceIds(appResources, type, required);
+        if(resourceIds.isEmpty()){
+            return null;
+        }
+
+        return Collections.min(resourceIds, new Comparator<String>() { // sort from webapp to global resources
             @Override
             public int compare(final String o1, final String o2) { // don't change global order, just put app scoped resource before others
                 if (o1.startsWith(prefix) && o2.startsWith(prefix)) {
@@ -2088,11 +2092,6 @@ public class AutoConfig implements DynamicDeployer, JndiConstants {
                 return resourceIds.indexOf(o1) - resourceIds.indexOf(o2);
             }
         });
-        String idd = null;
-        if (resourceIds.size() > 0) {
-            idd = resourceIds.get(0);
-        }
-        return idd;
     }
 
     private String findResourceId(final String resourceId, final String type, final Properties required, final AppResources appResources) {