Polishing
See gh-26834
This commit is contained in:
@@ -186,7 +186,7 @@ public abstract class AbstractListenerReadPublisher<T> implements Publisher<T> {
|
||||
*/
|
||||
private boolean readAndPublish() throws IOException {
|
||||
long r;
|
||||
while ((r = this.demand) > 0 && !this.state.get().equals(State.COMPLETED)) {
|
||||
while ((r = this.demand) > 0 && (this.state.get() != State.COMPLETED)) {
|
||||
T data = read();
|
||||
if (data != null) {
|
||||
if (r != Long.MAX_VALUE) {
|
||||
@@ -222,7 +222,7 @@ public abstract class AbstractListenerReadPublisher<T> implements Publisher<T> {
|
||||
// Protect from infinite recursion in Undertow, where we can't check if data
|
||||
// is available, so all we can do is to try to read.
|
||||
// Generally, no need to check if we just came out of readAndPublish()...
|
||||
if (!oldState.equals(State.READING)) {
|
||||
if (oldState != State.READING) {
|
||||
checkOnDataAvailable();
|
||||
}
|
||||
}
|
||||
@@ -230,7 +230,7 @@ public abstract class AbstractListenerReadPublisher<T> implements Publisher<T> {
|
||||
|
||||
private boolean handlePendingCompletionOrError() {
|
||||
State state = this.state.get();
|
||||
if (state.equals(State.DEMAND) || state.equals(State.NO_DEMAND)) {
|
||||
if (state == State.DEMAND || state == State.NO_DEMAND) {
|
||||
if (this.completionPending) {
|
||||
rsReadLogger.trace(getLogPrefix() + "Processing pending completion");
|
||||
this.state.get().onAllDataRead(this);
|
||||
|
||||
@@ -329,7 +329,7 @@ public abstract class AbstractListenerWriteFlushProcessor<T> implements Processo
|
||||
public <T> void onComplete(AbstractListenerWriteFlushProcessor<T> processor) {
|
||||
processor.sourceCompleted = true;
|
||||
// A competing write might have completed very quickly
|
||||
if (processor.state.get().equals(State.REQUESTED)) {
|
||||
if (processor.state.get() == State.REQUESTED) {
|
||||
handleSourceCompleted(processor);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,14 +183,14 @@ public abstract class AbstractListenerWriteProcessor<T> implements Processor<T,
|
||||
cancel();
|
||||
for (;;) {
|
||||
State prev = this.state.get();
|
||||
if (prev.equals(State.COMPLETED)) {
|
||||
if (prev == State.COMPLETED) {
|
||||
break;
|
||||
}
|
||||
if (this.state.compareAndSet(prev, State.COMPLETED)) {
|
||||
if (rsWriteLogger.isTraceEnabled()) {
|
||||
rsWriteLogger.trace(getLogPrefix() + prev + " -> " + this.state);
|
||||
}
|
||||
if (!prev.equals(State.WRITING)) {
|
||||
if (prev != State.WRITING) {
|
||||
discardCurrentData();
|
||||
}
|
||||
break;
|
||||
@@ -430,7 +430,7 @@ public abstract class AbstractListenerWriteProcessor<T> implements Processor<T,
|
||||
public <T> void onComplete(AbstractListenerWriteProcessor<T> processor) {
|
||||
processor.sourceCompleted = true;
|
||||
// A competing write might have completed very quickly
|
||||
if (processor.state.get().equals(State.REQUESTED)) {
|
||||
if (processor.state.get() == State.REQUESTED) {
|
||||
processor.changeStateToComplete(State.REQUESTED);
|
||||
}
|
||||
}
|
||||
@@ -441,7 +441,7 @@ public abstract class AbstractListenerWriteProcessor<T> implements Processor<T,
|
||||
public <T> void onComplete(AbstractListenerWriteProcessor<T> processor) {
|
||||
processor.sourceCompleted = true;
|
||||
// A competing write might have completed very quickly
|
||||
if (processor.state.get().equals(State.REQUESTED)) {
|
||||
if (processor.state.get() == State.REQUESTED) {
|
||||
processor.changeStateToComplete(State.REQUESTED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,7 +157,7 @@ public class ServletHttpHandlerAdapter implements Servlet {
|
||||
@Override
|
||||
public void service(ServletRequest request, ServletResponse response) throws ServletException, IOException {
|
||||
// Check for existing error attribute first
|
||||
if (DispatcherType.ASYNC.equals(request.getDispatcherType())) {
|
||||
if (DispatcherType.ASYNC == request.getDispatcherType()) {
|
||||
Throwable ex = (Throwable) request.getAttribute(WRITE_ERROR_ATTRIBUTE_NAME);
|
||||
throw new ServletException("Failed to create response content", ex);
|
||||
}
|
||||
|
||||
@@ -182,14 +182,14 @@ class WriteResultPublisher implements Publisher<Void> {
|
||||
@Override
|
||||
void publishComplete(WriteResultPublisher publisher) {
|
||||
publisher.completedBeforeSubscribed = true;
|
||||
if(State.SUBSCRIBED.equals(publisher.state.get())) {
|
||||
if(State.SUBSCRIBED == publisher.state.get()) {
|
||||
publisher.state.get().publishComplete(publisher);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
void publishError(WriteResultPublisher publisher, Throwable ex) {
|
||||
publisher.errorBeforeSubscribed = ex;
|
||||
if(State.SUBSCRIBED.equals(publisher.state.get())) {
|
||||
if(State.SUBSCRIBED == publisher.state.get()) {
|
||||
publisher.state.get().publishError(publisher, ex);
|
||||
}
|
||||
}
|
||||
@@ -203,14 +203,14 @@ class WriteResultPublisher implements Publisher<Void> {
|
||||
@Override
|
||||
void publishComplete(WriteResultPublisher publisher) {
|
||||
publisher.completedBeforeSubscribed = true;
|
||||
if(State.SUBSCRIBED.equals(publisher.state.get())) {
|
||||
if(State.SUBSCRIBED == publisher.state.get()) {
|
||||
publisher.state.get().publishComplete(publisher);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
void publishError(WriteResultPublisher publisher, Throwable ex) {
|
||||
publisher.errorBeforeSubscribed = ex;
|
||||
if(State.SUBSCRIBED.equals(publisher.state.get())) {
|
||||
if(State.SUBSCRIBED == publisher.state.get()) {
|
||||
publisher.state.get().publishError(publisher, ex);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user