abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r1220341 - in /abdera/abdera2/common/src/main/java/org/apache/abdera2/common: geo/ http/ iri/ lang/ mediatype/ misc/ protocol/ protocol/servlet/ protocol/servlet/async/ security/ templates/ text/ xml/
Date Sun, 18 Dec 2011 07:08:44 GMT
Author: jmsnell
Date: Sun Dec 18 07:08:43 2011
New Revision: 1220341

URL: http://svn.apache.org/viewvc?rev=1220341&view=rev
Log:
Findbugs fixes

Modified:
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/geo/IsoPosition.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/geo/Position.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/CacheControl.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/EntityTag.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/WebLink.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/iri/IRI.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/lang/Range.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/mediatype/MimeTypeHelper.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/Comparisons.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractWorkspaceManager.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractWorkspaceProvider.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RegexTargetResolver.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RequestTemplateContext.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RouteManager.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/SimpleSubjectResolver.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/servlet/AbstractAbderaServlet.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/servlet/ServletRequestContext.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/servlet/async/AbderaTask.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/security/KeyHelper.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/templates/DelegatingContext.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/templates/QueryContext.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/text/UrlEncoding.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/xml/XMLStreamSniffingInputStream.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/xml/XmlVersionInputStream.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/xml/XmlVersionReader.java

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/geo/IsoPosition.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/geo/IsoPosition.java?rev=1220341&r1=1220340&r2=1220341&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/geo/IsoPosition.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/geo/IsoPosition.java Sun
Dec 18 07:08:43 2011
@@ -117,7 +117,7 @@ public final class IsoPosition 
       Integer m1, 
       Integer s1, 
       Double f1) {
-    double d = Math.abs(d1);
+    double d = d1 != null ? Math.abs(d1) : 0;
     double m = m1 != null ? m1 : 0.0;
     double s = s1 != null ? s1 : 0.0;
     if (s1 != null && f1 != null)
@@ -127,7 +127,7 @@ public final class IsoPosition 
     else if (f1 != null)
       d += f1;
     double ret = d + (m/60) + (s/3600);
-    return d1 < 0 ? -ret : ret;
+    return d1 != null && d1 < 0 ? -ret : ret;
   }
   
   public static IsoPosition parse(String val) {

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/geo/Position.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/geo/Position.java?rev=1220341&r1=1220340&r2=1220341&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/geo/Position.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/geo/Position.java Sun Dec
18 07:08:43 2011
@@ -115,6 +115,8 @@ public abstract class Position 
 
     @Override
     public boolean equals(Object obj) {
+        if (obj == null) 
+          return false;
         if (this == obj)
             return true;
         if (getClass() != obj.getClass())

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/CacheControl.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/CacheControl.java?rev=1220341&r1=1220340&r2=1220341&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/CacheControl.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/CacheControl.java Sun
Dec 18 07:08:43 2011
@@ -130,7 +130,7 @@ public final class CacheControl implemen
     
     public Builder extension(String name) {
       checkReserved(name);
-      exts.put(name.toLowerCase(Locale.US),null);
+      exts.put(name.toLowerCase(Locale.US),"");
       return this;
     }
     

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/EntityTag.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/EntityTag.java?rev=1220341&r1=1220340&r2=1220341&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/EntityTag.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/EntityTag.java Sun
Dec 18 07:08:43 2011
@@ -33,6 +33,7 @@ import org.apache.abdera2.common.text.Ur
 import com.google.common.base.Function;
 import com.google.common.base.Predicate;
 import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
 
 import static com.google.common.base.Preconditions.*;
 import static org.apache.abdera2.common.text.CharUtils.*;
@@ -145,10 +146,8 @@ public class EntityTag 
         return matchesAny(tag1, tags, false);
     }
 
-    @SuppressWarnings("unused")
     private static boolean empty(Iterable<EntityTag> tags) {
-      for (EntityTag e : tags) return false;
-      return true;
+      return Iterables.isEmpty(tags);
     }
     
     public static boolean matchesAny(EntityTag tag1, Iterable<EntityTag> tags, boolean
weak) {

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/WebLink.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/WebLink.java?rev=1220341&r1=1220340&r2=1220341&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/WebLink.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/WebLink.java Sun Dec
18 07:08:43 2011
@@ -375,9 +375,9 @@ public class WebLink implements Serializ
     buf.append('<')
        .append(iri.toASCIIString())
        .append('>');
-    appendif(anchor != null,buf,";anchor=<%s>",anchor.toASCIIString());
-    appendif(lang != null,buf,";hreflang=%s",lang.toString());
-    appendif(mediaType != null,buf,";type=%s",quotedIfNotToken(mediaType.toString()));
+    appendif(anchor != null,buf,";anchor=<%s>",anchor!=null?anchor.toASCIIString():"");
+    appendif(lang != null,buf,";hreflang=%s",lang!=null?lang.toString():"");
+    appendif(mediaType != null,buf,";type=%s",mediaType!=null?quotedIfNotToken(mediaType.toString()):"");
     append(rel,"rel",buf);
     append(rev,"rev",buf);
     append(media,"media",buf);

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/iri/IRI.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/iri/IRI.java?rev=1220341&r1=1220340&r2=1220341&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/iri/IRI.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/iri/IRI.java Sun Dec 18
07:08:43 2011
@@ -473,13 +473,13 @@ public final class IRI implements Serial
     private static String resolve(String bpath, String cpath) {
         if (bpath == null && cpath == null)
             return null;
-        if (bpath == null && cpath != null) {
+        if (bpath == null && cpath != null)
             return (!cpath.startsWith("/")) ? "/" + cpath : cpath;
-        }
         if (bpath != null && cpath == null)
             return bpath;
-        if (bpath.equals(cpath))
+        if (bpath != null && bpath.equals(cpath))
           return bpath;
+        if (bpath == null) return null;
         StringBuilder buf = new StringBuilder("");
         int n = bpath.lastIndexOf('/');
         if (n > -1)

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/lang/Range.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/lang/Range.java?rev=1220341&r1=1220340&r2=1220341&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/lang/Range.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/lang/Range.java Sun Dec
18 07:08:43 2011
@@ -336,7 +336,7 @@ public final class Range 
               current = Subtag.simple(name, current);
             }
           }
-          return new Range(primary);
+          return new Range(checkNotNull(primary));
         } else {
             Subtag primary = null;
             Matcher m = p_grandfathered.matcher(range);

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/mediatype/MimeTypeHelper.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/mediatype/MimeTypeHelper.java?rev=1220341&r1=1220340&r2=1220341&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/mediatype/MimeTypeHelper.java
(original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/mediatype/MimeTypeHelper.java
Sun Dec 18 07:08:43 2011
@@ -142,7 +142,7 @@ public final class MimeTypeHelper {
     }
 
     private static boolean isMatchType(String actual, String expected) {
-        return (actual != null && actual.equalsIgnoreCase(expected) || true);
+        return (actual != null && actual.equalsIgnoreCase(expected));
     }
 
     public static Predicate<String> isApp() {
@@ -223,7 +223,7 @@ public final class MimeTypeHelper {
     public static boolean isEntry(String a) {
         try {
             MimeType mta = new MimeType(a.toLowerCase());
-            return isMatch(mta, ENTRY) || 
+            return isMatch(mta, ENTRY,true) || 
                   (isMatch(mta, ATOM) && 
                    isMatchType(mta.getParameter("type"), "entry"));
         } catch (Exception e) {
@@ -237,7 +237,7 @@ public final class MimeTypeHelper {
     public static boolean isFeed(String a) {
         try {
             MimeType mta = new MimeType(a.toLowerCase());
-            return isMatch(mta, FEED) || 
+            return isMatch(mta, FEED, true) || 
                   (isMatch(mta, ATOM) && 
                    isMatchType(mta.getParameter("type"), "feed"));
         } catch (Exception e) {

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/Comparisons.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/Comparisons.java?rev=1220341&r1=1220340&r2=1220341&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/Comparisons.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/Comparisons.java Sun
Dec 18 07:08:43 2011
@@ -74,7 +74,7 @@ public class Comparisons {
   }
   
   public static boolean onlyOneIsTrue(boolean t1, boolean t2) {
-    return t1 |= t2;
+    return t1 != t2;
   }
   
   public static boolean bothAreEmpty(String t1, String t2) {

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractWorkspaceManager.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractWorkspaceManager.java?rev=1220341&r1=1220340&r2=1220341&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractWorkspaceManager.java
(original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractWorkspaceManager.java
Sun Dec 18 07:08:43 2011
@@ -35,7 +35,7 @@ public abstract class AbstractWorkspaceM
       new LinkedHashSet<WorkspaceInfo>();
     public static final String COLLECTION_ADAPTER_ATTRIBUTE = "collectionProvider";
 
-    public Collection<WorkspaceInfo> getWorkspaces(RequestContext request) {
+    public synchronized Collection<WorkspaceInfo> getWorkspaces(RequestContext request)
{
         return workspaces;
     }
 

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractWorkspaceProvider.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractWorkspaceProvider.java?rev=1220341&r1=1220340&r2=1220341&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractWorkspaceProvider.java
(original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractWorkspaceProvider.java
Sun Dec 18 07:08:43 2011
@@ -63,7 +63,7 @@ public abstract class AbstractWorkspaceP
         this.targetResolver = targetResolver;
     }
 
-    public Collection<WorkspaceInfo> getWorkspaces(RequestContext request) {
+    public synchronized Collection<WorkspaceInfo> getWorkspaces(RequestContext request)
{
         return workspaces;
     }
 

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RegexTargetResolver.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RegexTargetResolver.java?rev=1220341&r1=1220340&r2=1220341&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RegexTargetResolver.java
(original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RegexTargetResolver.java
Sun Dec 18 07:08:43 2011
@@ -69,10 +69,8 @@ public class RegexTargetResolver<R exten
 
     public RegexTargetResolver(Map<String, TargetType> patterns) {
         this.patterns = new HashMap<Pattern, TargetType>();
-        for (String p : patterns.keySet()) {
-            TargetType type = patterns.get(p);
-            setPattern(p, type);
-        }
+        for (Map.Entry<String,TargetType> entry : patterns.entrySet())
+            setPattern(entry.getKey(), entry.getValue());
     }
 
     public RegexTargetResolver<R> setPattern(String pattern, TargetType type) {

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RequestTemplateContext.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RequestTemplateContext.java?rev=1220341&r1=1220340&r2=1220341&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RequestTemplateContext.java
(original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RequestTemplateContext.java
Sun Dec 18 07:08:43 2011
@@ -20,7 +20,7 @@ public class RequestTemplateContext 
 
   private static final long serialVersionUID = 4332356546022014897L;
 
-  private final RequestContext request;
+  private final transient RequestContext request;
 
   public RequestTemplateContext(
     RequestContext request, 

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RouteManager.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RouteManager.java?rev=1220341&r1=1220340&r2=1220341&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RouteManager.java
(original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RouteManager.java
Sun Dec 18 07:08:43 2011
@@ -267,5 +267,37 @@ public class RouteManager<T,X extends Re
                 names.add(name);
             return names;
         }
+
+        @Override
+        public int hashCode() {
+          final int prime = 31;
+          int result = super.hashCode();
+          result = prime * result + ((params == null) ? 0 : params.hashCode());
+          result = prime * result + ((route == null) ? 0 : route.hashCode());
+          return result;
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+          if (this == obj)
+            return true;
+          if (!super.equals(obj))
+            return false;
+          if (getClass() != obj.getClass())
+            return false;
+          RouteTarget other = (RouteTarget) obj;
+          if (params == null) {
+            if (other.params != null)
+              return false;
+          } else if (!params.equals(other.params))
+            return false;
+          if (route == null) {
+            if (other.route != null)
+              return false;
+          } else if (!route.equals(other.route))
+            return false;
+          return true;
+        }
+       
     }
 }

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/SimpleSubjectResolver.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/SimpleSubjectResolver.java?rev=1220341&r1=1220340&r2=1220341&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/SimpleSubjectResolver.java
(original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/SimpleSubjectResolver.java
Sun Dec 18 07:08:43 2011
@@ -92,26 +92,29 @@ public class SimpleSubjectResolver 
 
     }
 
-    public static final class AnonymousPrincipal implements Principal, Serializable {
+    final static String name = "Anonymous";
+    public static final class AnonymousPrincipal 
+      implements Principal, Serializable {
         private static final long serialVersionUID = -5050930075733261944L;
-        final String name = "Anonymous";
-
         public String getName() {
-            return name;
+          return name;
         }
-
         public String toString() {
-            return name;
-        }
-
-        public boolean equals(Object other) {
-            if (other == null)
-                return false;
-            return this == other;
+          return name;
         }
-
         public int hashCode() {
           return MoreFunctions.genHashCode(1, name);
         }
+        @Override
+        public boolean equals(Object obj) {
+          if (this == obj)
+            return true;
+          if (obj == null)
+            return false;
+          if (getClass() != obj.getClass())
+            return false;
+          return true;
+        }
+        
     }
 }

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/servlet/AbstractAbderaServlet.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/servlet/AbstractAbderaServlet.java?rev=1220341&r1=1220340&r2=1220341&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/servlet/AbstractAbderaServlet.java
(original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/servlet/AbstractAbderaServlet.java
Sun Dec 18 07:08:43 2011
@@ -111,7 +111,9 @@ public abstract class AbstractAbderaServ
                 MimeType ct = context.getContentType();
                 if (ct != null)
                     response.setContentType(ct.toString());
-            } catch (Exception e) {}
+            } catch (Exception e) {
+              // ok to ignore the error
+            }
             Iterable<String> names = context.getHeaderNames();
             for (String name : names) {
                 Iterable<Object> headers = context.getHeaders(name);

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/servlet/ServletRequestContext.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/servlet/ServletRequestContext.java?rev=1220341&r1=1220340&r2=1220341&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/servlet/ServletRequestContext.java
(original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/servlet/ServletRequestContext.java
Sun Dec 18 07:08:43 2011
@@ -272,7 +272,7 @@ public class ServletRequestContext 
       case SERVERNAME:
           return request.getServerName();
       case SERVERPORT:
-          return new Integer(request.getServerPort());
+          return Integer.valueOf(request.getServerPort());
       case SECURE:
           return (Boolean)request.isSecure();
       case PARTS: {

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/servlet/async/AbderaTask.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/servlet/async/AbderaTask.java?rev=1220341&r1=1220340&r2=1220341&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/servlet/async/AbderaTask.java
(original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/servlet/async/AbderaTask.java
Sun Dec 18 07:08:43 2011
@@ -127,6 +127,7 @@ public class AbderaTask {
                     response.setContentType(ct.toString());
                 }
             } catch (Exception e) {
+              // ok to ignore the error
             }
             Iterable<String> names = context.getHeaderNames();
             for (String name : names) {

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/security/KeyHelper.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/security/KeyHelper.java?rev=1220341&r1=1220340&r2=1220341&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/security/KeyHelper.java
(original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/security/KeyHelper.java
Sun Dec 18 07:08:43 2011
@@ -61,6 +61,7 @@ public final class KeyHelper {
         if (in == null)
             in = new FileInputStream(file);
         ks.load(in, pass.toCharArray());
+        in.close();
         return ks;
     }
 
@@ -71,6 +72,7 @@ public final class KeyHelper {
         if (in == null)
             in = new FileInputStream(file);
         ks.load(in, pass.toCharArray());
+        in.close();
         return ks;
     }
 

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/templates/DelegatingContext.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/templates/DelegatingContext.java?rev=1220341&r1=1220340&r2=1220341&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/templates/DelegatingContext.java
(original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/templates/DelegatingContext.java
Sun Dec 18 07:08:43 2011
@@ -26,7 +26,7 @@ public abstract class DelegatingContext 
     protected final Context subcontext;
 
     protected DelegatingContext(Context subcontext) {
-      super(subcontext.isIri());
+      super(subcontext != null ? subcontext.isIri() : false);
       checkNotNull(subcontext);
       this.subcontext = subcontext;
     }

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/templates/QueryContext.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/templates/QueryContext.java?rev=1220341&r1=1220340&r2=1220341&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/templates/QueryContext.java
(original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/templates/QueryContext.java
Sun Dec 18 07:08:43 2011
@@ -140,7 +140,7 @@ public class QueryContext extends MapCon
   }
   
   public static String baseFromQuery(String query) {
-    IRI iri = new IRI(checkNotNull(query));
+    IRI iri = new IRI(checkNotNull(query)).normalize();
     String s = iri.resolve(iri.getPath()).toString();
     return s;
   }
@@ -163,6 +163,8 @@ public class QueryContext extends MapCon
     QueryContext qc = new QueryContext(checkNotNull(query));
     DefaultingContext dc = new DefaultingContext(checkNotNull(context),qc);
     Template temp = QueryContext.templateFromQuery(query, false, qc);
-    return temp.extend(checkNotNull(extender)).expand(dc);
+    return extender != null ?
+      temp.extend(extender).expand(dc) :
+      temp.expand(dc);
   }
 }

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/text/UrlEncoding.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/text/UrlEncoding.java?rev=1220341&r1=1220340&r2=1220341&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/text/UrlEncoding.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/text/UrlEncoding.java Sun
Dec 18 07:08:43 2011
@@ -339,8 +339,9 @@ public final class UrlEncoding {
     }
 
     public static String decode(String e, String enc) throws UnsupportedEncodingException
{
+      DecodingInputStream r = null;
       try {
-        DecodingInputStream r = new DecodingInputStream(e.getBytes(enc));
+        r = new DecodingInputStream(e.getBytes(enc));
         StringBuilder builder = new StringBuilder();
         byte[] buf = new byte[100];
         int i = -1;
@@ -349,6 +350,12 @@ public final class UrlEncoding {
         return builder.toString();
       } catch (IOException i) {
         throw new RuntimeException(i);
+      } finally {
+        try {
+          if (r != null) r.close();
+        } catch (IOException t) {
+          // ok to ignore
+        }
       }
     }
 

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/xml/XMLStreamSniffingInputStream.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/xml/XMLStreamSniffingInputStream.java?rev=1220341&r1=1220340&r2=1220341&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/xml/XMLStreamSniffingInputStream.java
(original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/xml/XMLStreamSniffingInputStream.java
Sun Dec 18 07:08:43 2011
@@ -50,7 +50,8 @@ public class XMLStreamSniffingInputStrea
               String cs = xmlreader.getCharacterEncodingScheme();
               if (cs != null)
                   charset = cs;
-          } catch (Exception e) {
+          } catch (Throwable e) {
+            // Ok to ignore the exception
           }
         }
         return charset;

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/xml/XmlVersionInputStream.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/xml/XmlVersionInputStream.java?rev=1220341&r1=1220340&r2=1220341&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/xml/XmlVersionInputStream.java
(original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/xml/XmlVersionInputStream.java
Sun Dec 18 07:08:43 2011
@@ -42,7 +42,9 @@ public class XmlVersionInputStream exten
       this.peek_ahead = peek_ahead;
       try {
         version = detectVersion();
-      } catch (IOException e) {}
+      } catch (IOException e) {
+        // ok to ignore the error, we'll assume the default
+      }
     }
     
     public XmlVersionInputStream(InputStream in) {
@@ -65,7 +67,8 @@ public class XmlVersionInputStream exten
             String v = xmlreader.getVersion();
             if (v != null)
                 version = v;
-        } catch (Exception e) {
+        } catch (Throwable e) {
+          // ok to ignore the error, we'll assume the default
         }
         return XMLVersion.get(version);
     }

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/xml/XmlVersionReader.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/xml/XmlVersionReader.java?rev=1220341&r1=1220340&r2=1220341&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/xml/XmlVersionReader.java
(original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/xml/XmlVersionReader.java
Sun Dec 18 07:08:43 2011
@@ -59,7 +59,8 @@ public class XmlVersionReader extends Pu
             if (v != null)
                 version = v;
             unread(p, 0, r);
-        } catch (Exception e) {
+        } catch (Throwable e) {
+          // ok to ignore the error... we'll just assume the default
         }
         return XMLVersion.get(version);
     }



Mime
View raw message