From 3bda8fbe10e0710c2ab8ae720cfa6cbaebeac249 Mon Sep 17 00:00:00 2001 From: jonyangx Date: Sat, 7 Jan 2023 10:41:41 +0800 Subject: [PATCH] fix checkstyle check error --- .../eventmesh/runtime/util/WebhookUtil.java | 16 ++++++++-------- .../eventmesh/runtime/util/WebhookUtilTest.java | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/util/WebhookUtil.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/util/WebhookUtil.java index aa885b2a31..2cc760b832 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/util/WebhookUtil.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/util/WebhookUtil.java @@ -32,17 +32,15 @@ import java.util.Objects; import java.util.concurrent.ConcurrentHashMap; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; /** * Utility class for implementing CloudEvents Http Webhook spec * * @see CloudEvents Http Webhook */ +@Slf4j public class WebhookUtil { - private static final Logger LOGGER = LoggerFactory.getLogger(WebhookUtil.class); - private static final String CONTENT_TYPE_HEADER = "Content-Type"; private static final String REQUEST_ORIGIN_HEADER = "WebHook-Request-Origin"; private static final String ALLOWED_ORIGIN_HEADER = "WebHook-Allowed-Origin"; @@ -53,8 +51,8 @@ public static boolean obtainDeliveryAgreement(final CloseableHttpClient httpClie final String targetUrl, final String requestOrigin) { - if (LOGGER.isInfoEnabled()) { - LOGGER.info("obtain webhook delivery agreement for url: {}", targetUrl); + if (log.isInfoEnabled()) { + log.info("obtain webhook delivery agreement for url: {}", targetUrl); } final HttpOptions builder = new HttpOptions(targetUrl); @@ -65,8 +63,10 @@ public static boolean obtainDeliveryAgreement(final CloseableHttpClient httpClie return StringUtils.isEmpty(allowedOrigin) || "*".equals(allowedOrigin) || allowedOrigin.equalsIgnoreCase(requestOrigin); } catch (Exception e) { - LOGGER.error("HTTP Options Method is not supported at the Delivery Target: {}, " - + "unable to obtain the webhook delivery agreement.", targetUrl); + if (log.isErrorEnabled()) { + log.error("HTTP Options Method is not supported at the Delivery Target: {}, " + + "unable to obtain the webhook delivery agreement.", targetUrl); + } } return true; } diff --git a/eventmesh-runtime/src/test/java/org/apache/eventmesh/runtime/util/WebhookUtilTest.java b/eventmesh-runtime/src/test/java/org/apache/eventmesh/runtime/util/WebhookUtilTest.java index 945b9e804c..9acd032f88 100644 --- a/eventmesh-runtime/src/test/java/org/apache/eventmesh/runtime/util/WebhookUtilTest.java +++ b/eventmesh-runtime/src/test/java/org/apache/eventmesh/runtime/util/WebhookUtilTest.java @@ -47,8 +47,8 @@ public void testObtainDeliveryAgreement() { CloseableHttpResponse response = mock(CloseableHttpResponse.class); CloseableHttpClient httpClient2 = mock(CloseableHttpClient.class)) { - Mockito.when(response.getLastHeader("WebHook-Allowed-Origin")). - thenReturn(new BasicHeader("WebHook-Allowed-Origin", "*")); + Mockito.when(response.getLastHeader("WebHook-Allowed-Origin")) + .thenReturn(new BasicHeader("WebHook-Allowed-Origin", "*")); Mockito.when(httpClient.execute(any())).thenReturn(response); Assert.assertTrue("match logic must return true", WebhookUtil.obtainDeliveryAgreement(httpClient, "https://eventmesh.apache.org", "*"));