You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by am...@apache.org on 2017/10/26 20:37:14 UTC

[cxf] branch 3.1.x-fixes updated: [CXF-7537] Use doPriv when calling methods needing Java 2 permissions

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

amccright 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 168ebfd  [CXF-7537] Use doPriv when calling methods needing Java 2 permissions
     new d3505b8  Merge branch '3.1.x-fixes' of github.com:apache/cxf into 3.1.x-fixes
168ebfd is described below

commit 168ebfd2078ee1551cb072b2d9eb8cfbcd94a14c
Author: Andy McCright <j....@gmail.com>
AuthorDate: Wed Oct 25 15:54:15 2017 -0500

    [CXF-7537] Use doPriv when calling methods needing Java 2 permissions
    
    Conflicts:
    rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utilsResourceUtils.java
---
 .../java/org/apache/cxf/io/CachedOutputStream.java |   2 +-
 .../org/apache/cxf/jaxrs/utils/ResourceUtils.java  | 259 ++++++++++-----------
 2 files changed, 129 insertions(+), 132 deletions(-)

diff --git a/core/src/main/java/org/apache/cxf/io/CachedOutputStream.java b/core/src/main/java/org/apache/cxf/io/CachedOutputStream.java
index 780eb6b..7f241b0 100644
--- a/core/src/main/java/org/apache/cxf/io/CachedOutputStream.java
+++ b/core/src/main/java/org/apache/cxf/io/CachedOutputStream.java
@@ -569,7 +569,7 @@ public class CachedOutputStream extends OutputStream {
     
     public static void setDefaultMaxSize(long l) {
         if (l == -1) {
-            String s = System.getProperty("org.apache.cxf.io.CachedOutputStream.MaxSize",
+            String s = SystemPropertyAction.getProperty("org.apache.cxf.io.CachedOutputStream.MaxSize",
                     "-1");
             l = Long.parseLong(s);
         }
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
index 1695c04..e280c89 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
@@ -78,6 +78,7 @@ import org.apache.cxf.common.classloader.ClassLoaderUtils;
 import org.apache.cxf.common.i18n.BundleUtils;
 import org.apache.cxf.common.jaxb.JAXBUtils;
 import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.common.util.ReflectionUtil;
 import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.feature.Feature;
 import org.apache.cxf.helpers.CastUtils;
@@ -105,7 +106,7 @@ import org.apache.cxf.resource.ResourceManager;
 import org.apache.cxf.staxutils.StaxUtils;
 
 public final class ResourceUtils {
-    
+
     private static final Logger LOG = LogUtils.getL7dLogger(ResourceUtils.class);
     private static final ResourceBundle BUNDLE = BundleUtils.getBundle(ResourceUtils.class);
     private static final String CLASSPATH_PREFIX = "classpath:";
@@ -114,7 +115,7 @@ public final class ResourceUtils {
     private static final String NO_VOID_RETURN_ASYNC_MESSAGE_ID = "NO_VOID_RETURN_ASYNC_METHOD";
     private static final Set<String> SERVER_PROVIDER_CLASS_NAMES;
     static {
-        SERVER_PROVIDER_CLASS_NAMES = new HashSet<String>();
+        SERVER_PROVIDER_CLASS_NAMES = new HashSet<>();
         SERVER_PROVIDER_CLASS_NAMES.add("javax.ws.rs.ext.MessageBodyWriter");
         SERVER_PROVIDER_CLASS_NAMES.add("javax.ws.rs.ext.MessageBodyReader");
         SERVER_PROVIDER_CLASS_NAMES.add("javax.ws.rs.ext.ExceptionMapper");
@@ -128,9 +129,8 @@ public final class ResourceUtils {
         SERVER_PROVIDER_CLASS_NAMES.add("javax.ws.rs.core.Feature");
         SERVER_PROVIDER_CLASS_NAMES.add("org.apache.cxf.jaxrs.ext.ContextProvider");
     }
-    
+
     private ResourceUtils() {
-        
     }
     public static Method findPostConstructMethod(Class<?> c) {
         return findPostConstructMethod(c, null);
@@ -139,7 +139,7 @@ public final class ResourceUtils {
         if (Object.class == c || null == c) {
             return null;
         }
-        for (Method m : c.getDeclaredMethods()) {
+        for (Method m : ReflectionUtil.getDeclaredMethods(c)) {
             if (name != null) {
                 if (m.getName().equals(name)) {
                     return m;
@@ -160,16 +160,16 @@ public final class ResourceUtils {
         }
         return null;
     }
-    
+
     public static Method findPreDestroyMethod(Class<?> c) {
         return findPreDestroyMethod(c, null);
     }
-    
+
     public static Method findPreDestroyMethod(Class<?> c, String name) {
         if (Object.class == c || null == c) {
             return null;
         }
-        for (Method m : c.getDeclaredMethods()) {
+        for (Method m : ReflectionUtil.getDeclaredMethods(c)) {
             if (name != null) {
                 if (m.getName().equals(name)) {
                     return m;
@@ -190,7 +190,7 @@ public final class ResourceUtils {
         }
         return null;
     }
-    
+
     public static ClassResourceInfo createClassResourceInfo(
         Map<String, UserResource> resources, UserResource model,
         Class<?> defaultClass,
@@ -200,7 +200,7 @@ public final class ResourceUtils {
         Class<?> sClass = !isDefaultClass  ? loadClass(model.getName()) : defaultClass;
         return createServiceClassResourceInfo(resources, model, sClass, isRoot, enableStatic, bus);
     }
-    
+
     public static ClassResourceInfo createServiceClassResourceInfo(
         Map<String, UserResource> resources, UserResource model, 
         Class<?> sClass, boolean isRoot, boolean enableStatic, Bus bus) {
@@ -212,12 +212,12 @@ public final class ResourceUtils {
                                   model.getConsumes(), model.getProduces(), bus);
         URITemplate t = URITemplate.createTemplate(model.getPath());
         cri.setURITemplate(t);
-        
+
         MethodDispatcher md = new MethodDispatcher();
         Map<String, UserOperation> ops = model.getOperationsAsMap();
-        
+
         Method defaultMethod = null;
-        Map<String, Method> methodNames = new HashMap<String, Method>();
+        Map<String, Method> methodNames = new HashMap<>();
         for (Method m : cri.getServiceClass().getMethods()) {
             if (m.getAnnotation(DefaultMethod.class) != null) {
                 // if needed we can also support multiple default methods
@@ -225,7 +225,7 @@ public final class ResourceUtils {
             }
             methodNames.put(m.getName(), m);
         }
-        
+
         for (Map.Entry<String, UserOperation> entry : ops.entrySet()) {
             UserOperation op = entry.getValue();
             Method actualMethod = methodNames.get(op.getName());
@@ -255,32 +255,32 @@ public final class ResourceUtils {
                 md.bind(ori, actualMethod);
             }
         }
-        
+
         cri.setMethodDispatcher(md);
         return checkMethodDispatcher(cri) ? cri : null;
 
     }
-    
-    public static ClassResourceInfo createClassResourceInfo(final Class<?> rClass, 
+
+    public static ClassResourceInfo createClassResourceInfo(final Class<?> rClass,
                                                             final Class<?> sClass,
-                                                            boolean root, 
+                                                            boolean root,
                                                             boolean enableStatic) {
         return createClassResourceInfo(rClass, sClass, root, enableStatic, BusFactory.getThreadDefaultBus());
-        
+
     }
-    
-    public static ClassResourceInfo createClassResourceInfo(final Class<?> rClass, 
+
+    public static ClassResourceInfo createClassResourceInfo(final Class<?> rClass,
                                                             final Class<?> sClass,
-                                                            boolean root, 
+                                                            boolean root,
                                                             boolean enableStatic,
                                                             Bus bus) {
         return createClassResourceInfo(rClass, sClass, null, root, enableStatic, bus);
     }
-    
-    public static ClassResourceInfo createClassResourceInfo(final Class<?> rClass, 
+
+    public static ClassResourceInfo createClassResourceInfo(final Class<?> rClass,
                                                             final Class<?> sClass,
                                                             ClassResourceInfo parent,
-                                                            boolean root, 
+                                                            boolean root,
                                                             boolean enableStatic,
                                                             Bus bus) {
         ClassResourceInfo cri = new ClassResourceInfo(rClass, sClass, root, enableStatic, bus);
@@ -290,7 +290,7 @@ public final class ResourceUtils {
             URITemplate t = URITemplate.createTemplate(cri.getPath());
             cri.setURITemplate(t);
         }
-        
+
         evaluateResourceClass(cri, enableStatic);
         return checkMethodDispatcher(cri) ? cri : null;
     }
@@ -298,14 +298,14 @@ public final class ResourceUtils {
     private static void evaluateResourceClass(ClassResourceInfo cri, boolean enableStatic) {
         MethodDispatcher md = new MethodDispatcher();
         Class<?> serviceClass = cri.getServiceClass();
-        
+
         for (Method m : serviceClass.getMethods()) {
-            
+
             Method annotatedMethod = AnnotationUtils.getAnnotatedMethod(serviceClass, m);
-            
+
             String httpMethod = AnnotationUtils.getHttpMethodValue(annotatedMethod);
             Path path = AnnotationUtils.getMethodAnnotation(annotatedMethod, Path.class);
-            
+
             if (httpMethod != null || path != null) {
                 if (!checkAsyncResponse(annotatedMethod)) {
                     continue;
@@ -326,7 +326,7 @@ public final class ResourceUtils {
                                      : createClassResourceInfo(subClass, subClass, cri, false, enableStatic,
                                                                cri.getBus());
                         }
-                        
+
                         if (subCri != null) {
                             cri.addSubClassResourceInfo(subCri);
                         }
@@ -376,7 +376,7 @@ public final class ResourceUtils {
         }
         return getAncestorWithSameServiceClass(parent.getParent(), subClass);
     }
-    
+
     public static Constructor<?> findResourceConstructor(Class<?> resourceClass, boolean perRequest) {
         List<Constructor<?>> cs = new LinkedList<Constructor<?>>();
         for (Constructor<?> c : resourceClass.getConstructors()) {
@@ -405,46 +405,46 @@ public final class ResourceUtils {
                 int p2 = c2.getParameterTypes().length;
                 return p1 > p2 ? -1 : p1 < p2 ? 1 : 0;
             }
-        
+
         });
         return cs.size() == 0 ? null : cs.get(0);
     }
-    
+
     public static List<Parameter> getParameters(Method resourceMethod) {
         Annotation[][] paramAnns = resourceMethod.getParameterAnnotations();
         if (paramAnns.length == 0) {
             return CastUtils.cast(Collections.emptyList(), Parameter.class);
         }
         Class<?>[] types = resourceMethod.getParameterTypes();
-        List<Parameter> params = new ArrayList<Parameter>(paramAnns.length);
+        List<Parameter> params = new ArrayList<>(paramAnns.length);
         for (int i = 0; i < paramAnns.length; i++) {
             Parameter p = getParameter(i, paramAnns[i], types[i]);
             params.add(p);
         }
         return params;
     }
-    
+
     //CHECKSTYLE:OFF
     public static Parameter getParameter(int index, Annotation[] anns, Class<?> type) {
-        
+
         Context ctx = AnnotationUtils.getAnnotation(anns, Context.class);
         if (ctx != null) {
             return new Parameter(ParameterType.CONTEXT, index, null);
         }
-        
+
         boolean isEncoded = AnnotationUtils.getAnnotation(anns, Encoded.class) != null;
-        
+
         BeanParam bp = AnnotationUtils.getAnnotation(anns, BeanParam.class);
         if (bp != null) {
             return new Parameter(ParameterType.BEAN, index, null, isEncoded, null);
         }
-        
+
         String dValue = AnnotationUtils.getDefaultParameterValue(anns);
-        
-        PathParam a = AnnotationUtils.getAnnotation(anns, PathParam.class); 
+
+        PathParam a = AnnotationUtils.getAnnotation(anns, PathParam.class);
         if (a != null) {
             return new Parameter(ParameterType.PATH, index, a.value(), isEncoded, dValue);
-        } 
+        }
         QueryParam q = AnnotationUtils.getAnnotation(anns, QueryParam.class);
         if (q != null) {
             return new Parameter(ParameterType.QUERY, index, q.value(), isEncoded, dValue);
@@ -452,29 +452,29 @@ public final class ResourceUtils {
         MatrixParam m = AnnotationUtils.getAnnotation(anns, MatrixParam.class);
         if (m != null) {
             return new Parameter(ParameterType.MATRIX, index, m.value(), isEncoded, dValue);
-        }  
-    
+        }
+
         FormParam f = AnnotationUtils.getAnnotation(anns, FormParam.class);
         if (f != null) {
             return new Parameter(ParameterType.FORM, index, f.value(), isEncoded, dValue);
         }
-        
+
         HeaderParam h = AnnotationUtils.getAnnotation(anns, HeaderParam.class);
         if (h != null) {
             return new Parameter(ParameterType.HEADER, index, h.value(), isEncoded, dValue);
-        }  
-        
+        }
+
         CookieParam c = AnnotationUtils.getAnnotation(anns, CookieParam.class);
         if (c != null) {
             return new Parameter(ParameterType.COOKIE, index, c.value(), isEncoded, dValue);
         }
-        
-        return new Parameter(ParameterType.REQUEST_BODY, index, null); 
-        
+
+        return new Parameter(ParameterType.REQUEST_BODY, index, null);
+
     }
     //CHECKSTYLE:ON
-    
-    private static OperationResourceInfo createOperationInfo(Method m, Method annotatedMethod, 
+
+    private static OperationResourceInfo createOperationInfo(Method m, Method annotatedMethod,
                                                       ClassResourceInfo cri, Path path, String httpMethod) {
         OperationResourceInfo ori = new OperationResourceInfo(m, annotatedMethod, cri);
         URITemplate t = URITemplate.createTemplate(path);
@@ -482,18 +482,17 @@ public final class ResourceUtils {
         ori.setHttpMethod(httpMethod);
         return ori;
     }
-    
-       
+
+
     private static boolean checkMethodDispatcher(ClassResourceInfo cr) {
         if (cr.getMethodDispatcher().getOperationResourceInfos().isEmpty()) {
-            LOG.warning(new org.apache.cxf.common.i18n.Message("NO_RESOURCE_OP_EXC", 
-                                                               BUNDLE, 
+            LOG.warning(new org.apache.cxf.common.i18n.Message("NO_RESOURCE_OP_EXC",
+                                                               BUNDLE,
                                                                cr.getServiceClass().getName()).toString());
             return false;
         }
         return true;
     }
-    
 
     private static Class<?> loadClass(String cName) {
         try {
@@ -502,8 +501,8 @@ public final class ResourceUtils {
             throw new RuntimeException("No class " + cName.trim() + " can be found", ex); 
         }
     }
-    
-    
+
+
     public static List<UserResource> getUserResources(String loc, Bus bus) {
         try {
             InputStream is = ResourceUtils.getResourceStream(loc, bus);
@@ -514,15 +513,15 @@ public final class ResourceUtils {
         } catch (Exception ex) {
             LOG.warning("Problem with processing a user model at " + loc);
         }
-        
+
         return null;
     }
-    
+
     public static InputStream getResourceStream(String loc, Bus bus) throws Exception {
         URL url = getResourceURL(loc, bus);
         return url == null ? null : url.openStream();
     }
-    
+
     public static URL getResourceURL(String loc, Bus bus) throws Exception {
         URL url = null;
         if (loc.startsWith(CLASSPATH_PREFIX)) {
@@ -547,17 +546,17 @@ public final class ResourceUtils {
         }
         return url;
     }
-    
+
     public static InputStream getClasspathResourceStream(String path, Class<?> callingClass, Bus bus) {
         InputStream is = ClassLoaderUtils.getResourceAsStream(path, callingClass);
         return is == null ? getResource(path, InputStream.class, bus) : is;
     }
-    
+
     public static URL getClasspathResourceURL(String path, Class<?> callingClass, Bus bus) {
         URL url = ClassLoaderUtils.getResource(path, callingClass);
         return url == null ? getResource(path, URL.class, bus) : url;
     }
-    
+
     public static <T> T getResource(String path, Class<T> resourceClass, Bus bus) {
         if (bus != null) {
             ResourceManager rm = bus.getExtension(ResourceManager.class);
@@ -567,41 +566,41 @@ public final class ResourceUtils {
         }
         return null;
     }
-    
+
     public static Properties loadProperties(String propertiesLocation, Bus bus) throws Exception {
         Properties props = new Properties();
         InputStream is = getResourceStream(propertiesLocation, bus);
         props.load(is);
         return props;
     }
-    
+
     public static List<UserResource> getUserResources(String loc) {
         return getUserResources(loc, BusFactory.getThreadDefaultBus());
     }
-    
+
     public static List<UserResource> getUserResources(InputStream is) throws Exception {
         Document doc = StaxUtils.read(new InputStreamReader(is, StandardCharsets.UTF_8));
         return getResourcesFromElement(doc.getDocumentElement());
     }
-    
+
     public static List<UserResource> getResourcesFromElement(Element modelEl) {
-        List<UserResource> resources = new ArrayList<UserResource>();
-        List<Element> resourceEls = 
-            DOMUtils.findAllElementsByTagNameNS(modelEl, 
+        List<UserResource> resources = new ArrayList<>();
+        List<Element> resourceEls =
+            DOMUtils.findAllElementsByTagNameNS(modelEl,
                                                 "http://cxf.apache.org/jaxrs", "resource");
         for (Element e : resourceEls) {
             resources.add(getResourceFromElement(e));
         }
         return resources;
     }
-    
 
-    public static ResourceTypes getAllRequestResponseTypes(List<ClassResourceInfo> cris, 
+
+    public static ResourceTypes getAllRequestResponseTypes(List<ClassResourceInfo> cris,
                                                            boolean jaxbOnly) {
         return getAllRequestResponseTypes(cris, jaxbOnly, null);
     }
-    
-    public static ResourceTypes getAllRequestResponseTypes(List<ClassResourceInfo> cris, 
+
+    public static ResourceTypes getAllRequestResponseTypes(List<ClassResourceInfo> cris,
                                                            boolean jaxbOnly,
                                                            MessageBodyWriter<?> jaxbWriter) {
         ResourceTypes types = new ResourceTypes();
@@ -621,8 +620,8 @@ public final class ResourceUtils {
         }
         return type;
     }
-    
-    private static void getAllTypesForResource(ClassResourceInfo resource, 
+
+    private static void getAllTypesForResource(ClassResourceInfo resource,
                                                ResourceTypes types,
                                                boolean jaxbOnly,
                                                MessageBodyWriter<?> jaxbWriter) {
@@ -640,7 +639,7 @@ public final class ResourceUtils {
             } else {
                 types.getAllTypes().put(cls, type);
             }
-            
+
             for (Parameter pm : ori.getParameters()) {
                 if (pm.getType() == ParameterType.REQUEST_BODY) {
                     Class<?> inType = method.getParameterTypes()[pm.getIndex()];
@@ -655,16 +654,16 @@ public final class ResourceUtils {
                     }
                 }
             }
-            
+
         }
-        
+
         for (ClassResourceInfo sub : resource.getSubResources()) {
             if (!isRecursiveSubResource(resource, sub)) {
                 getAllTypesForResource(sub, types, jaxbOnly, jaxbWriter);
             }
         }
     }
-    
+
     private static boolean isRecursiveSubResource(ClassResourceInfo parent, ClassResourceInfo sub) {
         if (parent == null) {
             return false;
@@ -674,10 +673,10 @@ public final class ResourceUtils {
         }
         return isRecursiveSubResource(parent.getParent(), sub);
     }
-    
+
     private static void checkJaxbType(Class<?> serviceClass,
-                                      Class<?> type, 
-                                      Type genericType, 
+                                      Class<?> type,
+                                      Type genericType,
                                       ResourceTypes types,
                                       Annotation[] anns,
                                       MessageBodyWriter<?> jaxbWriter) {
@@ -687,7 +686,7 @@ public final class ResourceUtils {
             isCollection = true;
         }
         if (type == Object.class && !(genericType instanceof Class)) {
-            Type theType = InjectionUtils.processGenericTypeIfNeeded(serviceClass, 
+            Type theType = InjectionUtils.processGenericTypeIfNeeded(serviceClass,
                                                       Object.class,
                                                       genericType);
             type = InjectionUtils.getActualType(theType);
@@ -699,7 +698,7 @@ public final class ResourceUtils {
             || type.isInterface()) {
             return;
         }
-        
+
         MessageBodyWriter<?> writer = jaxbWriter;
         if (writer == null) {
             JAXBElementProvider<Object> defaultWriter = new JAXBElementProvider<Object>();
@@ -710,11 +709,11 @@ public final class ResourceUtils {
         if (writer.isWriteable(type, type, anns, MediaType.APPLICATION_XML_TYPE)) {
             types.getAllTypes().put(type, type);
             Class<?> genCls = InjectionUtils.getActualType(genericType);
-            if (genCls != type && genCls != null && genCls != Object.class 
+            if (genCls != type && genCls != null && genCls != Object.class
                 && !InjectionUtils.isSupportedCollectionOrArray(genCls)) {
                 types.getAllTypes().put(genCls, genCls);
             }
-            
+
             XMLName name = AnnotationUtils.getAnnotation(anns, XMLName.class);
             QName qname = name != null ? JAXRSUtils.convertStringToQName(name.value()) : null;
             if (isCollection) {
@@ -724,24 +723,24 @@ public final class ResourceUtils {
             }
         }
     }
-    
+
     private static UserResource getResourceFromElement(Element e) {
         UserResource resource = new UserResource();
         resource.setName(e.getAttribute("name"));
         resource.setPath(e.getAttribute("path"));
         resource.setConsumes(e.getAttribute("consumes"));
         resource.setProduces(e.getAttribute("produces"));
-        List<Element> operEls = 
-            DOMUtils.findAllElementsByTagNameNS(e, 
+        List<Element> operEls =
+            DOMUtils.findAllElementsByTagNameNS(e,
                  "http://cxf.apache.org/jaxrs", "operation");
-        List<UserOperation> opers = new ArrayList<UserOperation>(operEls.size());
+        List<UserOperation> opers = new ArrayList<>(operEls.size());
         for (Element operEl : operEls) {
             opers.add(getOperationFromElement(operEl));
         }
         resource.setOperations(opers);
         return resource;
     }
-    
+
     private static UserOperation getOperationFromElement(Element e) {
         UserOperation op = new UserOperation();
         op.setName(e.getAttribute("name"));
@@ -750,10 +749,10 @@ public final class ResourceUtils {
         op.setOneway(Boolean.parseBoolean(e.getAttribute("oneway")));
         op.setConsumes(e.getAttribute("consumes"));
         op.setProduces(e.getAttribute("produces"));
-        List<Element> paramEls = 
-            DOMUtils.findAllElementsByTagNameNS(e, 
+        List<Element> paramEls =
+            DOMUtils.findAllElementsByTagNameNS(e,
                  "http://cxf.apache.org/jaxrs", "param");
-        List<Parameter> params = new ArrayList<Parameter>(paramEls.size());
+        List<Parameter> params = new ArrayList<>(paramEls.size());
         for (int i = 0; i < paramEls.size(); i++) {
             Element paramEl = paramEls.get(i);
             Parameter p = new Parameter(paramEl.getAttribute("type"), i, paramEl.getAttribute("name"));
@@ -761,7 +760,7 @@ public final class ResourceUtils {
             p.setDefaultValue(paramEl.getAttribute("defaultValue"));
             String pClass = paramEl.getAttribute("class");
             if (!StringUtils.isEmpty(pClass)) {
-                try { 
+                try {
                     p.setJavaType(ClassLoaderUtils.loadClass(pClass, ResourceUtils.class));
                 } catch (Exception ex) {
                     throw new RuntimeException(ex);
@@ -772,15 +771,15 @@ public final class ResourceUtils {
         op.setParameters(params);
         return op;
     }
-    
-    public static Object[] createConstructorArguments(Constructor<?> c, 
-                                                      Message m, 
+
+    public static Object[] createConstructorArguments(Constructor<?> c,
+                                                      Message m,
                                                       boolean perRequest) {
         return createConstructorArguments(c, m, perRequest, null);
     }
-    
-    public static Object[] createConstructorArguments(Constructor<?> c, 
-                                                      Message m, 
+
+    public static Object[] createConstructorArguments(Constructor<?> c,
+                                                      Message m,
                                                       boolean perRequest,
                                                       Map<Class<?>, Object> contextValues) {
         if (m == null) {
@@ -825,12 +824,12 @@ public final class ResourceUtils {
 
         Set<Object> singletons = app.getSingletons();
         verifySingletons(singletons);
-        
+
         List<Class<?>> resourceClasses = new ArrayList<Class<?>>();
-        List<Object> providers = new ArrayList<Object>();
-        List<Feature> features = new ArrayList<Feature>();
-        Map<Class<?>, ResourceProvider> map = new HashMap<Class<?>, ResourceProvider>();
-        
+        List<Object> providers = new ArrayList<>();
+        List<Feature> features = new ArrayList<>();
+        Map<Class<?>, ResourceProvider> map = new HashMap<>();
+
         // Note, app.getClasses() returns a list of per-request classes
         // or singleton provider classes
         for (Class<?> cls : app.getClasses()) {
@@ -849,8 +848,8 @@ public final class ResourceUtils {
                 }
             }
         }
-        
-        // we can get either a provider or resource class here        
+
+        // we can get either a provider or resource class here
         for (Object o : singletons) {
             if (isValidProvider(o.getClass())) {
                 providers.add(o);
@@ -861,7 +860,7 @@ public final class ResourceUtils {
                 map.put(o.getClass(), new SingletonResourceProvider(o));
             }
         }
-        
+
         JAXRSServerFactoryBean bean = new JAXRSServerFactoryBean();
         if (bus != null) {
             bean.setBus(bus);
@@ -890,7 +889,7 @@ public final class ResourceUtils {
             bean.getProperties(true).putAll(appProps);
         }
         bean.setApplication(app);
-        
+
         return bean;
     }
     public static Object createProviderInstance(Class<?> cls) {
@@ -898,28 +897,27 @@ public final class ResourceUtils {
             Constructor<?> c = ResourceUtils.findResourceConstructor(cls, false);
             if (c.getParameterTypes().length == 0) {
                 return c.newInstance();
-            } else {
-                return c;
             }
+            return c;
         } catch (Throwable ex) {
-            throw new RuntimeException("Provider " + cls.getName() + " can not be created", ex); 
+            throw new RuntimeException("Provider " + cls.getName() + " can not be created", ex);
         }
     }
-    
+
     public static Feature createFeatureInstance(Class<? extends Feature> cls) {
         try {
             Constructor<?> c = ResourceUtils.findResourceConstructor(cls, false);
-            
+
             if (c == null) {
                 throw new RuntimeException("No valid constructor found for " + cls.getName());
             }
-            
+
             return (Feature) c.newInstance();
         } catch (Throwable ex) {
-            throw new RuntimeException("Feature " + cls.getName() + " can not be created", ex); 
+            throw new RuntimeException("Feature " + cls.getName() + " can not be created", ex);
         }
     }
-    
+
     private static boolean isValidProvider(Class<?> c) {
         if (c == null || c == Object.class) {
             return false;
@@ -927,29 +925,28 @@ public final class ResourceUtils {
         if (c.getAnnotation(Provider.class) != null) {
             return true;
         }
-        for (Class<?> itf : c.getInterfaces()) {    
+        for (Class<?> itf : c.getInterfaces()) {
             if (SERVER_PROVIDER_CLASS_NAMES.contains(itf.getName())) {
                 return true;
             }
         }
         return isValidProvider(c.getSuperclass());
     }
-    
+
     private static void verifySingletons(Set<Object> singletons) {
         if (singletons.isEmpty()) {
             return;
         }
-        Set<String> map = new HashSet<String>(); 
+        Set<String> map = new HashSet<>();
         for (Object s : singletons) {
             if (map.contains(s.getClass().getName())) {
                 throw new RuntimeException("More than one instance of the same singleton class "
-                                           + s.getClass().getName() + " is available"); 
-            } else {
-                map.add(s.getClass().getName());
+                                           + s.getClass().getName() + " is available");
             }
+            map.add(s.getClass().getName());
         }
     }
-    
+
     public static boolean isValidResourceClass(Class<?> c) {
         if (c.isInterface() || Modifier.isAbstract(c.getModifiers())) {
             LOG.info("Ignoring invalid resource class " + c.getName());
@@ -981,7 +978,7 @@ public final class ResourceUtils {
     }
 
     //TODO : consider moving JAXBDataBinding.createContext to JAXBUtils
-    public static JAXBContext createJaxbContext(Set<Class<?>> classes, Class<?>[] extraClass, 
+    public static JAXBContext createJaxbContext(Set<Class<?>> classes, Class<?>[] extraClass,
                                           Map<String, Object> contextProperties) {
         if (classes == null || classes.isEmpty()) {
             return null;
@@ -998,5 +995,5 @@ public final class ResourceUtils {
         }
         return null;
     }
-                                         
+
 }

-- 
To stop receiving notification emails like this one, please contact
['"commits@cxf.apache.org" <co...@cxf.apache.org>'].