diff --git a/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractListenerReadPublisher.java b/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractListenerReadPublisher.java index 21776e751dc9..0845a9f25f04 100644 --- a/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractListenerReadPublisher.java +++ b/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractListenerReadPublisher.java @@ -186,7 +186,7 @@ public final void onError(Throwable ex) { */ 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 @@ private void changeToDemandState(State oldState) { // 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 @@ private void changeToDemandState(State oldState) { 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); diff --git a/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractListenerWriteFlushProcessor.java b/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractListenerWriteFlushProcessor.java index 10342d681d10..1d04470065b1 100644 --- a/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractListenerWriteFlushProcessor.java +++ b/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractListenerWriteFlushProcessor.java @@ -329,7 +329,7 @@ public void writeComplete(AbstractListenerWriteFlushProcessor processor) public void onComplete(AbstractListenerWriteFlushProcessor 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); } } diff --git a/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractListenerWriteProcessor.java b/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractListenerWriteProcessor.java index b1a2a3affe1d..92d7b41846b5 100644 --- a/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractListenerWriteProcessor.java +++ b/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractListenerWriteProcessor.java @@ -183,14 +183,14 @@ void cancelAndSetCompleted() { 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 @@ else if (processor.changeState(this, WRITING)) { public void onComplete(AbstractListenerWriteProcessor 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 void onComplete(AbstractListenerWriteProcessor processor) { public void onComplete(AbstractListenerWriteProcessor 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); } } diff --git a/spring-web/src/main/java/org/springframework/http/server/reactive/ServletHttpHandlerAdapter.java b/spring-web/src/main/java/org/springframework/http/server/reactive/ServletHttpHandlerAdapter.java index b705df0da388..c38837c7ed03 100644 --- a/spring-web/src/main/java/org/springframework/http/server/reactive/ServletHttpHandlerAdapter.java +++ b/spring-web/src/main/java/org/springframework/http/server/reactive/ServletHttpHandlerAdapter.java @@ -157,7 +157,7 @@ private String getServletPath(ServletConfig config) { @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); } diff --git a/spring-web/src/main/java/org/springframework/http/server/reactive/WriteResultPublisher.java b/spring-web/src/main/java/org/springframework/http/server/reactive/WriteResultPublisher.java index 9bac8734bc56..63ac63dd3557 100644 --- a/spring-web/src/main/java/org/springframework/http/server/reactive/WriteResultPublisher.java +++ b/spring-web/src/main/java/org/springframework/http/server/reactive/WriteResultPublisher.java @@ -182,14 +182,14 @@ void subscribe(WriteResultPublisher publisher, Subscriber subscrib @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 @@ void request(WriteResultPublisher publisher, long n) { @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); } }