You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by ff...@apache.org on 2020/07/07 18:49:03 UTC
[cxf] branch 3.3.x-fixes updated: [CXF-8257]Logger no longer logs
bad requests
This is an automated email from the ASF dual-hosted git repository.
ffang pushed a commit to branch 3.3.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git
The following commit(s) were added to refs/heads/3.3.x-fixes by this push:
new b91912b [CXF-8257]Logger no longer logs bad requests
b91912b is described below
commit b91912b83ba40195ecbbd72443a5e2e170bbcbf8
Author: Freeman Fang <fr...@gmail.com>
AuthorDate: Tue Jul 7 14:44:50 2020 -0400
[CXF-8257]Logger no longer logs bad requests
(cherry picked from commit da4046011a8f0c70bbbd25001b2e08ac49c853d0)
---
.../ext/logging/AbstractLoggingInterceptor.java | 2 +-
.../cxf/ext/logging/LoggingInInterceptor.java | 24 ++++++++++++++++++++++
2 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/rt/features/logging/src/main/java/org/apache/cxf/ext/logging/AbstractLoggingInterceptor.java b/rt/features/logging/src/main/java/org/apache/cxf/ext/logging/AbstractLoggingInterceptor.java
index 38f6d19..bc88e56 100644
--- a/rt/features/logging/src/main/java/org/apache/cxf/ext/logging/AbstractLoggingInterceptor.java
+++ b/rt/features/logging/src/main/java/org/apache/cxf/ext/logging/AbstractLoggingInterceptor.java
@@ -34,7 +34,7 @@ public abstract class AbstractLoggingInterceptor extends AbstractPhaseIntercepto
public static final int DEFAULT_LIMIT = 48 * 1024;
public static final int DEFAULT_THRESHOLD = -1;
public static final String CONTENT_SUPPRESSED = "--- Content suppressed ---";
- private static final String LIVE_LOGGING_PROP = "org.apache.cxf.logging.enable";
+ protected static final String LIVE_LOGGING_PROP = "org.apache.cxf.logging.enable";
protected int limit = DEFAULT_LIMIT;
protected long threshold = DEFAULT_THRESHOLD;
protected boolean logBinary;
diff --git a/rt/features/logging/src/main/java/org/apache/cxf/ext/logging/LoggingInInterceptor.java b/rt/features/logging/src/main/java/org/apache/cxf/ext/logging/LoggingInInterceptor.java
index 76ea59e..91704b7 100644
--- a/rt/features/logging/src/main/java/org/apache/cxf/ext/logging/LoggingInInterceptor.java
+++ b/rt/features/logging/src/main/java/org/apache/cxf/ext/logging/LoggingInInterceptor.java
@@ -34,6 +34,7 @@ import org.apache.cxf.interceptor.Fault;
import org.apache.cxf.io.CachedOutputStream;
import org.apache.cxf.io.CachedWriter;
import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.AbstractPhaseInterceptor;
import org.apache.cxf.phase.Phase;
import org.apache.cxf.phase.PhaseInterceptor;
@@ -42,6 +43,23 @@ import org.apache.cxf.phase.PhaseInterceptor;
*/
@NoJSR250Annotations
public class LoggingInInterceptor extends AbstractLoggingInterceptor {
+
+
+ class LoggingInFaultInterceptor extends AbstractPhaseInterceptor<Message> {
+ LoggingInFaultInterceptor() {
+ super(Phase.RECEIVE);
+ }
+
+ @Override
+ public void handleMessage(Message message) throws Fault {
+ }
+
+ @Override
+ public void handleFault(Message message) throws Fault {
+ LoggingInInterceptor.this.handleMessage(message);
+ }
+ }
+
public LoggingInInterceptor() {
this(new Slf4jVerboseEventSender());
@@ -58,12 +76,18 @@ public class LoggingInInterceptor extends AbstractLoggingInterceptor {
public Collection<PhaseInterceptor<? extends Message>> getAdditionalInterceptors() {
Collection<PhaseInterceptor<? extends Message>> ret = new ArrayList<>();
ret.add(new WireTapIn(getWireTapLimit(), threshold));
+ ret.add(new LoggingInFaultInterceptor());
return ret;
}
public void handleMessage(Message message) throws Fault {
if (isLoggingDisabledNow(message)) {
return;
+ } else {
+ //ensure only logging once for a certain message
+ //this can prevent message logging again when fault
+ //happen after PRE_INVOKE phase(rewind calls into LoggingInFaultInterceptor)
+ message.put(LIVE_LOGGING_PROP, Boolean.FALSE);
}
createExchangeId(message);
final LogEvent event = eventMapper.map(message);