cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject git commit: Minor updates to MessageUtils and ExceptionUtils
Date Mon, 03 Nov 2014 11:56:54 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes a1e910583 -> 7788a9465


Minor updates to MessageUtils and ExceptionUtils


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/7788a946
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/7788a946
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/7788a946

Branch: refs/heads/3.0.x-fixes
Commit: 7788a9465727e0effb79b94d21b43a0303522bb8
Parents: a1e9105
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Mon Nov 3 11:55:03 2014 +0000
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Mon Nov 3 11:56:25 2014 +0000

----------------------------------------------------------------------
 .../main/java/org/apache/cxf/message/MessageUtils.java   |  2 +-
 .../cxf/jaxrs/impl/WebApplicationExceptionMapper.java    | 11 ++---------
 .../apache/cxf/jaxrs/provider/AbstractJAXBProvider.java  |  9 +--------
 .../apache/cxf/jaxrs/provider/JAXBElementProvider.java   |  2 +-
 .../java/org/apache/cxf/jaxrs/utils/ExceptionUtils.java  |  9 +++++++++
 5 files changed, 14 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/7788a946/core/src/main/java/org/apache/cxf/message/MessageUtils.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/message/MessageUtils.java b/core/src/main/java/org/apache/cxf/message/MessageUtils.java
index a6cf993..d8bbf0c 100644
--- a/core/src/main/java/org/apache/cxf/message/MessageUtils.java
+++ b/core/src/main/java/org/apache/cxf/message/MessageUtils.java
@@ -134,7 +134,7 @@ public final class MessageUtils {
     public static Object getContextualProperty(Message m, String propPreferred, String propDefault)
{
         Object prop = m.getContextualProperty(propPreferred);
         if (prop == null && propDefault != null) {
-            prop = (String)m.getContextualProperty(propDefault);
+            prop = m.getContextualProperty(propDefault);
         }
         return prop;
     }

http://git-wip-us.apache.org/repos/asf/cxf/blob/7788a946/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/WebApplicationExceptionMapper.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/WebApplicationExceptionMapper.java
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/WebApplicationExceptionMapper.java
index 723edd0..bbc0bfc 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/WebApplicationExceptionMapper.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/WebApplicationExceptionMapper.java
@@ -19,8 +19,6 @@
 
 package org.apache.cxf.jaxrs.impl;
 
-import java.io.PrintWriter;
-import java.io.StringWriter;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
@@ -30,6 +28,7 @@ import javax.ws.rs.core.Response;
 import javax.ws.rs.ext.ExceptionMapper;
 
 import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.jaxrs.utils.ExceptionUtils;
 import org.apache.cxf.jaxrs.utils.JAXRSUtils;
 import org.apache.cxf.logging.FaultListener;
 import org.apache.cxf.message.Message;
@@ -70,7 +69,7 @@ public class WebApplicationExceptionMapper
         if (flogger == null
             || !flogger.faultOccurred(ex, errorMessage, msg)) {
             Level level = printStackTrace ? Level.WARNING : Level.FINE;
-            LOG.log(level, getStackTrace(ex));
+            LOG.log(level, ExceptionUtils.getStackTrace(ex));
         }
         
         if (doAddMessage) {
@@ -95,12 +94,6 @@ public class WebApplicationExceptionMapper
         return sb.toString();
     }
     
-    private static String getStackTrace(Exception ex) { 
-        StringWriter sw = new StringWriter();
-        ex.printStackTrace(new PrintWriter(sw));
-        return sw.toString();
-    }
-
     /**
      * Control whether to log at WARN or FINE level.
      * Note this property is ignored if a registered {@link FaultListener} 

http://git-wip-us.apache.org/repos/asf/cxf/blob/7788a946/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
index e1c7bdd..8105259 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
@@ -22,8 +22,6 @@ package org.apache.cxf.jaxrs.provider;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
-import java.io.PrintWriter;
-import java.io.StringWriter;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Array;
 import java.lang.reflect.Type;
@@ -700,14 +698,9 @@ public abstract class AbstractJAXBProvider<T> extends AbstractConfigurableProvid
         packageContexts.clear();
     }
     
-    protected static String getStackTrace(Exception ex) { 
-        StringWriter sw = new StringWriter();
-        ex.printStackTrace(new PrintWriter(sw));
-        return sw.toString();
-    }
     //TODO: move these methods into the dedicated utility class
     protected static StringBuilder handleExceptionStart(Exception e) {
-        LOG.warning(getStackTrace(e));
+        LOG.warning(ExceptionUtils.getStackTrace(e));
         StringBuilder sb = new StringBuilder();
         if (e.getMessage() != null) {
             sb.append(e.getMessage()).append(". ");

http://git-wip-us.apache.org/repos/asf/cxf/blob/7788a946/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
index 3ea8d50..723ea0b 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
@@ -209,7 +209,7 @@ public class JAXBElementProvider<T> extends AbstractJAXBProvider<T>
 {
         } catch (WebApplicationException e) {
             throw e;
         } catch (Exception e) {
-            LOG.warning(getStackTrace(e));
+            LOG.warning(ExceptionUtils.getStackTrace(e));
             throw ExceptionUtils.toBadRequestException(e, null);        
         } finally {
             try {

http://git-wip-us.apache.org/repos/asf/cxf/blob/7788a946/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ExceptionUtils.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ExceptionUtils.java
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ExceptionUtils.java
index ed56966..20977ee 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ExceptionUtils.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ExceptionUtils.java
@@ -19,6 +19,9 @@
 
 package org.apache.cxf.jaxrs.utils;
 
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
 import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.ext.ExceptionMapper;
@@ -34,6 +37,12 @@ public final class ExceptionUtils {
     private ExceptionUtils() {        
     }
     
+    public static String getStackTrace(Throwable ex) { 
+        StringWriter sw = new StringWriter();
+        ex.printStackTrace(new PrintWriter(sw));
+        return sw.toString();
+    }
+    
     public static Class<?> getWebApplicationExceptionClass(Response exResponse,
                                                            Class<?> defaultExceptionType)
{
         return SpecExceptions.getWebApplicationExceptionClass(exResponse, defaultExceptionType);


Mime
View raw message