You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2009/10/06 23:12:41 UTC

svn commit: r822501 - in /cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet: ServletController.java ServletDestination.java ServletTransportFactory.java

Author: dkulp
Date: Tue Oct  6 21:12:40 2009
New Revision: 822501

URL: http://svn.apache.org/viewvc?rev=822501&view=rev
Log:
[CXF-2301] Lookup the destination using a decoded URL as well to handle
differenced as to if it is registered encoded or decoded

Modified:
    cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletController.java
    cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletDestination.java
    cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletTransportFactory.java

Modified: cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletController.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletController.java?rev=822501&r1=822500&r2=822501&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletController.java (original)
+++ cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletController.java Tue Oct  6 21:12:40 2009
@@ -103,12 +103,11 @@
     public void invoke(HttpServletRequest request, HttpServletResponse res) throws ServletException {
         try {
             EndpointInfo ei = new EndpointInfo();
+            
             String address = request.getPathInfo() == null ? "" : request.getPathInfo();
-
             ei.setAddress(address);
             
             ServletDestination d = getDestination(ei.getAddress());
-            
             if (d == null) {
                 if (!isHideServiceList && (request.getRequestURI().endsWith(serviceListRelativePath)
                     || request.getRequestURI().endsWith(serviceListRelativePath + "/")
@@ -182,7 +181,7 @@
     }
     
     protected ServletDestination getDestination(String address) {
-        return (ServletDestination)transport.getDestinationForPath(address);
+        return (ServletDestination)transport.getDestinationForPath(address, true);
     }
     
     protected ServletDestination checkRestfulRequest(HttpServletRequest request) throws IOException {        

Modified: cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletDestination.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletDestination.java?rev=822501&r1=822500&r2=822501&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletDestination.java (original)
+++ cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletDestination.java Tue Oct  6 21:12:40 2009
@@ -102,7 +102,11 @@
     
     @Override
     public void shutdown() {
-        factory.removeDestination(path);
+        try {
+            factory.removeDestination(path);
+        } catch (IOException ex) {
+            //ignore
+        }
         
         super.shutdown();
     }

Modified: cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletTransportFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletTransportFactory.java?rev=822501&r1=822500&r2=822501&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletTransportFactory.java (original)
+++ cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletTransportFactory.java Tue Oct  6 21:12:40 2009
@@ -21,6 +21,7 @@
 package org.apache.cxf.transport.servlet;
 
 import java.io.IOException;
+import java.net.URLDecoder;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
@@ -44,6 +45,8 @@
     
     private Map<String, ServletDestination> destinations = 
         new ConcurrentHashMap<String, ServletDestination>();
+    private Map<String, ServletDestination> decodedDestinations = 
+        new ConcurrentHashMap<String, ServletDestination>();
     
     private ServletController controller;
     
@@ -72,8 +75,9 @@
         super.setBus(b);
     }
     
-    public void removeDestination(String path) {
+    public void removeDestination(String path) throws IOException {
         destinations.remove(path);
+        decodedDestinations.remove(URLDecoder.decode(path, "ISO-8859-1"));
     }
     
     public Destination getDestination(EndpointInfo endpointInfo)
@@ -83,6 +87,7 @@
             String path = getTrimmedPath(endpointInfo.getAddress());
             d = new ServletDestination(getBus(), endpointInfo, this, path);
             destinations.put(path, d);
+            decodedDestinations.put(URLDecoder.decode(path, "ISO-8859-1"), d);
             
             if (controller != null
                 && !StringUtils.isEmpty(controller.getLastBaseURL())) {
@@ -102,8 +107,16 @@
     }
     
     public ServletDestination getDestinationForPath(String path) {
+        return getDestinationForPath(path, false);
+    }
+    public ServletDestination getDestinationForPath(String path, boolean tryDecoding) {
         // to use the url context match  
-        return destinations.get(getTrimmedPath(path));
+        String m = getTrimmedPath(path);
+        ServletDestination s = destinations.get(m);
+        if (s == null) {
+            s = decodedDestinations.get(m);
+        }
+        return s;
     }
 
     static String getTrimmedPath(String path) {