Skip to content

Commit 763e8bb

Browse files
authored
HttpPostRequestDecoder need be destroyed. (#15788)
1 parent 9b32dc1 commit 763e8bb

File tree

1 file changed

+23
-16
lines changed

1 file changed

+23
-16
lines changed

dubbo-plugin/dubbo-qos/src/main/java/org/apache/dubbo/qos/command/decoder/HttpCommandDecoder.java

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -55,24 +55,31 @@ public static CommandContext decode(HttpRequest request) {
5555
CommandContextFactory.newInstance(name, valueList.toArray(new String[] {}), true);
5656
}
5757
} else if (request.method() == HttpMethod.POST) {
58-
HttpPostRequestDecoder httpPostRequestDecoder = new HttpPostRequestDecoder(request);
59-
List<String> valueList = new ArrayList<>();
60-
for (InterfaceHttpData interfaceHttpData : httpPostRequestDecoder.getBodyHttpDatas()) {
61-
if (interfaceHttpData.getHttpDataType() == InterfaceHttpData.HttpDataType.Attribute) {
62-
Attribute attribute = (Attribute) interfaceHttpData;
63-
try {
64-
valueList.add(attribute.getValue());
65-
} catch (IOException ex) {
66-
throw new RuntimeException(ex);
58+
HttpPostRequestDecoder httpPostRequestDecoder = null;
59+
try {
60+
httpPostRequestDecoder = new HttpPostRequestDecoder(request);
61+
List<String> valueList = new ArrayList<>();
62+
for (InterfaceHttpData interfaceHttpData : httpPostRequestDecoder.getBodyHttpDatas()) {
63+
if (interfaceHttpData.getHttpDataType() == InterfaceHttpData.HttpDataType.Attribute) {
64+
Attribute attribute = (Attribute) interfaceHttpData;
65+
try {
66+
valueList.add(attribute.getValue());
67+
} catch (IOException ex) {
68+
throw new RuntimeException(ex);
69+
}
6770
}
6871
}
69-
}
70-
if (valueList.isEmpty()) {
71-
commandContext = CommandContextFactory.newInstance(name);
72-
commandContext.setHttp(true);
73-
} else {
74-
commandContext =
75-
CommandContextFactory.newInstance(name, valueList.toArray(new String[] {}), true);
72+
if (valueList.isEmpty()) {
73+
commandContext = CommandContextFactory.newInstance(name);
74+
commandContext.setHttp(true);
75+
} else {
76+
commandContext =
77+
CommandContextFactory.newInstance(name, valueList.toArray(new String[] {}), true);
78+
}
79+
} finally {
80+
if (httpPostRequestDecoder != null) {
81+
httpPostRequestDecoder.destroy();
82+
}
7683
}
7784
}
7885
} else if (array.length == 3) {

0 commit comments

Comments
 (0)