You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by or...@apache.org on 2023/11/29 10:20:46 UTC
(camel) 01/06: CAMEL-20163: consolidate duplicated logging code
This is an automated email from the ASF dual-hosted git repository.
orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 66945c13aa25765ba8502328afbb306a616cc5ea
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Wed Nov 29 05:39:56 2023 +0100
CAMEL-20163: consolidate duplicated logging code
---
.../netty/http/HttpClientInitializerFactory.java | 10 +-----
.../netty/http/HttpServerInitializerFactory.java | 12 ++-----
.../component/netty/http/InitializerHelper.java | 42 ++++++++++++++++++++++
3 files changed, 46 insertions(+), 18 deletions(-)
diff --git a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpClientInitializerFactory.java b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpClientInitializerFactory.java
index 2a0bc816f49..1e022ae112d 100644
--- a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpClientInitializerFactory.java
+++ b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpClientInitializerFactory.java
@@ -150,15 +150,7 @@ public class HttpClientInitializerFactory extends ClientInitializerFactory {
sniServerNames = answer.getSupportedSSLParameters().getServerNames();
}
} else {
- if (configuration.getKeyStoreFile() == null && configuration.getKeyStoreResource() == null) {
- LOG.debug("keystorefile is null");
- }
- if (configuration.getTrustStoreFile() == null && configuration.getTrustStoreResource() == null) {
- LOG.debug("truststorefile is null");
- }
- if (configuration.getPassphrase() == null) {
- LOG.debug("passphrase is null");
- }
+ InitializerHelper.logConfiguration(configuration);
char[] pw = configuration.getPassphrase() != null ? configuration.getPassphrase().toCharArray() : null;
SSLEngineFactory sslEngineFactory;
diff --git a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerInitializerFactory.java b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerInitializerFactory.java
index 3badc6b9246..4d5a33ddbd3 100644
--- a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerInitializerFactory.java
+++ b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerInitializerFactory.java
@@ -42,6 +42,8 @@ import org.apache.camel.component.netty.ssl.SSLEngineFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import static org.apache.camel.component.netty.http.InitializerHelper.logConfiguration;
+
/**
* {@link ServerInitializerFactory} for the Netty HTTP server.
*/
@@ -147,15 +149,7 @@ public class HttpServerInitializerFactory extends ServerInitializerFactory {
if (configuration.getSslContextParameters() != null) {
answer = configuration.getSslContextParameters().createSSLContext(camelContext);
} else {
- if (configuration.getKeyStoreFile() == null && configuration.getKeyStoreResource() == null) {
- LOG.debug("keystorefile is null");
- }
- if (configuration.getTrustStoreFile() == null && configuration.getTrustStoreResource() == null) {
- LOG.debug("truststorefile is null");
- }
- if (configuration.getPassphrase() == null) {
- LOG.debug("passphrase is null");
- }
+ logConfiguration(configuration);
char[] pw = configuration.getPassphrase() != null ? configuration.getPassphrase().toCharArray() : null;
SSLEngineFactory sslEngineFactory;
diff --git a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/InitializerHelper.java b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/InitializerHelper.java
new file mode 100644
index 00000000000..b59e230bd3f
--- /dev/null
+++ b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/InitializerHelper.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.camel.component.netty.http;
+
+import org.apache.camel.component.netty.NettyServerBootstrapConfiguration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public final class InitializerHelper {
+ private static final Logger LOG = LoggerFactory.getLogger(InitializerHelper.class);
+
+ private InitializerHelper() {
+
+ }
+
+ static void logConfiguration(NettyServerBootstrapConfiguration configuration) {
+ if (configuration.getKeyStoreFile() == null && configuration.getKeyStoreResource() == null) {
+ LOG.debug("keystorefile is null");
+ }
+ if (configuration.getTrustStoreFile() == null && configuration.getTrustStoreResource() == null) {
+ LOG.debug("truststorefile is null");
+ }
+ if (configuration.getPassphrase() == null) {
+ LOG.debug("passphrase is null");
+ }
+ }
+}