cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject git commit: Review all the eclipse warnings produced with the upgrade to Java7 and fix them
Date Tue, 29 Jul 2014 18:33:57 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 9899753a5 -> d391d9371


Review all the eclipse warnings produced with the upgrade to Java7 and fix them


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

Branch: refs/heads/master
Commit: d391d9371d8505c7774308c4fbbb9bc57ffd34a6
Parents: 9899753
Author: Daniel Kulp <dkulp@apache.org>
Authored: Tue Jul 29 14:33:20 2014 -0400
Committer: Daniel Kulp <dkulp@apache.org>
Committed: Tue Jul 29 14:33:20 2014 -0400

----------------------------------------------------------------------
 .../cxf/common/util/ClasspathScanner.java       |  7 ++++--
 .../org/apache/cxf/phase/PhaseChainCache.java   | 25 +++++++++-----------
 .../cxf/aegis/type/java5/AnnotationReader.java  | 24 ++++---------------
 .../org/apache/cxf/jaxrs/impl/MetadataMap.java  |  3 ++-
 .../cxf/ws/rm/soap/RetransmissionQueueImpl.java |  6 ++---
 .../systest/jaxrs/JAXRSLoggingAtomPushTest.java |  2 --
 .../extraction/JAXRSClientServerTikaTest.java   |  1 -
 .../JAXRSClientServerValidationTest.java        |  1 -
 .../cxf/tools/wadlto/jaxrs/WADLToJavaTest.java  |  3 ++-
 9 files changed, 27 insertions(+), 45 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/d391d937/core/src/main/java/org/apache/cxf/common/util/ClasspathScanner.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/common/util/ClasspathScanner.java b/core/src/main/java/org/apache/cxf/common/util/ClasspathScanner.java
index 870e749..ed12b02 100644
--- a/core/src/main/java/org/apache/cxf/common/util/ClasspathScanner.java
+++ b/core/src/main/java/org/apache/cxf/common/util/ClasspathScanner.java
@@ -61,10 +61,12 @@ public class ClasspathScanner {
      * @throws IOException class metadata is not readable 
      * @throws ClassNotFoundException class not found
      */
+    @SafeVarargs
     public static Map< Class< ? extends Annotation >, Collection< Class< ?
> > > findClasses(
         String basePackage, Class< ? extends Annotation > ... annotations) 
         throws IOException, ClassNotFoundException {
-        return findClasses(Collections.singletonList(basePackage), Arrays.asList(annotations));
+        return findClasses(Collections.singletonList(basePackage), 
+                           Collections.unmodifiableList(Arrays.asList(annotations)));
     }
     
     /**
@@ -75,10 +77,11 @@ public class ClasspathScanner {
      * @throws IOException class metadata is not readable 
      * @throws ClassNotFoundException class not found
      */
+    @SafeVarargs
     public static Map< Class< ? extends Annotation >, Collection< Class< ?
> > > findClasses(
         Collection< String > basePackages, Class< ? extends Annotation > ...
annotations) 
         throws IOException, ClassNotFoundException {
-        return findClasses(basePackages, Arrays.asList(annotations));
+        return findClasses(basePackages, Collections.unmodifiableList(Arrays.asList(annotations)));
     }
     
     /**

http://git-wip-us.apache.org/repos/asf/cxf/blob/d391d937/core/src/main/java/org/apache/cxf/phase/PhaseChainCache.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/phase/PhaseChainCache.java b/core/src/main/java/org/apache/cxf/phase/PhaseChainCache.java
index 44541b3..6c17236 100644
--- a/core/src/main/java/org/apache/cxf/phase/PhaseChainCache.java
+++ b/core/src/main/java/org/apache/cxf/phase/PhaseChainCache.java
@@ -39,46 +39,42 @@ import org.apache.cxf.message.Message;
 public final class PhaseChainCache {
     AtomicReference<ChainHolder> lastData = new AtomicReference<ChainHolder>();
     
-    
-    @SuppressWarnings("unchecked")
     public PhaseInterceptorChain get(SortedSet<Phase> phaseList,
                                      List<Interceptor<? extends Message>> p1)
{
-        return getChain(phaseList, p1);
+        return getChain(lastData, phaseList, p1);
     }
 
-    @SuppressWarnings("unchecked")
     public PhaseInterceptorChain get(SortedSet<Phase> phaseList,
                                      List<Interceptor<? extends Message>> p1,
                                      List<Interceptor<? extends Message>> p2)
{
-        return getChain(phaseList, p1, p2);
+        return getChain(lastData, phaseList, p1, p2);
     }
-    @SuppressWarnings("unchecked")
     public PhaseInterceptorChain get(SortedSet<Phase> phaseList,
                                      List<Interceptor<? extends Message>> p1,
                                      List<Interceptor<? extends Message>> p2,
                                      List<Interceptor<? extends Message>> p3)
{
-        return getChain(phaseList, p1, p2, p3);
+        return getChain(lastData, phaseList, p1, p2, p3);
     }
-    @SuppressWarnings("unchecked")
     public PhaseInterceptorChain get(SortedSet<Phase> phaseList,
                                      List<Interceptor<? extends Message>> p1,
                                      List<Interceptor<? extends Message>> p2,
                                      List<Interceptor<? extends Message>> p3,
                                      List<Interceptor<? extends Message>> p4)
{
-        return getChain(phaseList, p1, p2, p3, p4);
+        return getChain(lastData, phaseList, p1, p2, p3, p4);
     }
-    @SuppressWarnings("unchecked")
     public PhaseInterceptorChain get(SortedSet<Phase> phaseList,
                                      List<Interceptor<? extends Message>> p1,
                                      List<Interceptor<? extends Message>> p2,
                                      List<Interceptor<? extends Message>> p3,
                                      List<Interceptor<? extends Message>> p4,
                                      List<Interceptor<? extends Message>> p5)
{
-        return getChain(phaseList, p1, p2, p3, p4, p5);
+        return getChain(lastData, phaseList, p1, p2, p3, p4, p5);
     }
     
-    private PhaseInterceptorChain getChain(SortedSet<Phase> phaseList,
-                                           List<Interceptor<? extends Message>>
... providers) {
+    @SafeVarargs
+    static PhaseInterceptorChain getChain(AtomicReference<ChainHolder> lastData,
+                                          SortedSet<Phase> phaseList,
+                                         List<Interceptor<? extends Message>>
... providers) {
         ChainHolder last = lastData.get();
         
         if (last == null 
@@ -110,7 +106,8 @@ public final class PhaseChainCache {
             chain = c;
         }
         
-        boolean matches(List<Interceptor<? extends Message>> ... providers) {
+        @SafeVarargs
+        final boolean matches(List<Interceptor<? extends Message>> ... providers)
{
             if (lists.size() == providers.length) {
                 for (int x = 0; x < providers.length; x++) {
                     if (lists.get(x).size() != providers[x].size()) {

http://git-wip-us.apache.org/repos/asf/cxf/blob/d391d937/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/java5/AnnotationReader.java
----------------------------------------------------------------------
diff --git a/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/java5/AnnotationReader.java
b/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/java5/AnnotationReader.java
index bf06ed1..56f6a7e 100644
--- a/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/java5/AnnotationReader.java
+++ b/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/java5/AnnotationReader.java
@@ -42,29 +42,24 @@ public class AnnotationReader {
     private static final Class<? extends Annotation> XML_TRANSIENT =
             load("javax.xml.bind.annotation.XmlTransient");
 
-    @SuppressWarnings("unchecked")
     public boolean isIgnored(AnnotatedElement element) {
         return isAnnotationPresent(element,
                 IgnoreProperty.class,
                 XML_TRANSIENT);
     }
 
-    @SuppressWarnings("unchecked")
     public boolean isAttribute(AnnotatedElement element) {
         return isAnnotationPresent(element,
                 XmlAttribute.class,
                 XML_ATTRIBUTE);
     }
 
-    @SuppressWarnings("unchecked")
     public boolean isElement(AnnotatedElement element) {
         return isAnnotationPresent(element,
                 XmlElement.class,
                 XML_ELEMENT);
     }
 
-    // PMD incorrectly identifies this as a string comparison
-    @SuppressWarnings("unchecked")
     public Boolean isNillable(AnnotatedElement element) {
         return Boolean.TRUE.equals(getAnnotationValue("nillable", // NOPMD
                 element,
@@ -72,7 +67,6 @@ public class AnnotationReader {
                 XmlElement.class,
                 XML_ELEMENT));
     }
-    @SuppressWarnings("unchecked")
     public static Boolean isNillable(Annotation[] anns) {
         if (anns == null) {
             return null;
@@ -83,7 +77,6 @@ public class AnnotationReader {
                 XML_ELEMENT);
     }
 
-    @SuppressWarnings("unchecked")
     public Class<?> getType(AnnotatedElement element) {
         Class<?> value = (Class<?>) getAnnotationValue("type",
                 element,
@@ -101,7 +94,6 @@ public class AnnotationReader {
         return value;
     }
 
-    @SuppressWarnings("unchecked")
     public Class<?> getParamType(Method method, int index) {
         return (Class<?>) getAnnotationValue("type",
                 method,
@@ -110,7 +102,6 @@ public class AnnotationReader {
                 XmlParamType.class);
     }
 
-    @SuppressWarnings("unchecked")
     public Class<?> getReturnType(AnnotatedElement element) {
         return (Class<?>) getAnnotationValue("type",
                 element,
@@ -118,7 +109,6 @@ public class AnnotationReader {
                 XmlReturnType.class);
     }
 
-    @SuppressWarnings("unchecked")
     public String getName(AnnotatedElement element) {
         String name = (String) getAnnotationValue("name",
                 element,
@@ -139,7 +129,6 @@ public class AnnotationReader {
         return name;
     }
 
-    @SuppressWarnings("unchecked")
     public String getParamTypeName(Method method, int index) {
         return (String) getAnnotationValue("name",
                 method,
@@ -148,7 +137,6 @@ public class AnnotationReader {
                 XmlParamType.class);
     }
 
-    @SuppressWarnings("unchecked")
     public String getReturnTypeName(AnnotatedElement element) {
         return (String) getAnnotationValue("name",
                 element,
@@ -156,7 +144,6 @@ public class AnnotationReader {
                 XmlReturnType.class);
     }
 
-    @SuppressWarnings("unchecked")
     public String getNamespace(AnnotatedElement element) {
         // some poor class loader implementations may end not define Package elements
         if (element == null) {
@@ -184,7 +171,6 @@ public class AnnotationReader {
         return namespace;
     }
 
-    @SuppressWarnings("unchecked")
     public String getParamNamespace(Method method, int index) {
         String namespace = (String) getAnnotationValue("namespace",
                 method,
@@ -199,7 +185,6 @@ public class AnnotationReader {
         return namespace;
     }
 
-    @SuppressWarnings("unchecked")
     public String getReturnNamespace(AnnotatedElement element) {
         String namespace = (String) getAnnotationValue("namespace",
                 element,
@@ -213,7 +198,6 @@ public class AnnotationReader {
         return namespace;
     }
 
-    @SuppressWarnings("unchecked")
     public int getMinOccurs(AnnotatedElement element) {
         String minOccurs = (String) getAnnotationValue("minOccurs",
                 element,
@@ -231,7 +215,6 @@ public class AnnotationReader {
 
         return 0;
     }
-    @SuppressWarnings("unchecked")
     public static Integer getMinOccurs(Annotation[] anns) {
         if (anns == null) {
             return null;
@@ -250,7 +233,6 @@ public class AnnotationReader {
         }
         return null;
     }
-    @SuppressWarnings("unchecked")
     public boolean isExtensibleElements(AnnotatedElement element, boolean defaultValue) {
         Boolean extensibleElements = (Boolean) getAnnotationValue("extensibleElements",
                 element,
@@ -263,7 +245,6 @@ public class AnnotationReader {
         return extensibleElements;
     }
 
-    @SuppressWarnings("unchecked")
     public boolean isExtensibleAttributes(AnnotatedElement element, boolean defaultValue)
{
         Boolean extensibleAttributes = (Boolean) getAnnotationValue("extensibleAttributes",
                 element,
@@ -276,7 +257,7 @@ public class AnnotationReader {
         return extensibleAttributes;
     }
 
-    // PMD doesn't fully understand varargs
+    @SafeVarargs
     private static boolean isAnnotationPresent(AnnotatedElement element, // NOPMD
             Class<? extends Annotation>... annotations) {
         for (Class<?> annotation : annotations) {
@@ -287,6 +268,7 @@ public class AnnotationReader {
         return false;
     }
 
+    @SafeVarargs
     static Object getAnnotationValue(String name,
             AnnotatedElement element,
             Object ignoredValue,
@@ -311,6 +293,7 @@ public class AnnotationReader {
         }
         return null;
     }
+    @SafeVarargs
     static Object getAnnotationValue(String name,
                                      Annotation[] anns,
                                      Class<? extends Annotation>... annotations) {
@@ -331,6 +314,7 @@ public class AnnotationReader {
         return null;
     }
 
+    @SafeVarargs
     static Object getAnnotationValue(String name,
             Method method,
             int index,

http://git-wip-us.apache.org/repos/asf/cxf/blob/d391d937/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/MetadataMap.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/MetadataMap.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/MetadataMap.java
index d63884d..74df78f 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/MetadataMap.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/MetadataMap.java
@@ -237,7 +237,8 @@ public class MetadataMap<K, V> implements MultivaluedMap<K, V>
{
         
     }
 
-    public void addAll(K key, V... newValues) {
+    @SafeVarargs
+    public final void addAll(K key, V... newValues) {
         this.addAllValues(key, Arrays.asList(newValues));
     }
 

http://git-wip-us.apache.org/repos/asf/cxf/blob/d391d937/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/soap/RetransmissionQueueImpl.java
----------------------------------------------------------------------
diff --git a/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/soap/RetransmissionQueueImpl.java
b/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/soap/RetransmissionQueueImpl.java
index a3a9899..4219392 100644
--- a/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/soap/RetransmissionQueueImpl.java
+++ b/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/soap/RetransmissionQueueImpl.java
@@ -50,7 +50,6 @@ import org.apache.cxf.binding.soap.SoapMessage;
 import org.apache.cxf.binding.soap.SoapVersion;
 import org.apache.cxf.binding.soap.interceptor.SoapOutInterceptor;
 import org.apache.cxf.common.logging.LogUtils;
-import org.apache.cxf.endpoint.ConduitSelector;
 import org.apache.cxf.endpoint.DeferredConduitSelector;
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.helpers.DOMUtils;
@@ -862,7 +861,7 @@ public class RetransmissionQueueImpl implements RetransmissionQueue {
     protected Conduit buildConduit(SoapMessage message, final Endpoint endpoint, AttributedURIType
to) {
         Conduit c;
         final String address = to.getValue();
-        ConduitSelector cs = new DeferredConduitSelector() {
+        DeferredConduitSelector cs = new DeferredConduitSelector() {
             @Override
             public synchronized Conduit selectConduit(Message message) {
                 Conduit conduit = null;
@@ -876,6 +875,7 @@ public class RetransmissionQueueImpl implements RetransmissionQueue {
                 } finally {
                     endpointInfo.setAddress(original);
                 }
+                conduits.clear();
                 return conduit;
             }
         };
@@ -889,7 +889,7 @@ public class RetransmissionQueueImpl implements RetransmissionQueue {
                 LOG.fine("Ignoring response to resent message.");
             }
         });
-        
+        cs.close();
         message.getExchange().setConduit(c);
         return c;
     }

http://git-wip-us.apache.org/repos/asf/cxf/blob/d391d937/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLoggingAtomPushTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLoggingAtomPushTest.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLoggingAtomPushTest.java
index 19025e4..22d144b 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLoggingAtomPushTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLoggingAtomPushTest.java
@@ -67,8 +67,6 @@ public class JAXRSLoggingAtomPushTest extends Assert {
 
     private static Server server;
     
-    
-    @SuppressWarnings("unchecked")
     @BeforeClass
     public static void beforeClass() throws Exception {
         // disable logging for server startup

http://git-wip-us.apache.org/repos/asf/cxf/blob/d391d937/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/extraction/JAXRSClientServerTikaTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/extraction/JAXRSClientServerTikaTest.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/extraction/JAXRSClientServerTikaTest.java
index 3a52067..9d46f12 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/extraction/JAXRSClientServerTikaTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/extraction/JAXRSClientServerTikaTest.java
@@ -133,7 +133,6 @@ public class JAXRSClientServerTikaTest extends AbstractBusClientServerTestBase
{
             .get(Collection.class);
     }
     
-    @SuppressWarnings("unchecked")
     private WebClient createWebClient(final String url) {
         WebClient wc = WebClient.create("http://localhost:" + PORT + url, 
             Arrays.asList(new MultipartProvider(), new JacksonJsonProvider()));

http://git-wip-us.apache.org/repos/asf/cxf/blob/d391d937/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/validation/JAXRSClientServerValidationTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/validation/JAXRSClientServerValidationTest.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/validation/JAXRSClientServerValidationTest.java
index 50e0154..fa43389 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/validation/JAXRSClientServerValidationTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/validation/JAXRSClientServerValidationTest.java
@@ -48,7 +48,6 @@ public class JAXRSClientServerValidationTest extends AbstractJAXRSValidationTest
     public static final String PORT = allocatePort(JAXRSClientServerValidationTest.class);
     @Ignore
     public static class Server extends AbstractBusTestServerBase {        
-        @SuppressWarnings("unchecked")
         protected void run() {
             JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
 

http://git-wip-us.apache.org/repos/asf/cxf/blob/d391d937/tools/wadlto/jaxrs/src/test/java/org/apache/cxf/tools/wadlto/jaxrs/WADLToJavaTest.java
----------------------------------------------------------------------
diff --git a/tools/wadlto/jaxrs/src/test/java/org/apache/cxf/tools/wadlto/jaxrs/WADLToJavaTest.java
b/tools/wadlto/jaxrs/src/test/java/org/apache/cxf/tools/wadlto/jaxrs/WADLToJavaTest.java
index 6f76dca..06a08f8 100644
--- a/tools/wadlto/jaxrs/src/test/java/org/apache/cxf/tools/wadlto/jaxrs/WADLToJavaTest.java
+++ b/tools/wadlto/jaxrs/src/test/java/org/apache/cxf/tools/wadlto/jaxrs/WADLToJavaTest.java
@@ -94,7 +94,7 @@ public class WADLToJavaTest extends ProcessorTestBase {
     }
     
     private List<Class<?>> getSchemaClassFiles() throws Exception {
-        ClassLoader cl = new URLClassLoader(new URL[] {output.toURI().toURL()},
+        URLClassLoader cl = new URLClassLoader(new URL[] {output.toURI().toURL()},
                                             Thread.currentThread().getContextClassLoader());
            
         List<Class<?>> files = new ArrayList<Class<?>>(4);
@@ -102,6 +102,7 @@ public class WADLToJavaTest extends ProcessorTestBase {
         files.add(cl.loadClass("superbooks.Book"));
         files.add(cl.loadClass("superbooks.TheBook2"));
         files.add(cl.loadClass("superbooks.Chapter"));
+        cl.close();
         return files;
     }
 


Mime
View raw message