You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shenyu.apache.org by xi...@apache.org on 2023/06/09 06:12:59 UTC
[shenyu] branch master updated: [type:optimization] some syntactic sugar optimization (#4700)
This is an automated email from the ASF dual-hosted git repository.
xiaoyu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shenyu.git
The following commit(s) were added to refs/heads/master by this push:
new cc6b97ff5 [type:optimization] some syntactic sugar optimization (#4700)
cc6b97ff5 is described below
commit cc6b97ff57b1ab19f972bd9f8107c9197a2d4426
Author: zhengpeng <84...@qq.com>
AuthorDate: Fri Jun 9 14:12:53 2023 +0800
[type:optimization] some syntactic sugar optimization (#4700)
* some syntactic sugar optimization
* Empty Commit to setup deployments
* Empty Commit to setup deployments
* Empty Commit to setup deployments
* Empty Commit to setup deployments
* Empty Commit to setup deployments
* Empty Commit to setup deployments
* fix
* fix
* Empty Commit to setup deployments
* Empty Commit to setup deployments
* Empty Commit to setup deployments
---------
Co-authored-by: dragon-zhang <zh...@apache.org>
Co-authored-by: xiaoyu <xi...@apache.org>
---
.../java/org/apache/shenyu/protocol/tcp/TcpBootstrapServer.java | 8 ++------
.../protocol/tcp/connection/DefaultConnectionConfigProvider.java | 7 ++++---
.../client/server/etcd/EtcdClientServerRegisterRepository.java | 4 +---
.../org/apache/shenyu/register/client/apollo/ApolloClient.java | 3 ++-
.../org/apache/shenyu/register/client/http/utils/OkHttpTools.java | 2 +-
.../sdk/spring/annotation/RequestParamParameterProcessor.java | 4 +---
.../main/java/org/apache/shenyu/sync/data/etcd/EtcdClient.java | 4 ++--
7 files changed, 13 insertions(+), 19 deletions(-)
diff --git a/shenyu-protocol/shenyu-protocol-tcp/src/main/java/org/apache/shenyu/protocol/tcp/TcpBootstrapServer.java b/shenyu-protocol/shenyu-protocol-tcp/src/main/java/org/apache/shenyu/protocol/tcp/TcpBootstrapServer.java
index 8d3e6fa2b..0a25555c6 100644
--- a/shenyu-protocol/shenyu-protocol-tcp/src/main/java/org/apache/shenyu/protocol/tcp/TcpBootstrapServer.java
+++ b/shenyu-protocol/shenyu-protocol-tcp/src/main/java/org/apache/shenyu/protocol/tcp/TcpBootstrapServer.java
@@ -68,13 +68,9 @@ public class TcpBootstrapServer implements BootstrapServer {
tcpServerConfiguration.getWorkerGroupThreadCount(), true);
TcpServer tcpServer = TcpServer.create()
- .doOnChannelInit((connObserver, channel, remoteAddress) -> {
- channel.pipeline().addFirst(new LoggingHandler(LogLevel.INFO));
- })
+ .doOnChannelInit((connObserver, channel, remoteAddress) -> channel.pipeline().addFirst(new LoggingHandler(LogLevel.INFO)))
.wiretap(true)
- .observe((c, s) -> {
- LOG.info("connection={}|status={}", c, s);
- })
+ .observe((c, s) -> LOG.info("connection={}|status={}", c, s))
//.childObserve(connectionObserver)
.doOnConnection(this::bridgeConnections)
.port(tcpServerConfiguration.getPort())
diff --git a/shenyu-protocol/shenyu-protocol-tcp/src/main/java/org/apache/shenyu/protocol/tcp/connection/DefaultConnectionConfigProvider.java b/shenyu-protocol/shenyu-protocol-tcp/src/main/java/org/apache/shenyu/protocol/tcp/connection/DefaultConnectionConfigProvider.java
index 595601328..2a0e7b270 100644
--- a/shenyu-protocol/shenyu-protocol-tcp/src/main/java/org/apache/shenyu/protocol/tcp/connection/DefaultConnectionConfigProvider.java
+++ b/shenyu-protocol/shenyu-protocol-tcp/src/main/java/org/apache/shenyu/protocol/tcp/connection/DefaultConnectionConfigProvider.java
@@ -48,9 +48,10 @@ public class DefaultConnectionConfigProvider implements ClientConnectionConfigPr
@Override
public URI getProxiedService(final String ip) {
- List<Upstream> upstreamList = UpstreamProvider.getSingleton().provide(this.pluginSelectorName).stream().map(dp -> {
- return Upstream.builder().url(dp.getUpstreamUrl()).status(dp.isStatus()).weight(dp.getWeight()).protocol(dp.getProtocol()).build();
- }).collect(Collectors.toList());
+ List<Upstream> upstreamList = UpstreamProvider.getSingleton().provide(this.pluginSelectorName)
+ .stream()
+ .map(dp -> Upstream.builder().url(dp.getUpstreamUrl()).status(dp.isStatus()).weight(dp.getWeight()).protocol(dp.getProtocol()).build())
+ .collect(Collectors.toList());
Upstream upstream = LoadBalancerFactory.selector(upstreamList, loadBalanceAlgorithm, ip);
return cover(upstream);
}
diff --git a/shenyu-register-center/shenyu-register-client-server/shenyu-register-client-server-etcd/src/main/java/org/apache/shenyu/register/client/server/etcd/EtcdClientServerRegisterRepository.java b/shenyu-register-center/shenyu-register-client-server/shenyu-register-client-server-etcd/src/main/java/org/apache/shenyu/register/client/server/etcd/EtcdClientServerRegisterRepository.java
index 53aa3564b..221ddc193 100644
--- a/shenyu-register-center/shenyu-register-client-server/shenyu-register-client-server-etcd/src/main/java/org/apache/shenyu/register/client/server/etcd/EtcdClientServerRegisterRepository.java
+++ b/shenyu-register-center/shenyu-register-client-server/shenyu-register-client-server-etcd/src/main/java/org/apache/shenyu/register/client/server/etcd/EtcdClientServerRegisterRepository.java
@@ -100,9 +100,7 @@ public class EtcdClientServerRegisterRepository implements ShenyuClientServerReg
private void subscribeURI(final String rpcType) {
String rpcPath = RegisterPathConstants.buildURIContextPathParent(rpcType);
Set<String> contextList = new HashSet<>();
- client.getChildren(rpcPath).forEach(dataPath -> {
- contextList.add(getContext(dataPath));
- });
+ client.getChildren(rpcPath).forEach(dataPath -> contextList.add(getContext(dataPath)));
contextList.forEach(context -> registerUriChildrenList(rpcPath, context, rpcType));
LOGGER.info("subscribe uri change: {}", rpcPath);
client.subscribeChildChanges(rpcPath, new EtcdListenHandler() {
diff --git a/shenyu-register-center/shenyu-register-client/shenyu-register-client-apollo/src/main/java/org/apache/shenyu/register/client/apollo/ApolloClient.java b/shenyu-register-center/shenyu-register-client/shenyu-register-client-apollo/src/main/java/org/apache/shenyu/register/client/apollo/ApolloClient.java
index bdc6e60b6..8cd201b01 100644
--- a/shenyu-register-center/shenyu-register-client/shenyu-register-client-apollo/src/main/java/org/apache/shenyu/register/client/apollo/ApolloClient.java
+++ b/shenyu-register-center/shenyu-register-client/shenyu-register-client-apollo/src/main/java/org/apache/shenyu/register/client/apollo/ApolloClient.java
@@ -20,6 +20,7 @@ package org.apache.shenyu.register.client.apollo;
import com.ctrip.framework.apollo.openapi.client.ApolloOpenApiClient;
import com.ctrip.framework.apollo.openapi.dto.NamespaceReleaseDTO;
import com.ctrip.framework.apollo.openapi.dto.OpenItemDTO;
+import org.apache.commons.lang3.StringUtils;
import org.apache.shenyu.common.utils.GsonUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -64,7 +65,7 @@ public class ApolloClient {
if (openItemDTO == null) {
return null;
}
- if (openItemDTO.getKey().equals("timeout")) {
+ if (StringUtils.equals("timeout", openItemDTO.getKey())) {
LOG.error("apollo client getItemValue time out");
}
return openItemDTO.getValue();
diff --git a/shenyu-register-center/shenyu-register-client/shenyu-register-client-http/src/main/java/org/apache/shenyu/register/client/http/utils/OkHttpTools.java b/shenyu-register-center/shenyu-register-client/shenyu-register-client-http/src/main/java/org/apache/shenyu/register/client/http/utils/OkHttpTools.java
index 567f2c8ca..e9e24f65a 100644
--- a/shenyu-register-center/shenyu-register-client/shenyu-register-client-http/src/main/java/org/apache/shenyu/register/client/http/utils/OkHttpTools.java
+++ b/shenyu-register-center/shenyu-register-client/shenyu-register-client-http/src/main/java/org/apache/shenyu/register/client/http/utils/OkHttpTools.java
@@ -107,7 +107,7 @@ public final class OkHttpTools {
public String get(final String url, final Map<String, Object> query) throws IOException {
Request.Builder reqBuild = new Request.Builder();
HttpUrl.Builder urlBuilder = HttpUrl.parse(url).newBuilder();
- query.forEach((K, V) -> urlBuilder.addQueryParameter(K, String.valueOf(V)));
+ query.forEach((k, v) -> urlBuilder.addQueryParameter(k, String.valueOf(v)));
reqBuild.url(urlBuilder.build());
Request request = reqBuild.build();
return client.newCall(request).execute().body().string();
diff --git a/shenyu-sdk/shenyu-sdk-spring/src/main/java/org/apache/shenyu/sdk/spring/annotation/RequestParamParameterProcessor.java b/shenyu-sdk/shenyu-sdk-spring/src/main/java/org/apache/shenyu/sdk/spring/annotation/RequestParamParameterProcessor.java
index c9f5854d9..0af5b75f8 100644
--- a/shenyu-sdk/shenyu-sdk-spring/src/main/java/org/apache/shenyu/sdk/spring/annotation/RequestParamParameterProcessor.java
+++ b/shenyu-sdk/shenyu-sdk-spring/src/main/java/org/apache/shenyu/sdk/spring/annotation/RequestParamParameterProcessor.java
@@ -56,9 +56,7 @@ public class RequestParamParameterProcessor implements AnnotatedParameterProcess
}
pathResult.append(name).append("=").append(arg);
} else if (arg instanceof Map) {
- ((Map<?, ?>) arg).forEach((key, value) -> {
- pathResult.append(key).append("=").append(value);
- });
+ ((Map<?, ?>) arg).forEach((key, value) -> pathResult.append(key).append("=").append(value));
}
shenyuRequest.setUrl(requestTemplate.getUrl() + pathResult);
return true;
diff --git a/shenyu-sync-data-center/shenyu-sync-data-etcd/src/main/java/org/apache/shenyu/sync/data/etcd/EtcdClient.java b/shenyu-sync-data-center/shenyu-sync-data-etcd/src/main/java/org/apache/shenyu/sync/data/etcd/EtcdClient.java
index 596bbad4c..6d19a05f0 100644
--- a/shenyu-sync-data-center/shenyu-sync-data-etcd/src/main/java/org/apache/shenyu/sync/data/etcd/EtcdClient.java
+++ b/shenyu-sync-data-center/shenyu-sync-data-etcd/src/main/java/org/apache/shenyu/sync/data/etcd/EtcdClient.java
@@ -141,7 +141,7 @@ public class EtcdClient {
return keyValues.stream()
.map(e -> getSubNodeKeyName(prefix, e.getKey().toString(UTF_8), separator))
.distinct()
- .filter(e -> Objects.nonNull(e))
+ .filter(Objects::nonNull)
.collect(Collectors.toList());
}
@@ -159,7 +159,7 @@ public class EtcdClient {
.filter(e -> e.getKey().contains(prefix))
.map(e -> getSubNodeKeyName(prefix, e.getKey(), separator))
.distinct()
- .filter(e -> Objects.nonNull(e))
+ .filter(Objects::nonNull)
.collect(Collectors.toList());
}