Return-Path: X-Original-To: apmail-cxf-commits-archive@www.apache.org Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0761A11AFB for ; Thu, 12 Jun 2014 14:54:23 +0000 (UTC) Received: (qmail 56265 invoked by uid 500); 12 Jun 2014 14:54:22 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 56201 invoked by uid 500); 12 Jun 2014 14:54:22 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 56194 invoked by uid 99); 12 Jun 2014 14:54:22 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 Jun 2014 14:54:22 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 9A97048E47; Thu, 12 Jun 2014 14:54:22 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: dkulp@apache.org To: commits@cxf.apache.org Message-Id: <8dc0d0697d39498dacf2d144f7b2b021@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: git commit: [CXF-5761] When pretty writing, ignore any errors as they could be caused by the truncation Also unify the limits Date: Thu, 12 Jun 2014 14:54:22 +0000 (UTC) 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 Authored: Thu Jun 12 10:53:42 2014 -0400 Committer: Daniel Kulp 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 { - + public static final int DEFAULT_LIMIT = 48 * 1024; protected static final String BINARY_CONTENT_MESSAGE = "--- Binary Content ---"; private static final List 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,