You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2019/10/11 10:49:27 UTC
[camel] branch master updated (adfacf4 -> 1c114d8)
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git.
from adfacf4 CAMEL-14025: add muteException option on camel-undertow component (#3236)
new eab9046 CAMEL-14025: Fixed CS
new 1c114d8 CAMEL-14025: Add muteException as global option on undertow component so you can easily turn this on
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../camel-undertow/src/main/docs/undertow-component.adoc | 3 ++-
.../component/undertow/DefaultUndertowHttpBinding.java | 7 ++-----
.../apache/camel/component/undertow/UndertowComponent.java | 14 ++++++++++++++
.../apache/camel/component/undertow/UndertowEndpoint.java | 6 +++---
.../camel/component/undertow/UndertowHttpBinding.java | 2 +-
.../component/undertow/UndertowMuteExceptionTest.java | 9 ++-------
.../endpoint/dsl/UndertowEndpointBuilderFactory.java | 7 +++----
.../springboot/UndertowComponentConfiguration.java | 13 +++++++++++++
8 files changed, 40 insertions(+), 21 deletions(-)
[camel] 02/02: CAMEL-14025: Add muteException as global option on
undertow component so you can easily turn this on
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 1c114d872b5268a9d358877e0c4cfcdfbd7a0be4
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Oct 11 12:49:10 2019 +0200
CAMEL-14025: Add muteException as global option on undertow component so you can easily turn this on
---
.../camel-undertow/src/main/docs/undertow-component.adoc | 3 ++-
.../apache/camel/component/undertow/UndertowComponent.java | 14 ++++++++++++++
.../apache/camel/component/undertow/UndertowEndpoint.java | 1 -
.../endpoint/dsl/UndertowEndpointBuilderFactory.java | 7 +++----
.../springboot/UndertowComponentConfiguration.java | 13 +++++++++++++
5 files changed, 32 insertions(+), 6 deletions(-)
diff --git a/components/camel-undertow/src/main/docs/undertow-component.adoc b/components/camel-undertow/src/main/docs/undertow-component.adoc
index 060f44f..e39185d 100644
--- a/components/camel-undertow/src/main/docs/undertow-component.adoc
+++ b/components/camel-undertow/src/main/docs/undertow-component.adoc
@@ -43,7 +43,7 @@ You can append query options to the URI in the following format,
== Options
// component options: START
-The Undertow component supports 5 options, which are listed below.
+The Undertow component supports 6 options, which are listed below.
@@ -54,6 +54,7 @@ The Undertow component supports 5 options, which are listed below.
| *sslContextParameters* (security) | To configure security using SSLContextParameters | | SSLContextParameters
| *useGlobalSslContext Parameters* (security) | Enable usage of global SSL context parameters. | false | boolean
| *hostOptions* (advanced) | To configure common options, such as thread pools | | UndertowHostOptions
+| *muteException* (consumer) | If enabled and an Exchange failed processing on the consumer side the response's body won't contain the exception's stack trace. | false | boolean
| *basicPropertyBinding* (advanced) | Whether the component should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities | false | boolean
|===
// component options: END
diff --git a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowComponent.java b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowComponent.java
index faa2b4c..7468b7e 100644
--- a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowComponent.java
+++ b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowComponent.java
@@ -69,6 +69,8 @@ public class UndertowComponent extends DefaultComponent implements RestConsumerF
private boolean useGlobalSslContextParameters;
@Metadata(label = "advanced")
private UndertowHostOptions hostOptions;
+ @Metadata(label = "consumer", defaultValue = "false")
+ private boolean muteException;
public UndertowComponent() {
this(null);
@@ -98,6 +100,7 @@ public class UndertowComponent extends DefaultComponent implements RestConsumerF
UndertowEndpoint endpoint = createEndpointInstance(endpointUri, this);
// set options from component
endpoint.setSslContextParameters(sslParams);
+ endpoint.setMuteException(muteException);
// Prefer endpoint configured over component configured
if (undertowHttpBinding == null) {
// fallback to component configured
@@ -395,6 +398,17 @@ public class UndertowComponent extends DefaultComponent implements RestConsumerF
this.hostOptions = hostOptions;
}
+ public boolean isMuteException() {
+ return muteException;
+ }
+
+ /**
+ * If enabled and an Exchange failed processing on the consumer side the response's body won't contain the exception's stack trace.
+ */
+ public void setMuteException(boolean muteException) {
+ this.muteException = muteException;
+ }
+
public ComponentVerifierExtension getVerifier() {
return (scope, parameters) -> getExtension(ComponentVerifierExtension.class).orElseThrow(UnsupportedOperationException::new).verify(scope, parameters);
}
diff --git a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowEndpoint.java b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowEndpoint.java
index f2932e7..b4643ff 100644
--- a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowEndpoint.java
+++ b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowEndpoint.java
@@ -262,7 +262,6 @@ public class UndertowEndpoint extends DefaultEndpoint implements AsyncEndpoint,
/**
* If enabled and an Exchange failed processing on the consumer side the response's body won't contain the exception's stack trace.
- *
*/
public void setMuteException(Boolean muteException) {
this.muteException = muteException;
diff --git a/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/UndertowEndpointBuilderFactory.java b/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/UndertowEndpointBuilderFactory.java
index fb84b0c..510846c 100644
--- a/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/UndertowEndpointBuilderFactory.java
+++ b/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/UndertowEndpointBuilderFactory.java
@@ -184,12 +184,12 @@ public interface UndertowEndpointBuilderFactory {
* If enabled and an Exchange failed processing on the consumer side the
* response's body won't contain the exception's stack trace.
*
- * The option is a: <code>java.lang.Boolean</code> type.
+ * The option is a: <code>boolean</code> type.
*
* Group: consumer
*/
default UndertowEndpointConsumerBuilder muteException(
- Boolean muteException) {
+ boolean muteException) {
doSetProperty("muteException", muteException);
return this;
}
@@ -197,8 +197,7 @@ public interface UndertowEndpointBuilderFactory {
* If enabled and an Exchange failed processing on the consumer side the
* response's body won't contain the exception's stack trace.
*
- * The option will be converted to a <code>java.lang.Boolean</code>
- * type.
+ * The option will be converted to a <code>boolean</code> type.
*
* Group: consumer
*/
diff --git a/platforms/spring-boot/components-starter/camel-undertow-starter/src/main/java/org/apache/camel/component/undertow/springboot/UndertowComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-undertow-starter/src/main/java/org/apache/camel/component/undertow/springboot/UndertowComponentConfiguration.java
index a029ce6..56e6d3f 100644
--- a/platforms/spring-boot/components-starter/camel-undertow-starter/src/main/java/org/apache/camel/component/undertow/springboot/UndertowComponentConfiguration.java
+++ b/platforms/spring-boot/components-starter/camel-undertow-starter/src/main/java/org/apache/camel/component/undertow/springboot/UndertowComponentConfiguration.java
@@ -57,6 +57,11 @@ public class UndertowComponentConfiguration
*/
private UndertowHostOptionsNestedConfiguration hostOptions;
/**
+ * If enabled and an Exchange failed processing on the consumer side the
+ * response's body won't contain the exception's stack trace.
+ */
+ private Boolean muteException = false;
+ /**
* Whether the component should use basic property binding (Camel 2.x) or
* the newer property binding with additional capabilities
*/
@@ -96,6 +101,14 @@ public class UndertowComponentConfiguration
this.hostOptions = hostOptions;
}
+ public Boolean getMuteException() {
+ return muteException;
+ }
+
+ public void setMuteException(Boolean muteException) {
+ this.muteException = muteException;
+ }
+
public Boolean getBasicPropertyBinding() {
return basicPropertyBinding;
}
[camel] 01/02: CAMEL-14025: Fixed CS
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
commit eab9046e4156f96ae16778b2693ba07e292b1aac
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Oct 11 12:45:53 2019 +0200
CAMEL-14025: Fixed CS
---
.../camel/component/undertow/DefaultUndertowHttpBinding.java | 7 ++-----
.../org/apache/camel/component/undertow/UndertowEndpoint.java | 5 +++--
.../org/apache/camel/component/undertow/UndertowHttpBinding.java | 2 +-
.../camel/component/undertow/UndertowMuteExceptionTest.java | 9 ++-------
4 files changed, 8 insertions(+), 15 deletions(-)
diff --git a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/DefaultUndertowHttpBinding.java b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/DefaultUndertowHttpBinding.java
index f04f6d0..778e6a2 100644
--- a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/DefaultUndertowHttpBinding.java
+++ b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/DefaultUndertowHttpBinding.java
@@ -47,7 +47,6 @@ import org.apache.camel.Message;
import org.apache.camel.TypeConverter;
import org.apache.camel.attachment.AttachmentMessage;
import org.apache.camel.attachment.DefaultAttachment;
-import org.apache.camel.attachment.DefaultAttachmentMessage;
import org.apache.camel.spi.HeaderFilterStrategy;
import org.apache.camel.support.DefaultMessage;
import org.apache.camel.support.ExchangeHelper;
@@ -375,10 +374,8 @@ public class DefaultUndertowHttpBinding implements UndertowHttpBinding {
// and mark the exception as failure handled, as we handled it by returning it as the response
ExchangeHelper.setFailureHandled(message.getExchange());
- }
- else if (exception != null && isMuteException()) {
-
- // mark the exception as failure handled, as we handled it by actively muting it
+ } else if (exception != null && isMuteException()) {
+ // mark the exception as failure handled, as we handled it by actively muting it
ExchangeHelper.setFailureHandled(message.getExchange());
}
diff --git a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowEndpoint.java b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowEndpoint.java
index bf1b934..f2932e7 100644
--- a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowEndpoint.java
+++ b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowEndpoint.java
@@ -16,12 +16,13 @@
*/
package org.apache.camel.component.undertow;
-import io.undertow.server.HttpServerExchange;
-import io.undertow.server.handlers.accesslog.AccessLogReceiver;
import java.net.URI;
import java.util.Locale;
import java.util.Map;
import javax.net.ssl.SSLContext;
+
+import io.undertow.server.HttpServerExchange;
+import io.undertow.server.handlers.accesslog.AccessLogReceiver;
import org.apache.camel.AsyncEndpoint;
import org.apache.camel.Consumer;
import org.apache.camel.Exchange;
diff --git a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowHttpBinding.java b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowHttpBinding.java
index e0f03c9..17c35c8 100644
--- a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowHttpBinding.java
+++ b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowHttpBinding.java
@@ -48,6 +48,6 @@ public interface UndertowHttpBinding {
void setTransferException(Boolean transferException);
- void setMuteException(Boolean MuteException);
+ void setMuteException(Boolean muteException);
}
diff --git a/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/UndertowMuteExceptionTest.java b/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/UndertowMuteExceptionTest.java
index 5fe5d37..970815e 100644
--- a/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/UndertowMuteExceptionTest.java
+++ b/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/UndertowMuteExceptionTest.java
@@ -22,13 +22,10 @@ import org.apache.commons.httpclient.methods.GetMethod;
import org.junit.Assert;
import org.junit.Test;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-
public class UndertowMuteExceptionTest extends BaseUndertowTest {
@Test
- public void muteExceptionTest() throws IOException, ClassNotFoundException {
+ public void muteExceptionTest() throws Exception {
HttpClient client = new HttpClient();
GetMethod get = new GetMethod("http://localhost:" + getPort() + "/test/mute");
get.setRequestHeader("Accept", "application/text");
@@ -40,9 +37,8 @@ public class UndertowMuteExceptionTest extends BaseUndertowTest {
Assert.assertEquals(500, get.getStatusCode());
}
-
@Test
- public void muteExceptionWithTransferExceptionTest() throws IOException, ClassNotFoundException {
+ public void muteExceptionWithTransferExceptionTest() throws Exception {
HttpClient client = new HttpClient();
GetMethod get = new GetMethod("http://localhost:" + getPort() + "/test/muteWithTransfer");
get.setRequestHeader("Accept", "application/text");
@@ -59,7 +55,6 @@ public class UndertowMuteExceptionTest extends BaseUndertowTest {
return new RouteBuilder() {
public void configure() {
-
from("undertow:http://localhost:" + getPort() + "/test/mute?muteException=true").to("mock:input")
.throwException(new IllegalArgumentException("Camel cannot do this"));