Repository: cxf Updated Branches: refs/heads/master 28f5da32c -> 01fbddbf6
[CXF-6483] Sorting ConfigurerImpl matchers Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/01fbddbf Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/01fbddbf Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/01fbddbf Branch: refs/heads/master Commit: 01fbddbf6c2e9a935a43f86079734daf27ee445d Parents: 28f5da3 Author: Sergey Beryozkin <[email protected]> Authored: Thu Jul 2 14:22:43 2015 +0100 Committer: Sergey Beryozkin <[email protected]> Committed: Thu Jul 2 14:22:43 2015 +0100 ---------------------------------------------------------------------- .../apache/cxf/bus/blueprint/ConfigurerImpl.java | 17 +++++++++++++++++ .../cxf/configuration/spring/ConfigurerImpl.java | 18 ++++++++++++++++++ .../jaxrs/security/jaxrs-https-client2.xml | 7 ++++--- 3 files changed, 39 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/01fbddbf/core/src/main/java/org/apache/cxf/bus/blueprint/ConfigurerImpl.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/cxf/bus/blueprint/ConfigurerImpl.java b/core/src/main/java/org/apache/cxf/bus/blueprint/ConfigurerImpl.java index 128fee4..b2a09b5 100644 --- a/core/src/main/java/org/apache/cxf/bus/blueprint/ConfigurerImpl.java +++ b/core/src/main/java/org/apache/cxf/bus/blueprint/ConfigurerImpl.java @@ -21,6 +21,8 @@ package org.apache.cxf.bus.blueprint; import java.lang.reflect.Method; import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -89,6 +91,10 @@ public class ConfigurerImpl implements Configurer { } } } + Comparator<MatcherHolder> comp = new MatcherHolderComparator(); + for (Map.Entry<String, List<MatcherHolder>> entry : wildCardBeanDefinitions.entrySet()) { + Collections.sort(entry.getValue(), comp); + } } public void configureBean(Object beanInstance) { @@ -175,5 +181,16 @@ public class ConfigurerImpl implements Configurer { return beanName; } + private static class MatcherHolderComparator implements Comparator<MatcherHolder> { + @Override + public int compare(MatcherHolder mh1, MatcherHolder mh2) { + Integer literalCharsLen1 = mh1.wildCardId.replaceAll("\\*", "").length(); + Integer literalCharsLen2 = mh2.wildCardId.replaceAll("\\*", "").length(); + // The expression with more literal characters should end up on the top of the list + return literalCharsLen1.compareTo(literalCharsLen2) * -1; + + } + + } } http://git-wip-us.apache.org/repos/asf/cxf/blob/01fbddbf/core/src/main/java/org/apache/cxf/configuration/spring/ConfigurerImpl.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/cxf/configuration/spring/ConfigurerImpl.java b/core/src/main/java/org/apache/cxf/configuration/spring/ConfigurerImpl.java index 0b59288..c481de3 100644 --- a/core/src/main/java/org/apache/cxf/configuration/spring/ConfigurerImpl.java +++ b/core/src/main/java/org/apache/cxf/configuration/spring/ConfigurerImpl.java @@ -21,6 +21,8 @@ package org.apache.cxf.configuration.spring; import java.lang.reflect.Method; import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -118,6 +120,10 @@ public class ConfigurerImpl extends BeanConfigurerSupport } } } + Comparator<MatcherHolder> comp = new MatcherHolderComparator(); + for (Map.Entry<String, List<MatcherHolder>> entry : wildCardBeanDefinitions.entrySet()) { + Collections.sort(entry.getValue(), comp); + } } public void configureBean(Object beanInstance) { @@ -278,4 +284,16 @@ public class ConfigurerImpl extends BeanConfigurerSupport protected Set<ApplicationContext> getAppContexts() { return appContexts; } + private static class MatcherHolderComparator implements Comparator<MatcherHolder> { + + @Override + public int compare(MatcherHolder mh1, MatcherHolder mh2) { + Integer literalCharsLen1 = mh1.wildCardId.replaceAll("\\*", "").length(); + Integer literalCharsLen2 = mh2.wildCardId.replaceAll("\\*", "").length(); + // The expression with more literal characters should end up on the top of the list + return literalCharsLen1.compareTo(literalCharsLen2) * -1; + + } + + } } http://git-wip-us.apache.org/repos/asf/cxf/blob/01fbddbf/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/jaxrs-https-client2.xml ---------------------------------------------------------------------- diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/jaxrs-https-client2.xml b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/jaxrs-https-client2.xml index b2464fc..f02b741 100644 --- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/jaxrs-https-client2.xml +++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/jaxrs-https-client2.xml @@ -18,9 +18,10 @@ specific language governing permissions and limitations under the License. --> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:http="http://cxf.apache.org/transports/http/configuration" xmlns:httpj="http://cxf.apache.org/transports/http-jetty/configuration" xmlns:sec="http://cxf.apache.org/configuration/security" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd http://cxf.apache.org/transports/http-jetty/configuration http://cxf.apache.org/schemas/configuration/http-jetty.xsd http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.xsd "> - <!-- --> - <!-- HTTP/S configuration for proxy & web clients --> - <!-- --> + <!-- this conduit is less specific and should not be selected --> + <http:conduit name="*.http-conduit"> + <http:client ConnectionTimeout="3000000" ReceiveTimeout="3000000"/> + </http:conduit> <http:conduit name="https://localhost:.*/bookstore/securebooks.*"> <http:client ConnectionTimeout="3000000" ReceiveTimeout="3000000"/> <http:tlsClientParameters disableCNCheck="true">
