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 2014/06/12 16:54:22 UTC
git commit: [CXF-5761] When pretty writing,
ignore any errors as they could be caused by the truncation Also
unify the limits
Repository: cxf
Updated Branches:
refs/heads/master afd049257 -> 5ec1b6025
[CXF-5761] When pretty writing, ignore any errors as they could be caused by the truncation
Also unify the limits
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/5ec1b602
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/5ec1b602
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/5ec1b602
Branch: refs/heads/master
Commit: 5ec1b6025d1fd35157b7ce862198c61a7810e499
Parents: afd0492
Author: Daniel Kulp <dk...@apache.org>
Authored: Thu Jun 12 10:53:42 2014 -0400
Committer: Daniel Kulp <dk...@apache.org>
Committed: Thu Jun 12 10:53:42 2014 -0400
----------------------------------------------------------------------
.../org/apache/cxf/annotations/Logging.java | 4 +++-
.../org/apache/cxf/feature/LoggingFeature.java | 3 ++-
.../interceptor/AbstractLoggingInterceptor.java | 22 ++++++++++++++------
3 files changed, 21 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf/blob/5ec1b602/core/src/main/java/org/apache/cxf/annotations/Logging.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/annotations/Logging.java b/core/src/main/java/org/apache/cxf/annotations/Logging.java
index 172bff7..9c1b2f7 100644
--- a/core/src/main/java/org/apache/cxf/annotations/Logging.java
+++ b/core/src/main/java/org/apache/cxf/annotations/Logging.java
@@ -25,6 +25,8 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
+import org.apache.cxf.interceptor.AbstractLoggingInterceptor;
+
/**
* Enables message Logging
*/
@@ -35,7 +37,7 @@ public @interface Logging {
/**
* The size limit at which messages are truncated in the log
*/
- int limit() default 65536;
+ int limit() default AbstractLoggingInterceptor.DEFAULT_LIMIT;
/**
* the locations where the messages are logged. The default is
http://git-wip-us.apache.org/repos/asf/cxf/blob/5ec1b602/core/src/main/java/org/apache/cxf/feature/LoggingFeature.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/feature/LoggingFeature.java b/core/src/main/java/org/apache/cxf/feature/LoggingFeature.java
index 9582838..4a0c028 100644
--- a/core/src/main/java/org/apache/cxf/feature/LoggingFeature.java
+++ b/core/src/main/java/org/apache/cxf/feature/LoggingFeature.java
@@ -21,6 +21,7 @@ package org.apache.cxf.feature;
import org.apache.cxf.Bus;
import org.apache.cxf.annotations.Logging;
import org.apache.cxf.common.injection.NoJSR250Annotations;
+import org.apache.cxf.interceptor.AbstractLoggingInterceptor;
import org.apache.cxf.interceptor.InterceptorProvider;
import org.apache.cxf.interceptor.LoggingInInterceptor;
import org.apache.cxf.interceptor.LoggingOutInterceptor;
@@ -42,7 +43,7 @@ import org.apache.cxf.interceptor.LoggingOutInterceptor;
*/
@NoJSR250Annotations
public class LoggingFeature extends AbstractFeature {
- private static final int DEFAULT_LIMIT = 64 * 1024;
+ private static final int DEFAULT_LIMIT = AbstractLoggingInterceptor.DEFAULT_LIMIT;
private static final LoggingInInterceptor IN = new LoggingInInterceptor(DEFAULT_LIMIT);
private static final LoggingOutInterceptor OUT = new LoggingOutInterceptor(DEFAULT_LIMIT);
http://git-wip-us.apache.org/repos/asf/cxf/blob/5ec1b602/core/src/main/java/org/apache/cxf/interceptor/AbstractLoggingInterceptor.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/interceptor/AbstractLoggingInterceptor.java b/core/src/main/java/org/apache/cxf/interceptor/AbstractLoggingInterceptor.java
index b43f0d5..996ce60 100644
--- a/core/src/main/java/org/apache/cxf/interceptor/AbstractLoggingInterceptor.java
+++ b/core/src/main/java/org/apache/cxf/interceptor/AbstractLoggingInterceptor.java
@@ -31,6 +31,7 @@ import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
+import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
import javax.xml.transform.stream.StreamSource;
@@ -50,7 +51,7 @@ import org.apache.cxf.staxutils.StaxUtils;
* Logger.
*/
public abstract class AbstractLoggingInterceptor extends AbstractPhaseInterceptor<Message> {
-
+ public static final int DEFAULT_LIMIT = 48 * 1024;
protected static final String BINARY_CONTENT_MESSAGE = "--- Binary Content ---";
private static final List<String> BINARY_CONTENT_MEDIA_TYPES;
static {
@@ -61,7 +62,7 @@ public abstract class AbstractLoggingInterceptor extends AbstractPhaseIntercepto
BINARY_CONTENT_MEDIA_TYPES.add("image/gif");
}
- protected int limit = 48 * 1024;
+ protected int limit = DEFAULT_LIMIT;
protected long threshold = -1;
protected PrintWriter writer;
protected boolean prettyLogging;
@@ -160,9 +161,19 @@ public abstract class AbstractLoggingInterceptor extends AbstractPhaseIntercepto
XMLStreamWriter xwriter = StaxUtils.createXMLStreamWriter(swriter);
xwriter = new PrettyPrintXMLStreamWriter(xwriter, 2);
InputStream in = cos.getInputStream();
- StaxUtils.copy(new StreamSource(in), xwriter);
- xwriter.close();
- in.close();
+ try {
+ StaxUtils.copy(new StreamSource(in), xwriter);
+ } catch (XMLStreamException xse) {
+ //ignore
+ } finally {
+ try {
+ xwriter.flush();
+ xwriter.close();
+ } catch (XMLStreamException xse2) {
+ //ignore
+ }
+ in.close();
+ }
String result = swriter.toString();
if (result.length() < limit || limit == -1) {
@@ -177,7 +188,6 @@ public abstract class AbstractLoggingInterceptor extends AbstractPhaseIntercepto
} else {
cos.writeCacheTo(builder, encoding, limit);
}
-
}
}
protected void writePayload(StringBuilder builder,