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/incubator-shenyu.git
The following commit(s) were added to refs/heads/master by this push:
new 65f90ab fix issue from WeChat:Refactor code (#2954)
65f90ab is described below
commit 65f90ab638290e1807ce1e34995b3d97c23b1390
Author: erdengk <[email protected]>
AuthorDate: Tue Mar 1 18:05:02 2022 +0800
fix issue from WeChat:Refactor code (#2954)
---
.../shenyu/sync/data/http/HttpSyncDataService.java | 24 +---------------------
1 file changed, 1 insertion(+), 23 deletions(-)
diff --git
a/shenyu-sync-data-center/shenyu-sync-data-http/src/main/java/org/apache/shenyu/sync/data/http/HttpSyncDataService.java
b/shenyu-sync-data-center/shenyu-sync-data-http/src/main/java/org/apache/shenyu/sync/data/http/HttpSyncDataService.java
index 8644795..834fddd 100644
---
a/shenyu-sync-data-center/shenyu-sync-data-http/src/main/java/org/apache/shenyu/sync/data/http/HttpSyncDataService.java
+++
b/shenyu-sync-data-center/shenyu-sync-data-http/src/main/java/org/apache/shenyu/sync/data/http/HttpSyncDataService.java
@@ -52,8 +52,6 @@ import org.springframework.web.client.RestClientException;
import org.springframework.web.client.RestTemplate;
import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@@ -238,10 +236,7 @@ public class HttpSyncDataService implements
SyncDataService, AutoCloseable {
}
private Optional<Object> doLogin(final String server) {
- Map<String, Object> loginMap = new HashMap<>(2);
- loginMap.put(Constants.LOGIN_NAME, httpConfig.getUsername());
- loginMap.put(Constants.PASS_WORD, httpConfig.getPassword());
- String param = toQuery(loginMap);
+ String param = Constants.LOGIN_NAME + "=" + httpConfig.getUsername() +
"&" + Constants.PASS_WORD + "=" + httpConfig.getPassword();
String url = String.join("?", server + Constants.LOGIN_PATH, param);
String result = this.httpClient.getForObject(url, String.class);
Map<String, Object> resultMap =
GsonUtils.getInstance().convertToMap(result);
@@ -254,23 +249,6 @@ public class HttpSyncDataService implements
SyncDataService, AutoCloseable {
return Optional.ofNullable(tokenMap.get(Constants.ADMIN_RESULT_TOKEN));
}
- private String toQuery(final Object o) {
- Map<String, Object> map = null;
- if (o instanceof Map) {
- map = (Map) o;
- } else {
- map =
GsonUtils.getInstance().convertToMap(GsonUtils.getInstance().toJson(o));
- }
- String[] list = new String[((Map) map).size()];
- int i = 0;
-
- Map.Entry e;
- for (Iterator var = ((Map) map).entrySet().iterator(); var.hasNext();
list[i++] = (String) e.getKey() + "=" + e.getValue().toString()) {
- e = (Map.Entry) var.next();
- }
- return StringUtils.join(list, '&');
- }
-
class HttpLongPollingTask implements Runnable {
private final String server;