Copilot commented on code in PR #7087:
URL: https://github.com/apache/shenyu/pull/7087#discussion_r4032844110


##########
shenyu-plugin/shenyu-plugin-response/src/main/java/org/apache/shenyu/plugin/response/strategy/NettyClientMessageWriter.java:
##########
@@ -78,7 +79,7 @@ public Mono<Void> writeWith(final ServerWebExchange exchange, 
final ShenyuPlugin
             // watcher httpStatus
             final Consumer<HttpStatusCode> consumer = 
exchange.getAttribute(Constants.WATCHER_HTTP_STATUS);
             Optional.ofNullable(consumer).ifPresent(c -> 
c.accept(response.getStatusCode()));
-            return responseMono.onErrorResume(error -> 
releaseIfNotConsumed(body, error));
+            return responseMono.doOnError(error -> cleanup(exchange));

Review Comment:
   The new Netty error path is not covered by a regression test. The existing 
`NettyClientMessageWriterTest` only expects an unspecified error from 
incomplete mocks; it neither supplies a single-use inbound body nor verifies 
`connection.dispose()`. Add assertions that a response-write error preserves 
the original error, subscribes once, releases/discards retained buffers, and 
disposes the connection.



##########
shenyu-plugin/shenyu-plugin-response/src/test/java/org/apache/shenyu/plugin/response/strategy/WebClientMessageWriterTest.java:
##########
@@ -102,10 +107,30 @@ public void testWriteWith() {
         
StepVerifier.create(monoGatewayTimeout).expectSubscription().verifyComplete();
     }
 
+    @Test
+    public void testWriteErrorDoesNotResubscribeResponseBody() {
+        RuntimeException expected = new RuntimeException("write failed");
+        AtomicInteger subscriptions = new AtomicInteger();
+        Flux<DataBuffer> body = Flux.defer(() -> {
+            subscriptions.incrementAndGet();
+            return Flux.error(expected);
+        });

Review Comment:
   This regression body emits no `DataBuffer` and raises the error itself, so 
it verifies the removed re-subscription but never exercises the new discard 
cleanup. The test would still pass if `doOnDiscard` failed to release the 
in-flight pooled buffer described in #6724. Please emit a pooled buffer, make 
the response write fail or cancel after receiving it, and assert both one 
subscription and that the buffer is released.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to