This is an automated email from the ASF dual-hosted git repository.
ffang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cxf.git
The following commit(s) were added to refs/heads/master by this push:
new da40460 [CXF-8257]Logger no longer logs bad requests
new 77d1544 Merge branch 'master' of github.com:apache/cxf
da40460 is described below
commit da4046011a8f0c70bbbd25001b2e08ac49c853d0
Author: Freeman Fang <[email protected]>
AuthorDate: Tue Jul 7 14:44:50 2020 -0400
[CXF-8257]Logger no longer logs bad requests
---
.../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 9302a43..7927359 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 db677f0..a5ed555 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);