-
Notifications
You must be signed in to change notification settings - Fork 129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Internal optimisations #377
Conversation
Todo: add a consolidating summary in the PR description when ready for review |
Codecov Report
@@ Coverage Diff @@
## master #377 +/- ##
============================================
+ Coverage 89.82% 89.99% +0.16%
- Complexity 2768 2776 +8
============================================
Files 369 370 +1
Lines 10597 10624 +27
Branches 1298 1304 +6
============================================
+ Hits 9519 9561 +42
+ Misses 570 568 -2
+ Partials 508 495 -13 |
It's ok to fail, it needs #378 |
c172411
to
c97da07
Compare
c97da07
to
4e9d713
Compare
5d603da
to
9af5a9d
Compare
implementation/src/main/java/io/smallrye/mutiny/converters/uni/ToPublisher.java
Show resolved
Hide resolved
try { | ||
downstream.onNext(item); | ||
} catch (Throwable failure) { | ||
downstream.onError(failure); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't believe we should call onError here, if the failure comes from the downstream. You need to cancel, but I don't think we need to send a second event.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we just do:
if (upstream.getAndSet(CANCELLED) != CANCELLED) {
if (item != null) {
downstream.onNext(item);
}
downstream.onComplete();
}
then tests fail in UniRepeatTest
and UniCastProcessorTest
fail.
Handling exceptions as dropped exceptions does not work either, the downstream in these tests does want the error:
if (upstream.getAndSet(CANCELLED) != CANCELLED) {
if (item != null) {
try {
downstream.onNext(item);
} catch (Throwable failure) {
Infrastructure.handleDroppedException(failure);
return;
}
}
downstream.onComplete();
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(basically calling onError
does preserve the existing behaviour)
I can only accept that argument!
…On Fri 8 Jan 2021 at 10:09, Julien Ponge ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In
implementation/src/main/java/io/smallrye/mutiny/converters/uni/ToPublisher.java
<#377 (comment)>
:
> @@ -22,74 +27,8 @@ private ToPublisher() {
@OverRide
public Publisher<T> apply(Uni<T> uni) {
Yes, it's clearer when looking at stack traces believe me :-)
—
You are receiving this because your review was requested.
Reply to this email directly, view it on GitHub
<#377 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AADCG7LRTYYYXMFEZY22Q33SY3DVTANCNFSM4UKLOCEA>
.
|
Ok, we would need to see why these other tests require this second signal
as the failure comes from downstream. It is fine because the downstream
being failed the event is dropped.
…On Fri 8 Jan 2021 at 10:20, Julien Ponge ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In
implementation/src/main/java/io/smallrye/mutiny/converters/uni/UniToMultiPublisher.java
<#377 (comment)>
:
> + @OverRide
+ public void onSubscribe(UniSubscription subscription) {
+ if (!upstream.compareAndSet(null, subscription)) {
+ downstream.onError(new IllegalStateException(
+ "Invalid subscription state - already have a subscription for upstream"));
+ }
+ }
+
+ @OverRide
+ public void onItem(T item) {
+ if (upstream.getAndSet(CANCELLED) != CANCELLED) {
+ if (item != null) {
+ try {
+ downstream.onNext(item);
+ } catch (Throwable failure) {
+ downstream.onError(failure);
(basically calling onError does preserve the existing behaviour)
—
You are receiving this because your review was requested.
Reply to this email directly, view it on GitHub
<#377 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AADCG7JAABESMF6NVCUVJBDSY3E7BANCNFSM4UKLOCEA>
.
|
Looking into the corresponding operators, looks like they don't handle predicates throwing an exception as they should. |
Here we go :-)
…On Fri 8 Jan 2021 at 10:43, Julien Ponge ***@***.***> wrote:
Looking into the corresponding operators, looks like they don't handle
predicates throwing an exception as they should.
—
You are receiving this because your review was requested.
Reply to this email directly, view it on GitHub
<#377 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AADCG7PN7PVLES3R64PKLY3SY3HUPANCNFSM4UKLOCEA>
.
|
A set of performance-oriented optimisations and cleanups.