Skip to content

fix: Better exception handling in Rx3Util#68

Merged
kennethjor merged 10 commits intoautonomouslogic:mainfrom
jamesoguyer:refactor/use-defer-and-fromfuture
Mar 12, 2025
Merged

fix: Better exception handling in Rx3Util#68
kennethjor merged 10 commits intoautonomouslogic:mainfrom
jamesoguyer:refactor/use-defer-and-fromfuture

Conversation

@jamesoguyer
Copy link
Copy Markdown
Contributor

@jamesoguyer jamesoguyer commented Jan 21, 2025

This PR refactors the Rx3Util.toSingle and Rx3Util.toMaybe methods to improve their behavior and consistency when wrapping CompletionStage objects. The changes include better handling of null values, efficient cancellation, and proper error propagation. Corresponding test cases have been updated to ensure correctness.

@jamesoguyer jamesoguyer changed the title Refactor/use defer and fromfuture fix: Improve Rx3Util CompletionStage Wrappers for Better Error Handling and Cancellation Support Jan 21, 2025
@sonarqubecloud
Copy link
Copy Markdown

@sonarqubecloud
Copy link
Copy Markdown

assertEquals("java.lang.RuntimeException: test error", ex.getMessage());
ex.printStackTrace();
assertEquals(
"java.util.concurrent.ExecutionException: java.util.concurrent.CompletionException: java.lang.RuntimeException: test error",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't match exactly, but it's good enough

var maybe = Maybe.fromFuture(future);
var ex = assertThrows(RuntimeException.class, maybe::blockingGet);
ex.printStackTrace();
assertEquals("test error", ex.getMessage());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know why RxJava's Maybe.fromFuture doesn't wrap it like the others do. I opted to wrap it below to have consistency.

@kennethjor kennethjor changed the title fix: Improve Rx3Util CompletionStage Wrappers for Better Error Handling and Cancellation Support fix: Better exception handling in Rx3Util Mar 12, 2025
@kennethjor kennethjor merged commit 05e7364 into autonomouslogic:main Mar 12, 2025
4 checks passed
autonomous-logic-code-bot pushed a commit that referenced this pull request Mar 12, 2025
## [1.9.5](1.9.4...1.9.5) (2025-03-12)

### Bug Fixes

* Better exception handling in Rx3Util ([#68](#68)) ([05e7364](05e7364))

### Miscellaneous Chores

* **deps:** update plugin org.danilopianini.git-sensitive-semantic-versioning-gradle-plugin to v4 ([#69](#69)) ([6cb1535](6cb1535))
@autonomous-logic-code-bot
Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 1.9.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants