-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Issue #11803 - Follow Reactive Streams specification #11804
Conversation
jetty-core/jetty-io/src/test/java/org/eclipse/jetty/io/content/ContentSourcePublisherTest.java
Outdated
Show resolved
Hide resolved
jetty-core/jetty-io/src/test/java/org/eclipse/jetty/io/content/ContentSourcePublisherTest.java
Show resolved
Hide resolved
// As per rule 3.13, Subscription.cancel() MUST request the Publisher to eventually | ||
// drop any references to the corresponding subscriber. | ||
this.demand.set(NO_MORE_DEMAND); | ||
// TODO: HttpChannelState does not satisfy the contract of Content.Source "If read() has returned a last chunk, this is a no operation." |
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.
HttpChannelState does not satisfy the contract of Content.Source.fail method "If read() has returned a last chunk, this is a no operation."
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.
@@ -50,6 +55,22 @@ | |||
<argLine>@{argLine} ${jetty.surefire.argLine} | |||
--add-reads org.eclipse.jetty.io=org.eclipse.jetty.logging</argLine> | |||
</configuration> | |||
<dependencies> | |||
<!-- |
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.
It's ugly, but maybe I could:
- Create pull request to the reactive streams TCK and support also junit platform
- Have a look at the surefire plugin and try to understand if it possible to make junit5 with testng working together out of the box
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.
@olamy ???
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.
yup no much choice.
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.
It would be good to add parsing of testng
result files for Jenkins.
olamy@pop-os:~/dev/sources/jetty/jetty.project$ ls -lrt jetty-core/jetty-io/target/surefire-reports/Surefire\ suite/
total 72
-rw-rw-r-- 1 olamy olamy 60957 May 22 12:43 'Surefire test.html'
-rw-rw-r-- 1 olamy olamy 7951 May 22 12:43 'Surefire test.xml'
-rw-rw-r-- 1 olamy olamy 2127 May 22 12:43 testng-failed.xml
See the Jenkinsfille
transform
junit testResults: '**/target/surefire-reports/*.xml,**/target/invoker-reports/TEST*.xml', allowEmptyResults: true
into
junit testResults: '**/target/surefire-reports/**/*.xml,**/target/invoker-reports/TEST*.xml', allowEmptyResults: true
This should make it (at least we will see :))
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.
@olamy if you have time, could you please update jenkins configuration, because I'm not so much familiar with it
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 cannot push to your fork/branch. So you will need to cherry pick this commit 5f0168b
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.
cherry-picked, thanks. Jenkins could found the tests reports https://jenkins.webtide.net/job/jetty.project/job/PR-11804/20/testReport/org.eclipse.jetty.io.content/ContentSourcePublisherTest/
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.
Is this new testng requirement because it's used by import import org.reactivestreams.tck.TestEnvironment;
?
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.
@joakime unfortunately yes https://github.com/reactive-streams/reactive-streams-jvm/tree/master/tck
I'm not a fun to mix multiple testing frameworks, but it is what it is
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.
Thanks for this... looks good, but will need careful review. Just a couple of trivial comments first whilst I find time to look deeper....
jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/content/ContentSourcePublisher.java
Outdated
Show resolved
Hide resolved
jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/content/ContentSourcePublisher.java
Outdated
Show resolved
Hide resolved
jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/content/ContentSourcePublisher.java
Outdated
Show resolved
Hide resolved
jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/content/ContentSourcePublisher.java
Outdated
Show resolved
Hide resolved
jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/content/ContentSourcePublisher.java
Outdated
Show resolved
Hide resolved
jetty-core/jetty-io/src/test/java/org/eclipse/jetty/io/content/ContentSourcePublisherTest.java
Outdated
Show resolved
Hide resolved
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.
More feedback...
jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/content/ContentSourcePublisher.java
Show resolved
Hide resolved
jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/content/ContentSourcePublisher.java
Outdated
Show resolved
Hide resolved
jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/content/ContentSourcePublisher.java
Show resolved
Hide resolved
jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/content/ContentSourcePublisher.java
Show resolved
Hide resolved
jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/content/ContentSourcePublisher.java
Show resolved
Hide resolved
jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/content/ContentSourcePublisher.java
Show resolved
Hide resolved
jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/content/ContentSourcePublisher.java
Show resolved
Hide resolved
@@ -50,6 +55,22 @@ | |||
<argLine>@{argLine} ${jetty.surefire.argLine} | |||
--add-reads org.eclipse.jetty.io=org.eclipse.jetty.logging</argLine> | |||
</configuration> | |||
<dependencies> | |||
<!-- |
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.
It would be good to add parsing of testng
result files for Jenkins.
olamy@pop-os:~/dev/sources/jetty/jetty.project$ ls -lrt jetty-core/jetty-io/target/surefire-reports/Surefire\ suite/
total 72
-rw-rw-r-- 1 olamy olamy 60957 May 22 12:43 'Surefire test.html'
-rw-rw-r-- 1 olamy olamy 7951 May 22 12:43 'Surefire test.xml'
-rw-rw-r-- 1 olamy olamy 2127 May 22 12:43 testng-failed.xml
See the Jenkinsfille
transform
junit testResults: '**/target/surefire-reports/*.xml,**/target/invoker-reports/TEST*.xml', allowEmptyResults: true
into
junit testResults: '**/target/surefire-reports/**/*.xml,**/target/invoker-reports/TEST*.xml', allowEmptyResults: true
This should make it (at least we will see :))
|
||
public ContentSourcePublisher(Content.Source content) | ||
{ | ||
this.content = content; | ||
if (content == null) |
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.
Better use Objects.requireNonNull(content)
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.
@lorban thank you, fixed
// As per rule 2.13, we MUST consider subscription cancelled and | ||
// MUST raise this error condition in a fashion that is adequate for the runtime environment. | ||
subscription.cancel(err, LastWillSubscription.FinalSignal.SUPPRESS); | ||
LOG.error("Flow.Subscriber " + subscriber + " violated rule 2.13", err); |
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.
Wouldn't it be better to rethrow rather than logging?
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.
@lorban According to the specification we cannot throw any exception
- As per rule 1.9, subscribe method must return normally (i.e. not throw)
- As per rule 2.13, ...the caller MUST raise this error condition in a fashion that is adequate for the runtime environment. «Raise this error condition in a fashion that is adequate for the runtime environment» could mean logging the error—or otherwise make someone or something aware of the situation—as the error cannot be signalled to the faulty Subscriber.
jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/content/ContentSourcePublisher.java
Show resolved
Hide resolved
stalled = false; | ||
process = true; | ||
} | ||
if (reason == null) |
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.
Better use Objects.requireNonNull()
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.
@lorban thank you, fixed
jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/content/ContentSourcePublisher.java
Show resolved
Hide resolved
content.fail(chunk.getFailure()); | ||
subscriber.onError(chunk.getFailure()); | ||
return; | ||
LOG.error("Flow.Subscriber " + subscriber + " violated rule 2.13", err); |
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.
Why are you catching Throwable here?
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.
@lorban ActiveSubscription.process() method triggered from Subscription.cancel/request methods and may be executed synchronously
- 3.10, 3.11 While the Subscription is not cancelled, Subscription.request(long n) MAY synchronously call onNext on this
- 3.15 and 3.16 Calling Subscription.cancel/request MUST return normal (that's the reason why we cannot throw here)
- 2.13, ...the caller MUST raise this error condition in a fashion that is adequate for the runtime environment. «Raise this error condition in a fashion that is adequate for the runtime environment» could mean logging the error—or otherwise make someone or something aware of the situation—as the error cannot be signalled to the faulty Subscriber.
catch (Throwable err) | ||
{ | ||
cancel(err, FinalSignal.SUPPRESS); | ||
LOG.error("Flow.Subscriber " + subscriber + " violated rule 2.13", err); |
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.
Why not rethrowing?
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.
@lorban the same reason as above
…eactive streams tck Signed-off-by: Olivier Lamy <olamy@apache.org>
Simplified #11804 + removed LastWillSubscription, LastWill and FinalSignal + introduced Suppressed and Cancelled Throwables + updated notes
@scrat98 I thought you might be getting a bit tired of our exacting review process.... so I branched this in #11849 and changed it to how I'd like to see it. The key commit c216b00, which removes all the It passes the test. Feel free to bring in that commit here if you wish to make further modifications and I'll close the other PR. |
Simplified #11804 + removed LastWillSubscription, LastWill and FinalSignal + introduced Suppressed and Cancelled Throwables + updated notes
No worries, I'm much appreciated for such review process :) Thank you a lot for your time, I'll have a look at your changes this weekends(I'm sorry don't have enough free time this week) and cherry pick them. But the general idea is clear, thanks again |
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 think this looks good to go. Would be good to get it merged early in a release cycle.
I think the CI failures are unrelated, but we should check
Hi @gregw. If you don't mind let me day tomorrow, I would like to consider your changes as well and remove some todos from the code. I know that promised do it 2 days ago, but only tomorrow finally will have spare day to finish this merge request. Thanks in advance |
@gregw I think I'm done, one more time reviewed every comment and all changes. Small refactoring:
About your suggested changes:
Nevertheless, I gave you full access to the fork, feel free to merge your changes, I'm absolutely okay with it. About CI/CD tests it seems there are fluky tests, but this failed test I found really strange https://jenkins.webtide.net/job/jetty.project/job/PR-11804/20/testReport/org.eclipse.jetty.server/LoggerDebugTest/Parallel_Stage___Build___Test___JDK22___testWrapperNPE/ |
@scrat98 I have reopened by simplification of this in #11849. Not only do I not like the thanks for this contribution. |
Simplified jetty#11804 + removed LastWillSubscription, LastWill and FinalSignal + introduced Suppressed and Cancelled Throwables + updated notes
@gregw I prefer to merge your changes to this PR for the following reasons:
So I have cherry-picked your commit c216b00. If it's okay, please merge scrat98#1 Update: merge last changes as well. The difference with 11849 (git diff contrib/11804/ReactiveStreamSpec jetty-12.0.x-11849):
|
The main improvements: