rollbar / rollbar-java

Rollbar for Java and Android
https://docs.rollbar.com/docs/java
MIT License
71 stars 76 forks source link

Add reactive-streams Notifier implementation with optional Reactor support #263

Closed diegov closed 3 years ago

diegov commented 3 years ago

Description of the change

This PR adds two projects, a reactive-streams notifier supporting Java 7, as well as Project Reactor Project Reactor extensions in Java 8.

The implementations support non-blocking API calls, and provide default HTTP client implementations using Apache HTTPComponents in Java 7, and Reactor's built-in HTTP client in Java 8.

The interface of the non-blocking notifier reproduces as much as possible the interface of the core notifier, but it returns a Publisher<Response> instead of void, which must be consumed to execute the operation.

There is also a sync Sender implementation that wraps a non-blocking sender with fire-and-forget semantics, similar to the BufferedSender, but allowing the re-use an existing non-blocking IO reactor if an application is already using one. This can be used as a drop in replacement in the rollbar-java configuration.

Currently the build config is setup not to publish the artifacts to maven, since we expect most of the use in these features to come from the Spring Webflux integration, that will be delivered later.

Clubhouse: [ch82044]

Type of change

Related issues

Checklists

Development

Code review

shortcut-integration[bot] commented 3 years ago

This pull request has been linked to Clubhouse Story #82044: rollbar-java: org.reactivestreams support.

diegov commented 3 years ago

One general question to the async sender capabilities. What about support for different API endpoint and around HTTPS? I'm not sure how it's handled by rollbar-java but seems like much work is done in the sync sender than the async. E.g. can I use the rollbar-java to report to untrusted localhost server?

Most of the logic (payload manipulation, serialisation, etc...) is done in RollbarBase so it's reused between blocking and non-blocking code. The endpoint URL is configurable through the same config parameter in both cases, and it can be HTTP or HTTPS. Disabling HTTPS cert verification, or customising CAs is not available as a notifier option though, and it's kind of a hassle since there isn't a single HTTPS cert verification configuration used for all HTTP clients (some clients don't even have the option to customise this at all.) The best approach for development is to add a CA to the JVM's cert store.