opensearch-java icon indicating copy to clipboard operation
opensearch-java copied to clipboard

[BUG] Synchronous calls with async transport should preserve caller stack trace

Open andrewparmet opened this issue 2 years ago • 2 comments

What is the bug?

When an OpenSearchClient built with async transport fails, the transports unwrap causes and propagate them if they're RuntimeExceptions. We lose the stack trace since the exception originated in some pooled thread. Can these exceptions instead be re-wrapped in an IOException and propagated as the interface allows?

As it stands I just wrap the existing transport with one that catches and wraps this way, so it's not the end of the world, but it was confusing that we got random stack traces from a "synchronous" call.

andrewparmet avatar Oct 04 '23 23:10 andrewparmet

That's a good find! Care to fix/contribute, even starting with a test that demonstrates the issue?

dblock avatar Oct 05 '23 17:10 dblock

Sure - here's a first go: https://github.com/opensearch-project/opensearch-java/pull/656

andrewparmet avatar Oct 06 '23 20:10 andrewparmet