Merge pull request #2918 from KomachiSion/develop-issue#2842
[ISSUE #2842] Fix serverStatus api jackson error
This commit is contained in:
commit
ea4a029ca4
@ -86,7 +86,7 @@ public class RaftController {
|
||||
|
||||
JsonNode json = JacksonUtils.toObj(value);
|
||||
|
||||
RaftPeer peer = raftCore.receivedBeat(json.get("beat"));
|
||||
RaftPeer peer = raftCore.receivedBeat(JacksonUtils.toObj(json.get("beat").asText()));
|
||||
|
||||
return JacksonUtils.transferToJsonNode(peer);
|
||||
}
|
||||
@ -128,7 +128,7 @@ public class RaftController {
|
||||
String value = URLDecoder.decode(entity, "UTF-8");
|
||||
JsonNode json = JacksonUtils.toObj(value);
|
||||
|
||||
String key = json.get("key").toString();
|
||||
String key = json.get("key").asText();
|
||||
if (KeyBuilder.matchInstanceListKey(key)) {
|
||||
raftConsistencyService.put(key, JacksonUtils.toObj(json.get("value").toString(), Instances.class));
|
||||
return "ok";
|
||||
@ -233,7 +233,7 @@ public class RaftController {
|
||||
String value = URLDecoder.decode(entity, "UTF-8");
|
||||
value = URLDecoder.decode(value, "UTF-8");
|
||||
|
||||
JsonNode jsonObject = JacksonUtils.createEmptyJsonNode();
|
||||
JsonNode jsonObject = JacksonUtils.toObj(value);
|
||||
|
||||
Datum datum = JacksonUtils.toObj(jsonObject.get("datum").toString(), Datum.class);
|
||||
RaftPeer source = JacksonUtils.toObj(jsonObject.get("source").toString(), RaftPeer.class);
|
||||
|
@ -288,8 +288,8 @@ public class ServiceController {
|
||||
JsonNode json = JacksonUtils.toObj(value);
|
||||
|
||||
//format: service1@@checksum@@@service2@@checksum
|
||||
String statuses = json.get("statuses").toString();
|
||||
String serverIp = json.get("clientIP").toString();
|
||||
String statuses = json.get("statuses").asText();
|
||||
String serverIp = json.get("clientIP").asText();
|
||||
|
||||
if (!memberManager.hasMember(serverIp)) {
|
||||
throw new NacosException(NacosException.INVALID_PARAM,
|
||||
|
@ -119,6 +119,7 @@ public class Cluster extends com.alibaba.nacos.api.naming.pojo.Cluster implement
|
||||
}
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public HealthCheckTask getHealthCheckTask() {
|
||||
return checkTask;
|
||||
}
|
||||
|
@ -17,9 +17,16 @@ package com.alibaba.nacos.naming.core;
|
||||
|
||||
import com.alibaba.nacos.api.naming.pojo.healthcheck.impl.Http;
|
||||
import com.alibaba.nacos.common.utils.JacksonUtils;
|
||||
import com.alibaba.nacos.core.utils.ApplicationUtils;
|
||||
import com.alibaba.nacos.naming.misc.SwitchDomain;
|
||||
import com.alibaba.nacos.naming.misc.SwitchDomain.TcpHealthParams;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -29,23 +36,34 @@ import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* @author nkorange
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class ClusterTest {
|
||||
|
||||
private Cluster cluster;
|
||||
|
||||
@Mock
|
||||
private ConfigurableApplicationContext context;
|
||||
|
||||
@Mock
|
||||
private SwitchDomain switchDomain;
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
|
||||
ApplicationUtils.injectContext(context);
|
||||
when(context.getBean(SwitchDomain.class)).thenReturn(switchDomain);
|
||||
when(switchDomain.getTcpHealthParams()).thenReturn(new TcpHealthParams());
|
||||
Service service = new Service();
|
||||
service.setName("nacos.service.1");
|
||||
|
||||
cluster = new Cluster("nacos-cluster-1", service);
|
||||
cluster.setDefCkport(80);
|
||||
cluster.setDefIPPort(8080);
|
||||
cluster.init();
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user