This is an automated email from the ASF dual-hosted git repository.
EarthChen pushed a commit to branch 3.3
in repository https://gitbox.apache.org/repos/asf/dubbo.git
The following commit(s) were added to refs/heads/3.3 by this push:
new eb1d8abaeb Close rejected streaming decoder input (#16391)
eb1d8abaeb is described below
commit eb1d8abaebdc2ce1e15d6236cf9f9179d34e9082
Author: LeiXiaoGao <[email protected]>
AuthorDate: Thu Jul 23 10:27:08 2026 +0800
Close rejected streaming decoder input (#16391)
Fixes #16389
---
.../message/LengthFieldStreamingDecoder.java | 6 +-
.../message/LengthFieldStreamingDecoderTest.java | 65 ++++++++++++++++++++++
2 files changed, 70 insertions(+), 1 deletion(-)
diff --git
a/dubbo-remoting/dubbo-remoting-http12/src/main/java/org/apache/dubbo/remoting/http12/message/LengthFieldStreamingDecoder.java
b/dubbo-remoting/dubbo-remoting-http12/src/main/java/org/apache/dubbo/remoting/http12/message/LengthFieldStreamingDecoder.java
index e71a053345..30bc42fc64 100644
---
a/dubbo-remoting/dubbo-remoting-http12/src/main/java/org/apache/dubbo/remoting/http12/message/LengthFieldStreamingDecoder.java
+++
b/dubbo-remoting/dubbo-remoting-http12/src/main/java/org/apache/dubbo/remoting/http12/message/LengthFieldStreamingDecoder.java
@@ -72,7 +72,11 @@ public class LengthFieldStreamingDecoder implements
StreamingDecoder {
@Override
public final void decode(InputStream inputStream) throws DecodeException {
if (closing || closed) {
- // ignored
+ try {
+ inputStream.close();
+ } catch (IOException e) {
+ throw new DecodeException(e);
+ }
return;
}
accumulate.addInputStream(inputStream);
diff --git
a/dubbo-remoting/dubbo-remoting-http12/src/test/java/org/apache/dubbo/remoting/http12/message/LengthFieldStreamingDecoderTest.java
b/dubbo-remoting/dubbo-remoting-http12/src/test/java/org/apache/dubbo/remoting/http12/message/LengthFieldStreamingDecoderTest.java
new file mode 100644
index 0000000000..177df7baa4
--- /dev/null
+++
b/dubbo-remoting/dubbo-remoting-http12/src/test/java/org/apache/dubbo/remoting/http12/message/LengthFieldStreamingDecoderTest.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dubbo.remoting.http12.message;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+class LengthFieldStreamingDecoderTest {
+
+ @Test
+ void closesInputReceivedAfterStreamClosed() {
+ LengthFieldStreamingDecoder decoder = new
LengthFieldStreamingDecoder();
+ decoder.onStreamClosed();
+ CloseTrackingInputStream inputStream = new
CloseTrackingInputStream(new byte[] {0});
+
+ decoder.decode(inputStream);
+
+ assertTrue(inputStream.closed);
+ }
+
+ @Test
+ void closesInputReceivedWhileDecoderClosing() {
+ LengthFieldStreamingDecoder decoder = new
LengthFieldStreamingDecoder();
+ decoder.decode(new ByteArrayInputStream(new byte[] {0}));
+ decoder.close();
+ CloseTrackingInputStream inputStream = new
CloseTrackingInputStream(new byte[] {0});
+
+ decoder.decode(inputStream);
+
+ assertTrue(inputStream.closed);
+ }
+
+ private static final class CloseTrackingInputStream extends
ByteArrayInputStream {
+
+ private boolean closed;
+
+ private CloseTrackingInputStream(byte[] buf) {
+ super(buf);
+ }
+
+ @Override
+ public void close() throws IOException {
+ this.closed = true;
+ super.close();
+ }
+ }
+}