cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1442125 - in /cxf/branches/2.7.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
Date Mon, 04 Feb 2013 14:10:28 GMT
Author: sergeyb
Date: Mon Feb  4 14:10:28 2013
New Revision: 1442125

URL: http://svn.apache.org/viewvc?rev=1442125&view=rev
Log:
Merged revisions 1442076,1442121 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1442076 | sergeyb | 2013-02-04 11:14:52 +0000 (Mon, 04 Feb 2013) | 1 line
  
  Minor fix to InjectionUtils
........
  r1442121 | sergeyb | 2013-02-04 14:05:56 +0000 (Mon, 04 Feb 2013) | 1 line
  
  Making sure 2.0 filters can be re-entered if the exception has been mapped
........

Modified:
    cxf/branches/2.7.x-fixes/   (props changed)
    cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
    cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java

Propchange: cxf/branches/2.7.x-fixes/
------------------------------------------------------------------------------
  Merged /cxf/trunk:r1442076,1442121

Propchange: cxf/branches/2.7.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java?rev=1442125&r1=1442124&r2=1442125&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
Mon Feb  4 14:10:28 2013
@@ -35,6 +35,7 @@ import java.util.logging.Level;
 import java.util.logging.Logger;
 
 import javax.servlet.http.HttpServletResponse;
+import javax.ws.rs.InternalServerErrorException;
 import javax.ws.rs.container.AsyncResponse;
 import javax.ws.rs.core.GenericEntity;
 import javax.ws.rs.core.HttpHeaders;
@@ -132,6 +133,21 @@ public class JAXRSOutInterceptor extends
         OperationResourceInfo ori = (OperationResourceInfo)exchange.get(OperationResourceInfo.class
             .getName());
         
+        boolean retryHappened = false;
+        try {
+            response = runResponseFilters(providerFactory, message, response, ori);
+        } catch (Throwable ex) {
+            response = handleFilterException(providerFactory, message, response, ori, ex);
+            retryHappened = true;
+        }
+        
+        serializeMessage(message, response, ori, !retryHappened);        
+    }
+
+    private Response runResponseFilters(ProviderFactory providerFactory,
+                                Message message, 
+                                Response response, 
+                                OperationResourceInfo ori) {
         // Global post-match and name-bound response filters
         JAXRSUtils.runContainerResponseFilters(providerFactory, response, message, ori);
         Response updatedResponse = message.get(Response.class);
@@ -139,7 +155,6 @@ public class JAXRSOutInterceptor extends
             response = updatedResponse;
         }
         
-        
         List<ProviderInfo<ResponseHandler>> handlers = 
             ProviderFactory.getInstance(message).getResponseHandlers();
         for (ProviderInfo<ResponseHandler> rh : handlers) {
@@ -151,10 +166,9 @@ public class JAXRSOutInterceptor extends
             }
             
         }
-        
-        serializeMessage(message, response, ori, true);        
+        return response;
     }
-
+    
     private int getStatus(Message message, int defaultValue) {
         Object customStatus = message.getExchange().get(Message.RESPONSE_CODE);
         return customStatus == null ? defaultValue : (Integer)customStatus;
@@ -356,6 +370,18 @@ public class JAXRSOutInterceptor extends
         }
     }
     
+    private Response handleFilterException(ProviderFactory pf,
+                                       Message message, 
+                                       Response response, 
+                                       OperationResourceInfo ori,
+                                       Throwable ex) {
+        Response excResponse = JAXRSUtils.convertFaultToResponse(ex, message);
+        if (excResponse != null) {
+            return runResponseFilters(pf, message, excResponse, ori);
+        }
+        throw new InternalServerErrorException(ex);
+    }
+    
     private void handleWriteException(Message message, 
                                          Response response, 
                                          OperationResourceInfo ori,

Modified: cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java?rev=1442125&r1=1442124&r2=1442125&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
Mon Feb  4 14:10:28 2013
@@ -51,9 +51,9 @@ import java.util.TreeSet;
 import java.util.logging.Logger;
 
 import javax.ws.rs.BadRequestException;
+import javax.ws.rs.ClientErrorException;
 import javax.ws.rs.InternalServerErrorException;
 import javax.ws.rs.NotFoundException;
-import javax.ws.rs.ServerErrorException;
 import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.Application;
 import javax.ws.rs.core.HttpHeaders;
@@ -348,7 +348,7 @@ public final class InjectionUtils {
                 LOG.severe(new org.apache.cxf.common.i18n.Message("CLASS_CONSTRUCTOR_FAILURE",

                                                                    BUNDLE, 
                                                                    pClass.getName()).toString());
-                throw new ServerErrorException(HttpUtils.getParameterFailureStatus(pType),
ex);
+                throw new ClientErrorException(HttpUtils.getParameterFailureStatus(pType),
ex);
             }
         }
         if (result == null) {



Mime
View raw message