Bug description When a subscribed exception handler itself throws exceptions, the AbstractBedrockApi will infinitely try to complete the stream.
Environment Spring AI 1.0.0-snapshot openjdk 17.0.13 2024-10-15
Steps to reproduce
Create a Flux stream like so:
Anthropic3ChatBedrockApi api = new Anthropic3ChatBedrockApi(...);
api.chatCompletionStream(request).subscribe(response -> {
throw NullPointerException("some error1");
}, ex -> throw NullPointerException("some error2")
), () -> throw NullPointerException("some error3")
);
Expected behavior I'd expect an exception to be thrown.
Instead, I see Emitting complete:FAIL_TERMINATED output to console very rapidly and infinitely
This is because of the while loop in AbstractBedrockApi.internalInvocationStream() never meeting its exit condition. If an errorHandler throws an exception persistently, this can take down a service depending on what else the error handler is doing, there should be a circuit breaker that terminates the Flux stream.
Comment From: ilayaperumalg
This is fixed via #1699 https://github.com/spring-projects/spring-ai/commit/9fa89a2fd65dba03bd27b26ac49fd32a9fab558a