This is an automated email from the ASF dual-hosted git repository.
yui pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-shenyu.git
The following commit(s) were added to refs/heads/master by this push:
new 7b1aa6e <refactor> (<shenyu-web>) : [ISSUE #1866] remove lombok
dependency. (#1876)
7b1aa6e is described below
commit 7b1aa6eaa5e75208517d1c60b0be1962931daf4e
Author: JavaChain <[email protected]>
AuthorDate: Thu Aug 5 21:20:27 2021 +0800
<refactor> (<shenyu-web>) : [ISSUE #1866] remove lombok dependency. (#1876)
---
.../web/configuration/ShenyuConfiguration.java | 10 ++-
.../properties/ExcludePathProperties.java | 14 ++--
.../web/configuration/properties/ShenyuConfig.java | 74 +++++++++++++++++++++-
.../web/fallback/DefaultFallbackController.java | 12 ++--
.../forward/ForwardedRemoteAddressResolver.java | 27 ++++----
.../shenyu/web/handler/GlobalErrorHandler.java | 11 ++--
.../org/apache/shenyu/web/logo/ShenyuLogo.java | 12 ++--
7 files changed, 126 insertions(+), 34 deletions(-)
diff --git
a/shenyu-web/src/main/java/org/apache/shenyu/web/configuration/ShenyuConfiguration.java
b/shenyu-web/src/main/java/org/apache/shenyu/web/configuration/ShenyuConfiguration.java
index 3dbf047..57a98ed 100644
---
a/shenyu-web/src/main/java/org/apache/shenyu/web/configuration/ShenyuConfiguration.java
+++
b/shenyu-web/src/main/java/org/apache/shenyu/web/configuration/ShenyuConfiguration.java
@@ -17,7 +17,6 @@
package org.apache.shenyu.web.configuration;
-import lombok.extern.slf4j.Slf4j;
import org.apache.shenyu.web.configuration.properties.ShenyuConfig;
import org.apache.shenyu.web.configuration.properties.ExcludePathProperties;
import org.apache.shenyu.web.filter.CrossFilter;
@@ -33,6 +32,8 @@ import org.apache.shenyu.plugin.base.ParamTransformPlugin;
import org.apache.shenyu.plugin.base.cache.CommonPluginDataSubscriber;
import org.apache.shenyu.plugin.base.handler.PluginDataHandler;
import org.apache.shenyu.sync.data.api.PluginDataSubscriber;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.ObjectProvider;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
@@ -56,8 +57,11 @@ import java.util.stream.Collectors;
@Configuration
@ComponentScan("org.apache.shenyu")
@Import(value = {ErrorHandlerConfiguration.class,
ShenyuExtConfiguration.class, SpringExtConfiguration.class})
-@Slf4j
public class ShenyuConfiguration {
+ /**
+ * logger.
+ */
+ private static final Logger LOG =
LoggerFactory.getLogger(ShenyuConfiguration.class);
/**
* Init ShenyuWebHandler.
@@ -70,7 +74,7 @@ public class ShenyuConfiguration {
List<ShenyuPlugin> pluginList =
plugins.getIfAvailable(Collections::emptyList);
List<ShenyuPlugin> shenyuPlugins = pluginList.stream()
.sorted(Comparator.comparingInt(ShenyuPlugin::getOrder)).collect(Collectors.toList());
- shenyuPlugins.forEach(shenyuPlugin -> log.info("load plugin:[{}]
[{}]", shenyuPlugin.named(), shenyuPlugin.getClass().getName()));
+ shenyuPlugins.forEach(shenyuPlugin -> LOG.info("load plugin:[{}]
[{}]", shenyuPlugin.named(), shenyuPlugin.getClass().getName()));
return new ShenyuWebHandler(shenyuPlugins);
}
diff --git
a/shenyu-web/src/main/java/org/apache/shenyu/web/configuration/properties/ExcludePathProperties.java
b/shenyu-web/src/main/java/org/apache/shenyu/web/configuration/properties/ExcludePathProperties.java
index 485c661..6815635 100644
---
a/shenyu-web/src/main/java/org/apache/shenyu/web/configuration/properties/ExcludePathProperties.java
+++
b/shenyu-web/src/main/java/org/apache/shenyu/web/configuration/properties/ExcludePathProperties.java
@@ -17,22 +17,26 @@
package org.apache.shenyu.web.configuration.properties;
-import lombok.Getter;
-import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
-
import java.util.ArrayList;
import java.util.List;
/**
* Rule out the url Filter.
*/
-@Getter
-@Setter
@Component
@ConfigurationProperties(prefix = "shenyu.exclude")
public class ExcludePathProperties {
private final List<String> paths = new ArrayList<>();
+
+ /**
+ * get paths.
+ * @return paths
+ */
+ public List<String> getPaths() {
+ return paths;
+ }
+
}
diff --git
a/shenyu-web/src/main/java/org/apache/shenyu/web/configuration/properties/ShenyuConfig.java
b/shenyu-web/src/main/java/org/apache/shenyu/web/configuration/properties/ShenyuConfig.java
index 675c315..7d43918 100644
---
a/shenyu-web/src/main/java/org/apache/shenyu/web/configuration/properties/ShenyuConfig.java
+++
b/shenyu-web/src/main/java/org/apache/shenyu/web/configuration/properties/ShenyuConfig.java
@@ -17,12 +17,10 @@
package org.apache.shenyu.web.configuration.properties;
-import lombok.Data;
/**
* The type shenyu config.
*/
-@Data
public class ShenyuConfig {
private Integer filterTime = 10;
@@ -32,4 +30,76 @@ public class ShenyuConfig {
private Integer upstreamScheduledTime = 30;
private Integer fileMaxSize = 10;
+
+ /**
+ * get filterTime.
+ *
+ * @return filterTime
+ */
+ public Integer getFilterTime() {
+ return filterTime;
+ }
+
+ /**
+ * set filterTime.
+ *
+ * @param filterTime filterTime.
+ */
+ public void setFilterTime(final Integer filterTime) {
+ this.filterTime = filterTime;
+ }
+
+ /**
+ * get filterTimeEnable.
+ *
+ * @return filterTimeEnable
+ */
+ public Boolean getFilterTimeEnable() {
+ return filterTimeEnable;
+ }
+
+ /**
+ * set filterTimeEnable.
+ *
+ * @param filterTimeEnable filterTimeEnable.
+ */
+ public void setFilterTimeEnable(final Boolean filterTimeEnable) {
+ this.filterTimeEnable = filterTimeEnable;
+ }
+
+ /**
+ * get upstreamScheduledTime.
+ *
+ * @return upstreamScheduledTime
+ */
+ public Integer getUpstreamScheduledTime() {
+ return upstreamScheduledTime;
+ }
+
+ /**
+ * set upstreamScheduledTime.
+ *
+ * @param upstreamScheduledTime upstreamScheduledTime.
+ */
+ public void setUpstreamScheduledTime(final Integer upstreamScheduledTime) {
+ this.upstreamScheduledTime = upstreamScheduledTime;
+ }
+
+ /**
+ * get fileMaxSize.
+ *
+ * @return fileMaxSize
+ */
+ public Integer getFileMaxSize() {
+ return fileMaxSize;
+ }
+
+ /**
+ * set fileMaxSize.
+ *
+ * @param fileMaxSize fileMaxSize.
+ */
+ public void setFileMaxSize(final Integer fileMaxSize) {
+ this.fileMaxSize = fileMaxSize;
+ }
}
diff --git
a/shenyu-web/src/main/java/org/apache/shenyu/web/fallback/DefaultFallbackController.java
b/shenyu-web/src/main/java/org/apache/shenyu/web/fallback/DefaultFallbackController.java
index 4ff65dc..31017cb 100644
---
a/shenyu-web/src/main/java/org/apache/shenyu/web/fallback/DefaultFallbackController.java
+++
b/shenyu-web/src/main/java/org/apache/shenyu/web/fallback/DefaultFallbackController.java
@@ -17,9 +17,10 @@
package org.apache.shenyu.web.fallback;
-import lombok.extern.slf4j.Slf4j;
import org.apache.shenyu.plugin.api.result.DefaultShenyuEntity;
import org.apache.shenyu.plugin.api.result.ShenyuResultEnum;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@@ -29,8 +30,11 @@ import
org.springframework.web.bind.annotation.RestController;
*/
@RestController
@RequestMapping("/fallback")
-@Slf4j
public class DefaultFallbackController {
+ /**
+ * logger.
+ */
+ private static final Logger LOG =
LoggerFactory.getLogger(DefaultFallbackController.class);
/**
* default fallback for hystrix.
@@ -39,7 +43,7 @@ public class DefaultFallbackController {
*/
@GetMapping("/hystrix")
public Object hystrixPluginFallback() {
- log.error("the default fallback for hystrix");
+ LOG.error("the default fallback for hystrix");
return
DefaultShenyuEntity.error(ShenyuResultEnum.HYSTRIX_PLUGIN_FALLBACK.getCode(),
ShenyuResultEnum.HYSTRIX_PLUGIN_FALLBACK.getMsg(), null);
}
@@ -50,7 +54,7 @@ public class DefaultFallbackController {
*/
@GetMapping("/resilience4j")
public Object resilience4jFallBack() {
- log.error("the default fallback for resilience4j");
+ LOG.error("the default fallback for resilience4j");
return
DefaultShenyuEntity.error(ShenyuResultEnum.RESILIENCE4J_PLUGIN_FALLBACK.getCode(),
ShenyuResultEnum.RESILIENCE4J_PLUGIN_FALLBACK.getMsg(), null);
}
}
diff --git
a/shenyu-web/src/main/java/org/apache/shenyu/web/forward/ForwardedRemoteAddressResolver.java
b/shenyu-web/src/main/java/org/apache/shenyu/web/forward/ForwardedRemoteAddressResolver.java
index db6fa13..76cfc0b 100644
---
a/shenyu-web/src/main/java/org/apache/shenyu/web/forward/ForwardedRemoteAddressResolver.java
+++
b/shenyu-web/src/main/java/org/apache/shenyu/web/forward/ForwardedRemoteAddressResolver.java
@@ -17,8 +17,9 @@
package org.apache.shenyu.web.forward;
-import lombok.extern.slf4j.Slf4j;
import org.apache.shenyu.plugin.api.RemoteAddressResolver;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
@@ -34,21 +35,23 @@ import java.util.List;
* falls back to {@link RemoteAddressResolver} and
* {@link ServerHttpRequest#getRemoteAddress()}. Use the static constructor
methods which
* meets your security requirements.
- *
*/
-@Slf4j
public class ForwardedRemoteAddressResolver implements RemoteAddressResolver {
-
/**
* Forwarded-For header name.
*/
public static final String X_FORWARDED_FOR = "X-Forwarded-For";
-
+
+ /**
+ * logger.
+ */
+ private static final Logger LOG =
LoggerFactory.getLogger(ForwardedRemoteAddressResolver.class);
+
private final RemoteAddressResolver defaultRemoteIpResolver = new
RemoteAddressResolver() {
};
-
+
private final int maxTrustedIndex;
-
+
/**
* Instantiates a new Forwarded remote address resolver.
*
@@ -57,7 +60,7 @@ public class ForwardedRemoteAddressResolver implements
RemoteAddressResolver {
public ForwardedRemoteAddressResolver(final int maxTrustedIndex) {
this.maxTrustedIndex = maxTrustedIndex;
}
-
+
/**
* Trust all forwarded remote address resolver.
*
@@ -66,7 +69,7 @@ public class ForwardedRemoteAddressResolver implements
RemoteAddressResolver {
public static ForwardedRemoteAddressResolver trustAll() {
return new ForwardedRemoteAddressResolver(Integer.MAX_VALUE);
}
-
+
/**
* Max trusted index forwarded remote address resolver.
*
@@ -77,7 +80,7 @@ public class ForwardedRemoteAddressResolver implements
RemoteAddressResolver {
Assert.isTrue(maxTrustedIndex > 0, "An index greater than 0 is
required");
return new ForwardedRemoteAddressResolver(maxTrustedIndex);
}
-
+
@Override
public InetSocketAddress resolve(final ServerWebExchange exchange) {
List<String> xForwardedValues = extractXForwardedValues(exchange);
@@ -88,7 +91,7 @@ public class ForwardedRemoteAddressResolver implements
RemoteAddressResolver {
}
return defaultRemoteIpResolver.resolve(exchange);
}
-
+
private List<String> extractXForwardedValues(final ServerWebExchange
exchange) {
List<String> xForwardedValues = exchange.getRequest().getHeaders()
.get(X_FORWARDED_FOR);
@@ -96,7 +99,7 @@ public class ForwardedRemoteAddressResolver implements
RemoteAddressResolver {
return Collections.emptyList();
}
if (xForwardedValues.size() > 1) {
- log.warn("Multiple X-Forwarded-For headers found, discarding all");
+ LOG.warn("Multiple X-Forwarded-For headers found, discarding all");
return Collections.emptyList();
}
List<String> values = Arrays.asList(xForwardedValues.get(0).split(",
"));
diff --git
a/shenyu-web/src/main/java/org/apache/shenyu/web/handler/GlobalErrorHandler.java
b/shenyu-web/src/main/java/org/apache/shenyu/web/handler/GlobalErrorHandler.java
index c2a405e..6336fe1 100644
---
a/shenyu-web/src/main/java/org/apache/shenyu/web/handler/GlobalErrorHandler.java
+++
b/shenyu-web/src/main/java/org/apache/shenyu/web/handler/GlobalErrorHandler.java
@@ -17,9 +17,10 @@
package org.apache.shenyu.web.handler;
-import lombok.extern.slf4j.Slf4j;
import org.apache.shenyu.common.utils.GsonUtils;
import org.apache.shenyu.plugin.api.result.ShenyuResultWrap;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.web.ErrorProperties;
import org.springframework.boot.autoconfigure.web.ResourceProperties;
import
org.springframework.boot.autoconfigure.web.reactive.error.DefaultErrorWebExceptionHandler;
@@ -31,14 +32,16 @@ import
org.springframework.web.reactive.function.server.RouterFunction;
import org.springframework.web.reactive.function.server.RouterFunctions;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;
-
import java.util.Map;
/**
* GlobalErrorHandler.
*/
-@Slf4j
public class GlobalErrorHandler extends DefaultErrorWebExceptionHandler {
+ /**
+ * logger.
+ */
+ private static final Logger LOG =
LoggerFactory.getLogger(GlobalErrorHandler.class);
/**
* Instantiates a new Global error handler.
@@ -79,7 +82,7 @@ public class GlobalErrorHandler extends
DefaultErrorWebExceptionHandler {
private void logError(final ServerRequest request) {
Throwable ex = getError(request);
- log.error(request.exchange().getLogPrefix() + formatError(ex,
request));
+ LOG.error(request.exchange().getLogPrefix() + formatError(ex,
request));
}
private String formatError(final Throwable ex, final ServerRequest
request) {
diff --git
a/shenyu-web/src/main/java/org/apache/shenyu/web/logo/ShenyuLogo.java
b/shenyu-web/src/main/java/org/apache/shenyu/web/logo/ShenyuLogo.java
index 98ddb59..9e723e5 100644
--- a/shenyu-web/src/main/java/org/apache/shenyu/web/logo/ShenyuLogo.java
+++ b/shenyu-web/src/main/java/org/apache/shenyu/web/logo/ShenyuLogo.java
@@ -17,22 +17,26 @@
package org.apache.shenyu.web.logo;
-import lombok.extern.slf4j.Slf4j;
import org.apache.shenyu.common.constant.Constants;
import org.apache.shenyu.common.utils.VersionUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import
org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent;
import org.springframework.boot.context.logging.LoggingApplicationListener;
import org.springframework.context.ApplicationListener;
import org.springframework.core.annotation.Order;
-
import java.util.concurrent.atomic.AtomicBoolean;
/**
* the shenyu logo.
*/
@Order(LoggingApplicationListener.DEFAULT_ORDER + 1)
-@Slf4j
+
public class ShenyuLogo implements
ApplicationListener<ApplicationEnvironmentPreparedEvent> {
+ /**
+ * logger.
+ */
+ private static final Logger LOG =
LoggerFactory.getLogger(ShenyuLogo.class);
private static final String SHENYU_LOGO = "\n"
+ " _____ _ \n"
@@ -51,7 +55,7 @@ public class ShenyuLogo implements
ApplicationListener<ApplicationEnvironmentPre
if (!alreadyLog.compareAndSet(false, true)) {
return;
}
- log.info(buildBannerText());
+ LOG.info(buildBannerText());
}
private String buildBannerText() {