abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r616793 - in /incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server: context/AbstractRequestContext.java servlet/ServletRequestContext.java
Date Wed, 30 Jan 2008 15:47:36 GMT
Author: jmsnell
Date: Wed Jan 30 07:47:35 2008
New Revision: 616793

URL: http://svn.apache.org/viewvc?rev=616793&view=rev
Log:
Fix NPE reported by Remy Gendron

Modified:
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/context/AbstractRequestContext.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/servlet/ServletRequestContext.java

Modified: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/context/AbstractRequestContext.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/context/AbstractRequestContext.java?rev=616793&r1=616792&r2=616793&view=diff
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/context/AbstractRequestContext.java
(original)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/context/AbstractRequestContext.java
Wed Jan 30 07:47:35 2008
@@ -33,6 +33,8 @@
 import org.apache.abdera.protocol.server.Provider;
 import org.apache.abdera.protocol.server.RequestContext;
 import org.apache.abdera.protocol.server.Target;
+import org.apache.abdera.protocol.server.TargetType;
+import org.apache.abdera.protocol.server.impl.AbstractTarget;
 import org.apache.abdera.protocol.util.AbstractRequest;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -61,6 +63,16 @@
       this.method = method;
       this.baseUri = baseUri;
       this.requestUri = requestUri;
+      
+  }
+  
+  protected Target initTarget() {
+    try {
+      Target target = provider.resolveTarget(this);
+      return target != null ? target : new UnknownTarget(this);
+    } catch (Exception e) {
+      throw new RuntimeException(e);
+    }
   }
   
   public Abdera getAbdera() {
@@ -169,4 +181,11 @@
       return getResolvedUri().resolve(
         urlFor(key,param)).toString();
     }
+  
+  public static class UnknownTarget 
+    extends AbstractTarget {
+    public UnknownTarget(RequestContext context) {
+      super(TargetType.TYPE_UNKNOWN, context);
+    }
+  }
 }

Modified: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/servlet/ServletRequestContext.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/servlet/ServletRequestContext.java?rev=616793&r1=616792&r2=616793&view=diff
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/servlet/ServletRequestContext.java
(original)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/servlet/ServletRequestContext.java
Wed Jan 30 07:47:35 2008
@@ -55,7 +55,7 @@
       this.session = request.getSession(false);
       this.principal = request.getUserPrincipal();
       this.subject = provider.resolveSubject(this);
-      this.target = provider.resolveTarget(this);
+      this.target = initTarget();
   }
   
   public Object getProperty(Property property) {



Mime
View raw message