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

sergeyb pushed a commit to branch 3.1.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git


The following commit(s) were added to refs/heads/3.1.x-fixes by this push:
     new e4e1b41  [CXF-7630] Ensuring FilterProviderInfo always has non null 
bindings set
e4e1b41 is described below

commit e4e1b410e470d4678a35180803cd9df08f26a4c3
Author: Sergey Beryozkin <sberyoz...@gmail.com>
AuthorDate: Fri Feb 2 12:57:04 2018 +0000

    [CXF-7630] Ensuring FilterProviderInfo always has non null bindings set
---
 .../org/apache/cxf/jaxrs/model/FilterProviderInfo.java   | 15 ++++++++-------
 .../org/apache/cxf/jaxrs/provider/ProviderFactory.java   | 16 +++++++++-------
 .../apache/cxf/jaxrs/provider/ServerProviderFactory.java |  5 +++--
 3 files changed, 20 insertions(+), 16 deletions(-)

diff --git 
a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/FilterProviderInfo.java
 
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/FilterProviderInfo.java
index 8294736..2b65926 100644
--- 
a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/FilterProviderInfo.java
+++ 
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/FilterProviderInfo.java
@@ -28,7 +28,7 @@ import org.apache.cxf.jaxrs.provider.ProviderFactory;
 
 public class FilterProviderInfo<T> extends ProviderInfo<T> {
 
-    private Set<String> nameBinding;
+    private Set<String> nameBindings;
     private Map<Class<?>, Integer> supportedContracts;
     private boolean dynamic;
 
@@ -37,25 +37,26 @@ public class FilterProviderInfo<T> extends ProviderInfo<T> {
                               T provider,
                               Bus bus,
                               Map<Class<?>, Integer> supportedContracts) {
-        this(resourceClass, serviceClass, provider, bus, 
ProviderFactory.DEFAULT_FILTER_NAME_BINDING, 
-            false, supportedContracts);
+        this(resourceClass, serviceClass, provider, bus,
+             null, false, supportedContracts);
     }
 
     public FilterProviderInfo(Class<?> resourceClass, 
                               Class<?> serviceClass,
                               T provider,
                               Bus bus,
-                              String nameBinding,
+                              Set<String> nameBindings,
                               boolean dynamic,
                               Map<Class<?>, Integer> supportedContracts) {
         super(resourceClass, serviceClass, provider, bus, true);
-        this.nameBinding = nameBinding == null ? null : 
Collections.singleton(nameBinding);
+        this.nameBindings = nameBindings == null 
+            ? 
Collections.singleton(ProviderFactory.DEFAULT_FILTER_NAME_BINDING) : 
nameBindings;
         this.supportedContracts = supportedContracts;
         this.dynamic = dynamic;
     }
 
-    public Set<String> getNameBinding() {
-        return nameBinding;
+    public Set<String> getNameBindings() {
+        return nameBindings;
     }
 
     public int getPriority(Class<?> contract) {
diff --git 
a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
 
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
index a2735b7..7d12c57 100644
--- 
a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
+++ 
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
@@ -948,7 +948,7 @@ public abstract class ProviderFactory {
             } else {
                 if (provider instanceof FilterProviderInfo) {
                     FilterProviderInfo<?> fpi = 
(FilterProviderInfo<?>)provider;
-                    if (fpi.isDynamic() && 
!names.containsAll(fpi.getNameBinding())) {
+                    if (fpi.isDynamic() && 
!names.containsAll(fpi.getNameBindings())) {
                         continue;
                     }
                 }
@@ -1237,12 +1237,14 @@ public abstract class ProviderFactory {
     protected static Set<String> getFilterNameBindings(ProviderInfo<?> p) {
         Set<String> names = null;
         if (p instanceof FilterProviderInfo) {
-            names = ((FilterProviderInfo<?>)p).getNameBinding();
-        }
-        if (names == null) {
-            Class<?> pClass = ClassHelper.getRealClass(p.getBus(), 
p.getProvider());
-            names = AnnotationUtils.getNameBindings(pClass.getAnnotations());
-        }
+            names = ((FilterProviderInfo<?>)p).getNameBindings();
+        } 
+        return names == null ? getFilterNameBindings(p.getBus(), 
p.getProvider()) : names;
+        
+    }
+    protected static Set<String> getFilterNameBindings(Bus bus, Object 
provider) {
+        Class<?> pClass = ClassHelper.getRealClass(bus, provider);
+        Set<String> names = 
AnnotationUtils.getNameBindings(pClass.getAnnotations());
         if (names.isEmpty()) {
             names = Collections.singleton(DEFAULT_FILTER_NAME_BINDING);
         }
diff --git 
a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ServerProviderFactory.java
 
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ServerProviderFactory.java
index 3ae0728..4e09c24 100644
--- 
a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ServerProviderFactory.java
+++ 
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ServerProviderFactory.java
@@ -219,7 +219,8 @@ public final class ServerProviderFactory extends 
ProviderFactory {
                                                                         
providerCls,
                                                                         
featureProvider,
                                                                         
getBus(),
-                                                                        null,
+                                                                        
getFilterNameBindings(getBus(), 
+                                                                               
               featureProvider),
                                                                         false,
                                                                         
contracts));
                     } else {
@@ -415,7 +416,7 @@ public final class ServerProviderFactory extends 
ProviderFactory {
                             providerCls,
                             provider,
                             getBus(),
-                            nameBinding,
+                            Collections.singleton(nameBinding),
                             true,
                             contracts));
                         
ori.addNameBindings(Collections.singletonList(nameBinding));

-- 
To stop receiving notification emails like this one, please contact
serg...@apache.org.

Reply via email to