fix: improve error handling in HttpClientSseClientTransport and add test
- Include response body in error messages for better debugging - Change sendHttpPost return type from HttpResponse<Void> to HttpResponse<String> - Use BodyHandlers.ofString() instead of discarding response body - Add testErrorOnBogusMessage test to verify error handling for invalid JSON-RPC messages - Test validates that malformed messages return 400 status with descriptive error message Replace #361 Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com> Co-authored-by: jkma <jkma@trip.com>
This commit is contained in:
parent
d282d40a38
commit
b678de6514
1 changed files with 14 additions and 4 deletions
|
|
@ -105,6 +105,16 @@ class HttpClientSseClientTransportTests {
|
|||
container.stop();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testErrorOnBogusMessage() {
|
||||
// bogus message
|
||||
JSONRPCRequest bogusMessage = new JSONRPCRequest(null, null, "test-id", Map.of("key", "value"));
|
||||
|
||||
StepVerifier.create(transport.sendMessage(bogusMessage))
|
||||
.verifyErrorMessage(
|
||||
"Sending message failed with a non-OK HTTP code: 400 - Invalid message: {\"id\":\"test-id\",\"params\":{\"key\":\"value\"}}");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMessageProcessing() {
|
||||
// Create a test message
|
||||
|
|
|
|||
Loading…
Reference in a new issue