Skip to content

Commit 1881422

Browse files
authored
Revert "Let name server generate valid JSON response when process topic route queries (#4432)"
This reverts commit 73b9ac8.
1 parent 6273782 commit 1881422

File tree

4 files changed

+2
-67
lines changed

4 files changed

+2
-67
lines changed

namesrv/src/main/java/org/apache/rocketmq/namesrv/processor/DefaultRequestProcessor.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
*/
1717
package org.apache.rocketmq.namesrv.processor;
1818

19-
import com.alibaba.fastjson.serializer.SerializerFeature;
2019
import io.netty.channel.ChannelHandlerContext;
2120
import java.io.UnsupportedEncodingException;
2221
import java.util.Properties;
@@ -363,9 +362,7 @@ public RemotingCommand getRouteInfoByTopic(ChannelHandlerContext ctx,
363362
topicRouteData.setOrderTopicConf(orderTopicConf);
364363
}
365364

366-
byte[] content = topicRouteData.encode(SerializerFeature.BrowserCompatible,
367-
SerializerFeature.QuoteFieldNames, SerializerFeature.SkipTransientField,
368-
SerializerFeature.MapSortField);
365+
byte[] content = topicRouteData.encode();
369366
response.setBody(content);
370367
response.setCode(ResponseCode.SUCCESS);
371368
response.setRemark(null);

remoting/pom.xml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,5 @@
4040
<groupId>${project.groupId}</groupId>
4141
<artifactId>rocketmq-logging</artifactId>
4242
</dependency>
43-
44-
<dependency>
45-
<groupId>com.google.code.gson</groupId>
46-
<artifactId>gson</artifactId>
47-
<version>2.9.0</version>
48-
<scope>test</scope>
49-
</dependency>
5043
</dependencies>
5144
</project>

remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingSerializable.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
package org.apache.rocketmq.remoting.protocol;
1818

1919
import com.alibaba.fastjson.JSON;
20-
import com.alibaba.fastjson.serializer.SerializerFeature;
21-
2220
import java.nio.charset.Charset;
2321
import java.nio.charset.StandardCharsets;
2422

@@ -54,17 +52,6 @@ public byte[] encode() {
5452
return null;
5553
}
5654

57-
/**
58-
* Allow call-site to apply specific features according to their requirements.
59-
*
60-
* @param features Features to apply
61-
* @return serialized data.
62-
*/
63-
public byte[] encode(SerializerFeature...features) {
64-
final String json = JSON.toJSONString(this, features);
65-
return json.getBytes(CHARSET_UTF8);
66-
}
67-
6855
public String toJson() {
6956
return toJson(false);
7057
}

remoting/src/test/java/org/apache/rocketmq/remoting/protocol/RemotingSerializableTest.java

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,9 @@
1616
*/
1717
package org.apache.rocketmq.remoting.protocol;
1818

19-
import com.alibaba.fastjson.serializer.SerializerFeature;
20-
import com.google.gson.Gson;
21-
import com.google.gson.JsonElement;
22-
import com.google.gson.TypeAdapter;
23-
import org.junit.Assert;
24-
import org.junit.Test;
25-
26-
import java.io.IOException;
27-
import java.nio.charset.Charset;
2819
import java.util.Arrays;
29-
import java.util.HashMap;
3020
import java.util.List;
31-
import java.util.Map;
21+
import org.junit.Test;
3222

3323
import static org.assertj.core.api.Assertions.assertThat;
3424

@@ -90,38 +80,6 @@ public void setStringList(List<String> stringList) {
9080
"}");
9181
}
9282

93-
@Test
94-
public void testEncode() {
95-
class Foo extends RemotingSerializable {
96-
Map<Long, String> map = new HashMap<>();
97-
98-
Foo() {
99-
map.put(0L, "Test");
100-
}
101-
102-
public Map<Long, String> getMap() {
103-
return map;
104-
}
105-
}
106-
Foo foo = new Foo();
107-
String invalid = new String(foo.encode(), Charset.defaultCharset());
108-
String valid = new String(foo.encode(SerializerFeature.BrowserCompatible, SerializerFeature.QuoteFieldNames,
109-
SerializerFeature.MapSortField), Charset.defaultCharset());
110-
111-
Gson gson = new Gson();
112-
final TypeAdapter<JsonElement> strictAdapter = gson.getAdapter(JsonElement.class);
113-
try {
114-
strictAdapter.fromJson(invalid);
115-
Assert.fail("Should have thrown");
116-
} catch (IOException ignore) {
117-
}
118-
119-
try {
120-
strictAdapter.fromJson(valid);
121-
} catch (IOException ignore) {
122-
Assert.fail("Should not throw");
123-
}
124-
}
12583
}
12684

12785
class Sample {

0 commit comments

Comments
 (0)