cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r911865 - in /cxf/trunk/common/common/src: main/java/org/apache/cxf/common/commands/ main/java/org/apache/cxf/common/logging/ main/java/org/apache/cxf/common/util/ main/java/org/apache/cxf/common/xmlschema/ main/java/org/apache/cxf/configur...
Date Fri, 19 Feb 2010 16:55:20 GMT
Author: dkulp
Date: Fri Feb 19 16:55:19 2010
New Revision: 911865

URL: http://svn.apache.org/viewvc?rev=911865&view=rev
Log:
Fix a bunch of things found by findbugs

Modified:
    cxf/trunk/common/common/src/main/java/org/apache/cxf/common/commands/ForkedCommand.java
    cxf/trunk/common/common/src/main/java/org/apache/cxf/common/logging/AbstractDelegatingLogger.java
    cxf/trunk/common/common/src/main/java/org/apache/cxf/common/logging/LogUtils.java
    cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/CacheMap.java
    cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/Compiler.java
    cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/ModCountCopyOnWriteArrayList.java
    cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/SortedArraySet.java
    cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/StringUtils.java
    cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/WeakIdentityHashMap.java
    cxf/trunk/common/common/src/main/java/org/apache/cxf/common/xmlschema/SchemaCollection.java
    cxf/trunk/common/common/src/main/java/org/apache/cxf/common/xmlschema/XmlSchemaUtils.java
    cxf/trunk/common/common/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java
    cxf/trunk/common/common/src/main/java/org/apache/cxf/configuration/spring/AbstractSpringBeanMap.java
    cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/FileUtils.java
    cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/MethodComparator.java
    cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/NSDecl.java
    cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/NSStack.java
    cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/XMLUtils.java
    cxf/trunk/common/common/src/main/java/org/apache/cxf/jaxb/JAXBUtils.java
    cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/AbstractDOMStreamReader.java
    cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/CachingXmlEventWriter.java
    cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
    cxf/trunk/common/common/src/test/java/org/apache/cxf/common/commands/ForkedCommandTest.java
    cxf/trunk/common/common/src/test/java/org/apache/cxf/helpers/NameSpaceTest.java

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/common/commands/ForkedCommand.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/commands/ForkedCommand.java?rev=911865&r1=911864&r2=911865&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/common/commands/ForkedCommand.java
(original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/common/commands/ForkedCommand.java
Fri Feb 19 16:55:19 2010
@@ -65,7 +65,7 @@
 
     public String toString() {
         if (null == arguments) {
-            return null;
+            return "";
         }
         StringBuilder buf = new StringBuilder();
         for (int i = 0; i < arguments.length; i++) {

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/common/logging/AbstractDelegatingLogger.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/logging/AbstractDelegatingLogger.java?rev=911865&r1=911864&r2=911865&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/common/logging/AbstractDelegatingLogger.java
(original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/common/logging/AbstractDelegatingLogger.java
Fri Feb 19 16:55:19 2010
@@ -184,10 +184,13 @@
                 logp(Level.FINER, sourceClass, sourceMethod, msg);
                 return;
             }
+            StringBuilder builder = new StringBuilder(msg);
             for (int i = 0; i < params.length; i++) {
-                msg = msg + " {" + i + "}";
+                builder.append(" {");
+                builder.append(Integer.toString(i));
+                builder.append("}");
             }
-            logp(Level.FINER, sourceClass, sourceMethod, msg, params);
+            logp(Level.FINER, sourceClass, sourceMethod, builder.toString(), params);
         }
     }
 

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/common/logging/LogUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/logging/LogUtils.java?rev=911865&r1=911864&r2=911865&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/common/logging/LogUtils.java (original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/common/logging/LogUtils.java Fri
Feb 19 16:55:19 2010
@@ -73,7 +73,11 @@
                 }
                 if (ins != null) {
                     BufferedReader din = new BufferedReader(new InputStreamReader(ins));
-                    cname = din.readLine();
+                    try {
+                        cname = din.readLine();
+                    } finally {
+                        din.close();
+                    }
                 }
             }
             if (StringUtils.isEmpty(cname)) {

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/CacheMap.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/CacheMap.java?rev=911865&r1=911864&r2=911865&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/CacheMap.java (original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/CacheMap.java Fri Feb
19 16:55:19 2010
@@ -84,7 +84,7 @@
         V val = mainDataMap.get(key);
         if (val == null) {
             updateMainDataMap();
-            val = mainDataMap.get(val);
+            val = mainDataMap.get(key);
         }
         if (val != null) {
             extraKeyMap.put((K)key, val);

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/Compiler.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/Compiler.java?rev=911865&r1=911864&r2=911865&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/Compiler.java (original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/Compiler.java Fri Feb
19 16:55:19 2010
@@ -221,12 +221,12 @@
 
             if (p.getErrorStream() != null) {
                 StreamPrinter errorStreamPrinter = new StreamPrinter(p.getErrorStream(),
"", System.out);
-                errorStreamPrinter.run();
+                errorStreamPrinter.start();
             }
 
             if (p.getInputStream() != null) {
                 StreamPrinter infoStreamPrinter = new StreamPrinter(p.getInputStream(), "[INFO]",
System.out);
-                infoStreamPrinter.run();
+                infoStreamPrinter.start();
             }
 
             if (p != null) {

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/ModCountCopyOnWriteArrayList.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/ModCountCopyOnWriteArrayList.java?rev=911865&r1=911864&r2=911865&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/ModCountCopyOnWriteArrayList.java
(original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/ModCountCopyOnWriteArrayList.java
Fri Feb 19 16:55:19 2010
@@ -29,17 +29,20 @@
         super();
     }
     public ModCountCopyOnWriteArrayList(Collection<? extends T> c) {
-        super(c);
-        if (c instanceof ModCountCopyOnWriteArrayList) {
-            modCount = ((ModCountCopyOnWriteArrayList)c).modCount;
+        super();
+        synchronized (c) {
+            addAll(c);
+            if (c instanceof ModCountCopyOnWriteArrayList) {
+                modCount = ((ModCountCopyOnWriteArrayList)c).getModCount();
+            }
         }
     }
     
-    public int getModCount() {
+    public synchronized int getModCount() {
         return modCount;
     }
     
-    public void setModCount(int i) {
+    public synchronized void setModCount(int i) {
         modCount = i;
     }
     
@@ -108,6 +111,17 @@
         ++modCount;
         return super.retainAll(c);
     }
+    
+    public synchronized int hashCode() {
+        return super.hashCode() + modCount;
+    }
+    
+    public synchronized boolean equals(Object o) {
+        if (o instanceof ModCountCopyOnWriteArrayList) {
+            return super.equals(o) && modCount == ((ModCountCopyOnWriteArrayList)o).getModCount();
+        }
+        return false;
+    }
 
 }
 

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/SortedArraySet.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/SortedArraySet.java?rev=911865&r1=911864&r2=911865&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/SortedArraySet.java (original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/SortedArraySet.java Fri
Feb 19 16:55:19 2010
@@ -168,9 +168,12 @@
     @SuppressWarnings("unchecked")
     public <X> X[] toArray(X[] a) {
         T[] tmp = data.get();
-        if (tmp == null && a.length != 0) {
-            return (X[])java.lang.reflect.Array.
-                newInstance(a.getClass().getComponentType(), 0);
+        if (tmp == null) {
+            if (a.length != 0) {
+                return (X[])java.lang.reflect.Array.
+                    newInstance(a.getClass().getComponentType(), 0);
+            }
+            return a;
         }
         
         if (a.length < tmp.length) {
@@ -186,6 +189,9 @@
 
     @SuppressWarnings("unchecked")
     public boolean equals(Object o) {
+        if (!(o instanceof SortedArraySet)) {
+            return false;
+        }
         SortedArraySet<T> as = (SortedArraySet<T>)o;
         return Arrays.equals(data.get(), as.data.get());
     }

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/StringUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/StringUtils.java?rev=911865&r1=911864&r2=911865&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/StringUtils.java (original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/StringUtils.java Fri
Feb 19 16:55:19 2010
@@ -216,11 +216,10 @@
     }
     
     public static String uncapitalize(String str) {
-        int strLen = str.length();
-        if (str == null || strLen == 0) {
+        if (str == null || str.length() == 0) {
             return str;
         }
-        return new StringBuilder(strLen)
+        return new StringBuilder(str.length())
             .append(Character.toLowerCase(str.charAt(0)))
             .append(str.substring(1))
             .toString();

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/WeakIdentityHashMap.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/WeakIdentityHashMap.java?rev=911865&r1=911864&r2=911865&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/WeakIdentityHashMap.java
(original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/WeakIdentityHashMap.java
Fri Feb 19 16:55:19 2010
@@ -98,6 +98,9 @@
     }
 
     public boolean equals(Object o) {
+        if (!(o instanceof WeakIdentityHashMap)) {
+            return false;
+        }
         return backingStore.equals(((WeakIdentityHashMap)o).backingStore);
     }
 
@@ -161,9 +164,11 @@
             if (this == o) {
                 return true;
             }
-            IdentityWeakReference ref = (IdentityWeakReference)o;
-            if (this.get() == ref.get()) {
-                return true;
+            if (o instanceof WeakReference) {
+                WeakReference ref = (WeakReference)o;
+                if (this.get() == ref.get()) {
+                    return true;
+                }
             }
             return false;
         }

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/common/xmlschema/SchemaCollection.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/xmlschema/SchemaCollection.java?rev=911865&r1=911864&r2=911865&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/common/xmlschema/SchemaCollection.java
(original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/common/xmlschema/SchemaCollection.java
Fri Feb 19 16:55:19 2010
@@ -57,6 +57,7 @@
 import org.apache.ws.commons.schema.utils.NamespacePrefixList;
 import org.apache.ws.commons.schema.utils.TargetNamespaceValidator;
 
+
 /**
  * Wrapper class for XmlSchemaCollection that deals with various quirks and bugs.
  */
@@ -84,7 +85,12 @@
     }
 
     public boolean equals(Object obj) {
-        return schemaCollection.equals(obj);
+        if (obj instanceof SchemaCollection) {
+            return schemaCollection.equals(((SchemaCollection)obj).schemaCollection);
+        } else if (obj instanceof XmlSchemaCollection) {
+            return schemaCollection.equals(obj);
+        }
+        return false;
     }
 
     public XmlSchemaElement getElementByQName(QName qname) {

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/common/xmlschema/XmlSchemaUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/xmlschema/XmlSchemaUtils.java?rev=911865&r1=911864&r2=911865&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/common/xmlschema/XmlSchemaUtils.java
(original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/common/xmlschema/XmlSchemaUtils.java
Fri Feb 19 16:55:19 2010
@@ -411,6 +411,7 @@
                                                String referencingURI, 
                                                XmlSchemaElement element,
                                                XmlSchemaType containingType) {
+        assert element != null;
         if (element.getSchemaTypeName() != null) {
             XmlSchemaType type = xmlSchemaCollection.getTypeByQName(element.getSchemaTypeName());
             if (type == null) {
@@ -420,7 +421,6 @@
             }
             return type;
         }
-        assert element != null;
         // The referencing URI only helps if there is a schema that points to
         // it.
         // It might be the URI for the wsdl TNS, which might have no schema.

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java?rev=911865&r1=911864&r2=911865&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java
(original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java
Fri Feb 19 16:55:19 2010
@@ -349,13 +349,8 @@
             }
             
             Unmarshaller u = context.createUnmarshaller();
-            Object obj = u.unmarshal(data, cls);
-            if (obj instanceof JAXBElement<?>) {
-                JAXBElement<?> el = (JAXBElement<?>)obj;
-                obj = el.getValue();
-
-            }
-            return cls.cast(obj);
+            JAXBElement<?> obj = u.unmarshal(data, cls);
+            return cls.cast(obj.getValue());
         } catch (RuntimeException e) {
             throw e;
         } catch (Exception e) {

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/configuration/spring/AbstractSpringBeanMap.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/configuration/spring/AbstractSpringBeanMap.java?rev=911865&r1=911864&r2=911865&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/configuration/spring/AbstractSpringBeanMap.java
(original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/configuration/spring/AbstractSpringBeanMap.java
Fri Feb 19 16:55:19 2010
@@ -19,6 +19,7 @@
 package org.apache.cxf.configuration.spring;
 
 import java.beans.PropertyDescriptor;
+import java.io.Serializable;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
@@ -39,7 +40,7 @@
 import org.springframework.context.ApplicationContextAware;
 
 abstract class AbstractSpringBeanMap<X, V> 
-    implements ApplicationContextAware, InitializingBean, MapProvider<X, V> {
+    implements ApplicationContextAware, InitializingBean, MapProvider<X, V>, Serializable
{
     protected ApplicationContext context;
     protected Class<?> type;
     protected String idsProperty;

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/FileUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/FileUtils.java?rev=911865&r1=911864&r2=911865&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/FileUtils.java (original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/FileUtils.java Fri Feb 19
16:55:19 2010
@@ -53,7 +53,14 @@
         } catch (SecurityException e) {
             //Ignorable, we'll use the default
         }
-        if (s == null) {
+        if (s != null) {
+            //assume someone outside of us will manage the directory
+            File f = new File(s);
+            if (f.mkdirs()) {
+                defaultTempDir = f;                
+            }
+        }
+        if (defaultTempDir == null) {
             int x = (int)(Math.random() * 1000000);
             s = System.getProperty("java.io.tmpdir");
             File checkExists = new File(s);
@@ -76,11 +83,6 @@
                 }
             };
             Runtime.getRuntime().addShutdownHook(hook);            
-        } else {
-            //assume someone outside of us will manage the directory
-            File f = new File(s);
-            f.mkdirs();
-            defaultTempDir = f;
         }
         return defaultTempDir;
     }
@@ -290,10 +292,14 @@
         }
         BufferedReader reader = new BufferedReader(new FileReader(file));
         List<String> results = new ArrayList<String>();
-        String line = reader.readLine();
-        while (line != null) {
-            results.add(line);
-            line = reader.readLine();
+        try {
+            String line = reader.readLine();
+            while (line != null) {
+                results.add(line);
+                line = reader.readLine();
+            }
+        } finally {
+            reader.close();
         }
         return results;
     }

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/MethodComparator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/MethodComparator.java?rev=911865&r1=911864&r2=911865&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/MethodComparator.java (original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/MethodComparator.java Fri
Feb 19 16:55:19 2010
@@ -19,6 +19,7 @@
 
 package org.apache.cxf.helpers;
 
+import java.io.Serializable;
 import java.lang.reflect.Method;
 import java.util.Comparator;
 
@@ -26,7 +27,7 @@
  * Sorts methods according to their name, number of parameters, and parameter
  * types.
  */
-public class MethodComparator implements Comparator<Method> {
+public class MethodComparator implements Comparator<Method>, Serializable {
 
     public int compare(Method m1, Method m2) {
 

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/NSDecl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/NSDecl.java?rev=911865&r1=911864&r2=911865&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/NSDecl.java (original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/NSDecl.java Fri Feb 19 16:55:19
2010
@@ -51,6 +51,9 @@
     }
 
     public boolean equals(Object obj) {
+        if (!(obj instanceof NSDecl)) {
+            return false;
+        }
         return obj != null
             && uri == ((NSDecl)obj).uri
             && prefix == ((NSDecl)obj).prefix;

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/NSStack.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/NSStack.java?rev=911865&r1=911864&r2=911865&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/NSStack.java (original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/NSStack.java Fri Feb 19 16:55:19
2010
@@ -92,7 +92,7 @@
      * @param URI the namespace name for whom a declared prefix is desired
      * @return the prefix or null if namespace name not found
      */
-    public String getPrefix(String uri) {
+    public synchronized String getPrefix(String uri) {
         for (int i = size - 1; i >= 0; i--) {
             List<NSDecl> scope = stack.get(i);
             ListIterator<NSDecl> lsIterator =  scope.listIterator();
@@ -115,7 +115,7 @@
      * @param prefix the prefix for whom a declared namespace name is desired
      * @return the namespace name or null if prefix not found
      */
-    public String getURI(String prefix) {
+    public synchronized String getURI(String prefix) {
         for (int i = size - 1; i >= 0; i--) {
             List<NSDecl> scope = stack.get(i);
             ListIterator<NSDecl> lsIterator = scope.listIterator();

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/XMLUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/XMLUtils.java?rev=911865&r1=911864&r2=911865&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/XMLUtils.java (original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/XMLUtils.java Fri Feb 19
16:55:19 2010
@@ -154,8 +154,11 @@
     }
 
     public static Document parse(byte[] in) throws ParserConfigurationException, SAXException,
IOException {
-        if (in == null && LOG.isLoggable(Level.FINE)) {
-            LOG.fine("XMLUtils trying to parse a null bytes");
+        if (in == null) {
+            if (LOG.isLoggable(Level.FINE)) {
+                LOG.fine("XMLUtils trying to parse a null bytes");
+            }
+            return null;
         }
         return getParser().parse(new ByteArrayInputStream(in));
     }

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/jaxb/JAXBUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/jaxb/JAXBUtils.java?rev=911865&r1=911864&r2=911865&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/jaxb/JAXBUtils.java (original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/jaxb/JAXBUtils.java Fri Feb 19 16:55:19
2010
@@ -779,9 +779,9 @@
         }
         for (Map.Entry<String, InputStream> entry : packages.entrySet()) {
             if (entry.getValue() != null) {
+                BufferedReader reader = null;
                 try {
-                    BufferedReader reader = new BufferedReader(new InputStreamReader(entry.getValue(),
-                                                                                     "UTF-8"));
+                    reader = new BufferedReader(new InputStreamReader(entry.getValue(), "UTF-8"));
                     String pkg = entry.getKey();
                     ClassLoader loader = packageLoaders.get(pkg);
                     if (!StringUtils.isEmpty(pkg)) {
@@ -808,7 +808,10 @@
                     // ignore
                 } finally {
                     try {
-                        entry.getValue().close();
+                        if (reader != null) {
+                            reader.close();
+                            entry.getValue().close();
+                        }
                     } catch (Exception e) {
                         // ignore
                     }

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/AbstractDOMStreamReader.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/AbstractDOMStreamReader.java?rev=911865&r1=911864&r2=911865&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/AbstractDOMStreamReader.java
(original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/AbstractDOMStreamReader.java
Fri Feb 19 16:55:19 2010
@@ -62,7 +62,6 @@
         List<String> uris;
         List<String> prefixes;
         List<Object> attributes;
-        List<Object> allAttributes;
 
         final ElementFrame<T, I> parent;
         
@@ -83,7 +82,6 @@
             attributes = Collections.emptyList();
             prefixes = Collections.emptyList();
             uris = Collections.emptyList();
-            allAttributes = Collections.emptyList();
         }
         public ElementFrame(T doc) {
             this(doc, true);

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/CachingXmlEventWriter.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/CachingXmlEventWriter.java?rev=911865&r1=911864&r2=911865&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/CachingXmlEventWriter.java
(original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/CachingXmlEventWriter.java
Fri Feb 19 16:55:19 2010
@@ -225,7 +225,7 @@
                                             Collections.EMPTY_SET.iterator()));
     }
     
-    private class NSContext implements NamespaceContext {
+    private static class NSContext implements NamespaceContext {
         NamespaceContext parent;
         Map<String, String> map = new HashMap<String, String>();
         

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java?rev=911865&r1=911864&r2=911865&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java (original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java Fri Feb
19 16:55:19 2010
@@ -1150,7 +1150,7 @@
         String localName = value.substring(index + 1);
         String ns = reader.getNamespaceURI(prefix);
 
-        if ((prefix != null && ns == null) || localName == null) {
+        if ((!StringUtils.isEmpty(prefix) && ns == null) || localName == null) {
             throw new RuntimeException("Invalid QName in mapping: " + value);
         }
 

Modified: cxf/trunk/common/common/src/test/java/org/apache/cxf/common/commands/ForkedCommandTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/test/java/org/apache/cxf/common/commands/ForkedCommandTest.java?rev=911865&r1=911864&r2=911865&view=diff
==============================================================================
--- cxf/trunk/common/common/src/test/java/org/apache/cxf/common/commands/ForkedCommandTest.java
(original)
+++ cxf/trunk/common/common/src/test/java/org/apache/cxf/common/commands/ForkedCommandTest.java
Fri Feb 19 16:55:19 2010
@@ -46,7 +46,7 @@
     public void testBasics() {
         ForkedCommand fc1 = new ForkedCommand();
         String cmdline1 = fc1.toString();
-        assertNull(cmdline1);
+        assertEquals("", cmdline1);
         try {
             fc1.execute();
         } catch (ForkedCommandException ex) {

Modified: cxf/trunk/common/common/src/test/java/org/apache/cxf/helpers/NameSpaceTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/test/java/org/apache/cxf/helpers/NameSpaceTest.java?rev=911865&r1=911864&r2=911865&view=diff
==============================================================================
--- cxf/trunk/common/common/src/test/java/org/apache/cxf/helpers/NameSpaceTest.java (original)
+++ cxf/trunk/common/common/src/test/java/org/apache/cxf/helpers/NameSpaceTest.java Fri Feb
19 16:55:19 2010
@@ -24,10 +24,10 @@
 
 public class NameSpaceTest extends Assert {
     
-    private final String myURL1 = "http://test.apache.org/testurl1";
-    private final String myURL2 = "http://test.apache.org/testurl2";
-    private final String myCustomURL = "http://test.apache.org/custom-prefix-url";
-    private final String myOwnPrefix = "myown-prefix";
+    private static final String MY_URL1 = "http://test.apache.org/testurl1";
+    private static final String MY_URL2 = "http://test.apache.org/testurl2";
+    private static final String MY_CUSTOM_URL = "http://test.apache.org/custom-prefix-url";
+    private static final String MY_OWN_PREFIX = "myown-prefix";
     
 
     @Test
@@ -36,30 +36,30 @@
         
         nsStackObj.push();
         
-        nsStackObj.add(myURL1);
-        nsStackObj.add(myOwnPrefix, myCustomURL);
-        nsStackObj.add(myURL2);
-        
-        assertEquals(myURL1, nsStackObj.getURI("ns1"));
-        assertEquals(myCustomURL, nsStackObj.getURI(myOwnPrefix));
-        assertEquals(myURL2, nsStackObj.getURI("ns2"));
+        nsStackObj.add(MY_URL1);
+        nsStackObj.add(MY_OWN_PREFIX, MY_CUSTOM_URL);
+        nsStackObj.add(MY_URL2);
+        
+        assertEquals(MY_URL1, nsStackObj.getURI("ns1"));
+        assertEquals(MY_CUSTOM_URL, nsStackObj.getURI(MY_OWN_PREFIX));
+        assertEquals(MY_URL2, nsStackObj.getURI("ns2"));
         assertNull(nsStackObj.getURI("non-existent-prefix"));
         
-        assertEquals("ns2", nsStackObj.getPrefix(myURL2));
-        assertEquals(myOwnPrefix, nsStackObj.getPrefix(myCustomURL));
-        assertEquals("ns1", nsStackObj.getPrefix(myURL1));
+        assertEquals("ns2", nsStackObj.getPrefix(MY_URL2));
+        assertEquals(MY_OWN_PREFIX, nsStackObj.getPrefix(MY_CUSTOM_URL));
+        assertEquals("ns1", nsStackObj.getPrefix(MY_URL1));
         assertNull(nsStackObj.getPrefix("non-existent-prefix"));
         
         nsStackObj.pop();
         assertNull(nsStackObj.getPrefix("non-existent-prefix"));
-        assertNull(nsStackObj.getPrefix(myCustomURL));
+        assertNull(nsStackObj.getPrefix(MY_CUSTOM_URL));
     }
     
     @Test
     public void testNSDeclOperaions() throws Exception {
-        NSDecl nsDecl1 = new NSDecl(myOwnPrefix, myCustomURL);
-        NSDecl nsDecl2 = new NSDecl("ns2", myURL2);
-        NSDecl nsDecl3 = new NSDecl(myOwnPrefix, myCustomURL);
+        NSDecl nsDecl1 = new NSDecl(MY_OWN_PREFIX, MY_CUSTOM_URL);
+        NSDecl nsDecl2 = new NSDecl("ns2", MY_URL2);
+        NSDecl nsDecl3 = new NSDecl(MY_OWN_PREFIX, MY_CUSTOM_URL);
         
         assertFalse(nsDecl2.equals(nsDecl1));
         assertTrue(nsDecl3.equals(nsDecl1));



Mime
View raw message