cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject [04/30] cxf git commit: Some issues in the core identified by findbugs
Date Sun, 04 Dec 2016 01:11:46 GMT
Some issues in the core identified by findbugs


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

Branch: refs/heads/CXF-6882.nio
Commit: 8a605be6dbf7810252cc60a4dc44b6fac7d2e2f9
Parents: dc28879
Author: Colm O hEigeartaigh <coheigea@apache.org>
Authored: Thu Nov 24 11:41:56 2016 +0000
Committer: Colm O hEigeartaigh <coheigea@apache.org>
Committed: Thu Nov 24 11:42:14 2016 +0000

----------------------------------------------------------------------
 .../apache/cxf/attachment/AttachmentUtil.java   |  4 ++--
 .../cxf/attachment/ContentDisposition.java      |  2 +-
 .../jaxb/SchemaCollectionContextProxy.java      |  7 +++---
 .../apache/cxf/common/security/SimpleGroup.java |  2 +-
 .../AbstractBPBeanDefinitionParser.java         |  9 ++++----
 .../databinding/source/XMLStreamDataReader.java |  2 +-
 .../apache/cxf/feature/FastInfosetFeature.java  | 12 +++++-----
 .../transform/AbstractXSLTInterceptor.java      |  8 +++----
 .../java/org/apache/cxf/helpers/FileUtils.java  | 23 +++++++++++---------
 .../staxutils/PrettyPrintXMLStreamWriter.java   |  2 +-
 .../org/apache/cxf/staxutils/StaxUtils.java     | 10 ++++-----
 11 files changed, 42 insertions(+), 39 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/8a605be6/core/src/main/java/org/apache/cxf/attachment/AttachmentUtil.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/attachment/AttachmentUtil.java b/core/src/main/java/org/apache/cxf/attachment/AttachmentUtil.java
index 5950d6c..79af3b1 100644
--- a/core/src/main/java/org/apache/cxf/attachment/AttachmentUtil.java
+++ b/core/src/main/java/org/apache/cxf/attachment/AttachmentUtil.java
@@ -176,7 +176,7 @@ public final class AttachmentUtil {
             if (threshold instanceof Long) {
                 bos.setThreshold((Long)threshold);
             } else {
-                bos.setThreshold(Long.valueOf((String)threshold));
+                bos.setThreshold(Long.parseLong((String)threshold));
             }
         } else {
             bos.setThreshold(AttachmentDeserializer.THRESHOLD);
@@ -187,7 +187,7 @@ public final class AttachmentUtil {
             if (maxSize instanceof Long) {
                 bos.setMaxSize((Long) maxSize);
             } else {
-                bos.setMaxSize(Long.valueOf((String)maxSize));
+                bos.setMaxSize(Long.parseLong((String)maxSize));
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/cxf/blob/8a605be6/core/src/main/java/org/apache/cxf/attachment/ContentDisposition.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/attachment/ContentDisposition.java b/core/src/main/java/org/apache/cxf/attachment/ContentDisposition.java
index 9ce30e9..2632e57 100644
--- a/core/src/main/java/org/apache/cxf/attachment/ContentDisposition.java
+++ b/core/src/main/java/org/apache/cxf/attachment/ContentDisposition.java
@@ -103,7 +103,7 @@ public class ContentDisposition {
                 while (matcher.find()) {
                     String matched = matcher.group();
                     if (matched.startsWith("&#")) {
-                        int codePoint = Integer.valueOf(matched.substring(2, 6));
+                        int codePoint = Integer.parseInt(matched.substring(2, 6));
                         sb.append(Character.toChars(codePoint));
                     } else {
                         sb.append(matched.charAt(0));

http://git-wip-us.apache.org/repos/asf/cxf/blob/8a605be6/core/src/main/java/org/apache/cxf/common/jaxb/SchemaCollectionContextProxy.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/common/jaxb/SchemaCollectionContextProxy.java
b/core/src/main/java/org/apache/cxf/common/jaxb/SchemaCollectionContextProxy.java
index c5e7d65..5091235 100644
--- a/core/src/main/java/org/apache/cxf/common/jaxb/SchemaCollectionContextProxy.java
+++ b/core/src/main/java/org/apache/cxf/common/jaxb/SchemaCollectionContextProxy.java
@@ -126,10 +126,11 @@ public class SchemaCollectionContextProxy implements JAXBContextProxy
{
 
     public Object getBeanInfo(Class<?> cls) {
         Class<?> origCls = cls;
-        String postfix = "";
+        StringBuilder postfix = new StringBuilder();
+        postfix.append("");
         while (cls.isArray()) {
             cls = cls.getComponentType();
-            postfix += "Array";
+            postfix.append("Array");
         }
         XmlRootElement xre = cls.getAnnotation(XmlRootElement.class);
         String name = xre == null ? "##default" : xre.name();
@@ -149,7 +150,7 @@ public class SchemaCollectionContextProxy implements JAXBContextProxy
{
                 namespace = defaultNamespace;
             }
         }
-        final QName qname = new QName(namespace, name + postfix);
+        final QName qname = new QName(namespace, name + postfix.toString());
         final XmlSchemaElement el = schemas.getElementByQName(qname);
         XmlSchemaType type = null;
         if (el != null) {

http://git-wip-us.apache.org/repos/asf/cxf/blob/8a605be6/core/src/main/java/org/apache/cxf/common/security/SimpleGroup.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/common/security/SimpleGroup.java b/core/src/main/java/org/apache/cxf/common/security/SimpleGroup.java
index 1d39a5e..73b0d5c 100644
--- a/core/src/main/java/org/apache/cxf/common/security/SimpleGroup.java
+++ b/core/src/main/java/org/apache/cxf/common/security/SimpleGroup.java
@@ -82,7 +82,7 @@ public class SimpleGroup extends SimplePrincipal implements Group {
             return false;
         }
         SimpleGroup other = (SimpleGroup)obj;
-        return getName().equals(other.getName()) && members.equals(other.members);
+        return members.equals(other.members) && super.equals(obj);
     }
     
     public int hashCode() {

http://git-wip-us.apache.org/repos/asf/cxf/blob/8a605be6/core/src/main/java/org/apache/cxf/configuration/blueprint/AbstractBPBeanDefinitionParser.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/configuration/blueprint/AbstractBPBeanDefinitionParser.java
b/core/src/main/java/org/apache/cxf/configuration/blueprint/AbstractBPBeanDefinitionParser.java
index 1e34cf0..8b83053 100644
--- a/core/src/main/java/org/apache/cxf/configuration/blueprint/AbstractBPBeanDefinitionParser.java
+++ b/core/src/main/java/org/apache/cxf/configuration/blueprint/AbstractBPBeanDefinitionParser.java
@@ -336,12 +336,11 @@ public abstract class AbstractBPBeanDefinitionParser {
         public Object createJAXBBean(String v) {
             XMLStreamReader reader = StaxUtils.createXMLStreamReader(new StringReader(v));
             try {
-                Object o = JAXBUtils.unmarshall(ctx, reader, cls);
-                if (o instanceof JAXBElement<?>) {
-                    JAXBElement<?> el = (JAXBElement<?>)o;
-                    o = el.getValue();
+                JAXBElement<?> el = JAXBUtils.unmarshall(ctx, reader, cls);
+                if (el != null) {
+                    return el.getValue();
                 }
-                return o;
+                return null;
             } catch (JAXBException e) {
                 throw new RuntimeException(e);
             } finally {

http://git-wip-us.apache.org/repos/asf/cxf/blob/8a605be6/core/src/main/java/org/apache/cxf/databinding/source/XMLStreamDataReader.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/databinding/source/XMLStreamDataReader.java
b/core/src/main/java/org/apache/cxf/databinding/source/XMLStreamDataReader.java
index 092a841..5e1a056 100644
--- a/core/src/main/java/org/apache/cxf/databinding/source/XMLStreamDataReader.java
+++ b/core/src/main/java/org/apache/cxf/databinding/source/XMLStreamDataReader.java
@@ -316,7 +316,7 @@ public class XMLStreamDataReader implements DataReader<XMLStreamReader>
{
         }
     }
     
-    class NUllOutputStream extends OutputStream {
+    static class NUllOutputStream extends OutputStream {
         public void write(byte[] b, int off, int len) {
         }
         public void write(int b) {

http://git-wip-us.apache.org/repos/asf/cxf/blob/8a605be6/core/src/main/java/org/apache/cxf/feature/FastInfosetFeature.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/feature/FastInfosetFeature.java b/core/src/main/java/org/apache/cxf/feature/FastInfosetFeature.java
index 38cc159..91bdc74 100644
--- a/core/src/main/java/org/apache/cxf/feature/FastInfosetFeature.java
+++ b/core/src/main/java/org/apache/cxf/feature/FastInfosetFeature.java
@@ -59,24 +59,24 @@ public class FastInfosetFeature extends AbstractFeature {
 
         FIStaxOutInterceptor out = new FIStaxOutInterceptor(force);
         if (serializerAttributeValueMapMemoryLimit != null && serializerAttributeValueMapMemoryLimit.intValue()
> 0) {
-            out.setSerializerAttributeValueMapMemoryLimit(serializerAttributeValueMapMemoryLimit.intValue());
+            out.setSerializerAttributeValueMapMemoryLimit(serializerAttributeValueMapMemoryLimit);
         }
         if (serializerMinAttributeValueSize != null && serializerMinAttributeValueSize.intValue()
> 0) {
-            out.setSerializerMinAttributeValueSize(serializerMinAttributeValueSize.intValue());
+            out.setSerializerMinAttributeValueSize(serializerMinAttributeValueSize);
         }
         if (serializerMaxAttributeValueSize != null && serializerMaxAttributeValueSize.intValue()
> 0) {
-            out.setSerializerMaxAttributeValueSize(serializerMaxAttributeValueSize.intValue());
+            out.setSerializerMaxAttributeValueSize(serializerMaxAttributeValueSize);
         }
         if (serializerCharacterContentChunkMapMemoryLimit != null
                 && serializerCharacterContentChunkMapMemoryLimit.intValue() >
0) {
             out.setSerializerCharacterContentChunkMapMemoryLimit(
-                    serializerCharacterContentChunkMapMemoryLimit.intValue());
+                    serializerCharacterContentChunkMapMemoryLimit);
         }
         if (serializerMinCharacterContentChunkSize != null && serializerMinCharacterContentChunkSize.intValue()
> 0) {
-            out.setSerializerMinCharacterContentChunkSize(serializerMinCharacterContentChunkSize.intValue());
+            out.setSerializerMinCharacterContentChunkSize(serializerMinCharacterContentChunkSize);
         }
         if (serializerMaxCharacterContentChunkSize != null && serializerMaxCharacterContentChunkSize.intValue()
> 0) {
-            out.setSerializerMaxCharacterContentChunkSize(serializerMaxCharacterContentChunkSize.intValue());
+            out.setSerializerMaxCharacterContentChunkSize(serializerMaxCharacterContentChunkSize);
         }
         
         provider.getInInterceptors().add(in);

http://git-wip-us.apache.org/repos/asf/cxf/blob/8a605be6/core/src/main/java/org/apache/cxf/feature/transform/AbstractXSLTInterceptor.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/feature/transform/AbstractXSLTInterceptor.java
b/core/src/main/java/org/apache/cxf/feature/transform/AbstractXSLTInterceptor.java
index 4259220..562e7b1 100644
--- a/core/src/main/java/org/apache/cxf/feature/transform/AbstractXSLTInterceptor.java
+++ b/core/src/main/java/org/apache/cxf/feature/transform/AbstractXSLTInterceptor.java
@@ -72,12 +72,12 @@ public abstract class AbstractXSLTInterceptor extends AbstractPhaseInterceptor<M
             xsltTemplate = TRANSFORM_FACTORY.newTemplates(new DOMSource(doc));
         } catch (TransformerConfigurationException e) {
             throw new IllegalArgumentException(
-                                               String.format("Cannot create XSLT template
from path: %s, error: ",
-                                                             xsltPath, e.getException()),
e);
+                                               String.format("Cannot create XSLT template
from path: %s",
+                                                             xsltPath), e);
         } catch (XMLStreamException e) {
             throw new IllegalArgumentException(
-                                               String.format("Cannot create XSLT template
from path: %s, error: ",
-                                                             xsltPath, e.getNestedException()),
e);
+                                               String.format("Cannot create XSLT template
from path: %s",
+                                                             xsltPath), e);
         }        
     }
 

http://git-wip-us.apache.org/repos/asf/cxf/blob/8a605be6/core/src/main/java/org/apache/cxf/helpers/FileUtils.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/helpers/FileUtils.java b/core/src/main/java/org/apache/cxf/helpers/FileUtils.java
index 59632e5..cdab0ab 100644
--- a/core/src/main/java/org/apache/cxf/helpers/FileUtils.java
+++ b/core/src/main/java/org/apache/cxf/helpers/FileUtils.java
@@ -377,16 +377,19 @@ public final class FileUtils {
                                               Pattern pattern,
                                               File exclude, boolean rec,
                                               List<File> fileList) {
-        for (File file : dir.listFiles()) {
-            if (file.equals(exclude)) {
-                continue;
-            }
-            if (file.isDirectory() && rec) {
-                getFilesRecurse(file, pattern, exclude, rec, fileList);
-            } else {
-                Matcher m = pattern.matcher(file.getName());
-                if (m.matches()) {
-                    fileList.add(file);                                
+        File[] files = dir.listFiles();
+        if (files != null) {
+            for (File file : dir.listFiles()) {
+                if (file.equals(exclude)) {
+                    continue;
+                }
+                if (file.isDirectory() && rec) {
+                    getFilesRecurse(file, pattern, exclude, rec, fileList);
+                } else {
+                    Matcher m = pattern.matcher(file.getName());
+                    if (m.matches()) {
+                        fileList.add(file);                                
+                    }
                 }
             }
         }

http://git-wip-us.apache.org/repos/asf/cxf/blob/8a605be6/core/src/main/java/org/apache/cxf/staxutils/PrettyPrintXMLStreamWriter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/staxutils/PrettyPrintXMLStreamWriter.java b/core/src/main/java/org/apache/cxf/staxutils/PrettyPrintXMLStreamWriter.java
index 0c34c96..73b5d0c 100644
--- a/core/src/main/java/org/apache/cxf/staxutils/PrettyPrintXMLStreamWriter.java
+++ b/core/src/main/java/org/apache/cxf/staxutils/PrettyPrintXMLStreamWriter.java
@@ -240,7 +240,7 @@ public class PrettyPrintXMLStreamWriter implements XMLStreamWriter {
     }
 
 
-    class CurrentElement {
+    static class CurrentElement {
         private QName name;
         private boolean hasChildElements;
 

http://git-wip-us.apache.org/repos/asf/cxf/blob/8a605be6/core/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/staxutils/StaxUtils.java b/core/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
index eb68092..d307b04 100644
--- a/core/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
+++ b/core/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
@@ -814,7 +814,7 @@ public final class StaxUtils {
                 && StringUtils.isEmpty(writer.getNamespaceContext().getNamespaceURI("")))
{
                 writeElementNS = false;
             }
-            while (it != null && it.hasNext()) {
+            while (it.hasNext()) {
                 String s = it.next();
                 if (s == null) {
                     s = "";
@@ -1182,7 +1182,7 @@ public final class StaxUtils {
         Document doc = DOMUtils.createDocument();
         if (reader.getLocation().getSystemId() != null) {
             try {
-                doc.setDocumentURI(new String(reader.getLocation().getSystemId()));
+                doc.setDocumentURI(reader.getLocation().getSystemId());
             } catch (Exception e) {
                 //ignore - probably not DOM level 3
             }
@@ -1197,7 +1197,7 @@ public final class StaxUtils {
         Document doc = builder == null ? DOMUtils.createDocument() : builder.newDocument();
         if (reader.getLocation().getSystemId() != null) {
             try {
-                doc.setDocumentURI(new String(reader.getLocation().getSystemId()));
+                doc.setDocumentURI(reader.getLocation().getSystemId());
             } catch (Exception e) {
                 //ignore - probably not DOM level 3
             }
@@ -1687,8 +1687,8 @@ public final class StaxUtils {
         node.setAttributeNodeNS(attr);
     }
     public static XMLStreamReader createXMLStreamReader(InputSource src) {
-        String sysId = src.getSystemId() == null ? null : new String(src.getSystemId());
-        String pubId = src.getPublicId() == null ? null : new String(src.getPublicId());
+        String sysId = src.getSystemId() == null ? null : src.getSystemId();
+        String pubId = src.getPublicId() == null ? null : src.getPublicId();
         if (src.getByteStream() != null) {
             if (src.getEncoding() == null) {
                 StreamSource ss = new StreamSource(src.getByteStream(), sysId);


Mime
View raw message