Skip to content

Commit 21c9082

Browse files
committed
Polishing
See gh-26834
1 parent 5b96c9b commit 21c9082

File tree

5 files changed

+13
-13
lines changed

5 files changed

+13
-13
lines changed

Diff for: spring-web/src/main/java/org/springframework/http/server/reactive/AbstractListenerReadPublisher.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ public final void onError(Throwable ex) {
186186
*/
187187
private boolean readAndPublish() throws IOException {
188188
long r;
189-
while ((r = this.demand) > 0 && !this.state.get().equals(State.COMPLETED)) {
189+
while ((r = this.demand) > 0 && (this.state.get() != State.COMPLETED)) {
190190
T data = read();
191191
if (data != null) {
192192
if (r != Long.MAX_VALUE) {
@@ -222,15 +222,15 @@ private void changeToDemandState(State oldState) {
222222
// Protect from infinite recursion in Undertow, where we can't check if data
223223
// is available, so all we can do is to try to read.
224224
// Generally, no need to check if we just came out of readAndPublish()...
225-
if (!oldState.equals(State.READING)) {
225+
if (oldState != State.READING) {
226226
checkOnDataAvailable();
227227
}
228228
}
229229
}
230230

231231
private boolean handlePendingCompletionOrError() {
232232
State state = this.state.get();
233-
if (state.equals(State.DEMAND) || state.equals(State.NO_DEMAND)) {
233+
if (state == State.DEMAND || state == State.NO_DEMAND) {
234234
if (this.completionPending) {
235235
rsReadLogger.trace(getLogPrefix() + "Processing pending completion");
236236
this.state.get().onAllDataRead(this);

Diff for: spring-web/src/main/java/org/springframework/http/server/reactive/AbstractListenerWriteFlushProcessor.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ public <T> void writeComplete(AbstractListenerWriteFlushProcessor<T> processor)
329329
public <T> void onComplete(AbstractListenerWriteFlushProcessor<T> processor) {
330330
processor.sourceCompleted = true;
331331
// A competing write might have completed very quickly
332-
if (processor.state.get().equals(State.REQUESTED)) {
332+
if (processor.state.get() == State.REQUESTED) {
333333
handleSourceCompleted(processor);
334334
}
335335
}

Diff for: spring-web/src/main/java/org/springframework/http/server/reactive/AbstractListenerWriteProcessor.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -183,14 +183,14 @@ void cancelAndSetCompleted() {
183183
cancel();
184184
for (;;) {
185185
State prev = this.state.get();
186-
if (prev.equals(State.COMPLETED)) {
186+
if (prev == State.COMPLETED) {
187187
break;
188188
}
189189
if (this.state.compareAndSet(prev, State.COMPLETED)) {
190190
if (rsWriteLogger.isTraceEnabled()) {
191191
rsWriteLogger.trace(getLogPrefix() + prev + " -> " + this.state);
192192
}
193-
if (!prev.equals(State.WRITING)) {
193+
if (prev != State.WRITING) {
194194
discardCurrentData();
195195
}
196196
break;
@@ -430,7 +430,7 @@ else if (processor.changeState(this, WRITING)) {
430430
public <T> void onComplete(AbstractListenerWriteProcessor<T> processor) {
431431
processor.sourceCompleted = true;
432432
// A competing write might have completed very quickly
433-
if (processor.state.get().equals(State.REQUESTED)) {
433+
if (processor.state.get() == State.REQUESTED) {
434434
processor.changeStateToComplete(State.REQUESTED);
435435
}
436436
}
@@ -441,7 +441,7 @@ public <T> void onComplete(AbstractListenerWriteProcessor<T> processor) {
441441
public <T> void onComplete(AbstractListenerWriteProcessor<T> processor) {
442442
processor.sourceCompleted = true;
443443
// A competing write might have completed very quickly
444-
if (processor.state.get().equals(State.REQUESTED)) {
444+
if (processor.state.get() == State.REQUESTED) {
445445
processor.changeStateToComplete(State.REQUESTED);
446446
}
447447
}

Diff for: spring-web/src/main/java/org/springframework/http/server/reactive/ServletHttpHandlerAdapter.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ private String getServletPath(ServletConfig config) {
157157
@Override
158158
public void service(ServletRequest request, ServletResponse response) throws ServletException, IOException {
159159
// Check for existing error attribute first
160-
if (DispatcherType.ASYNC.equals(request.getDispatcherType())) {
160+
if (DispatcherType.ASYNC == request.getDispatcherType()) {
161161
Throwable ex = (Throwable) request.getAttribute(WRITE_ERROR_ATTRIBUTE_NAME);
162162
throw new ServletException("Failed to create response content", ex);
163163
}

Diff for: spring-web/src/main/java/org/springframework/http/server/reactive/WriteResultPublisher.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -182,14 +182,14 @@ void subscribe(WriteResultPublisher publisher, Subscriber<? super Void> subscrib
182182
@Override
183183
void publishComplete(WriteResultPublisher publisher) {
184184
publisher.completedBeforeSubscribed = true;
185-
if(State.SUBSCRIBED.equals(publisher.state.get())) {
185+
if(State.SUBSCRIBED == publisher.state.get()) {
186186
publisher.state.get().publishComplete(publisher);
187187
}
188188
}
189189
@Override
190190
void publishError(WriteResultPublisher publisher, Throwable ex) {
191191
publisher.errorBeforeSubscribed = ex;
192-
if(State.SUBSCRIBED.equals(publisher.state.get())) {
192+
if(State.SUBSCRIBED == publisher.state.get()) {
193193
publisher.state.get().publishError(publisher, ex);
194194
}
195195
}
@@ -203,14 +203,14 @@ void request(WriteResultPublisher publisher, long n) {
203203
@Override
204204
void publishComplete(WriteResultPublisher publisher) {
205205
publisher.completedBeforeSubscribed = true;
206-
if(State.SUBSCRIBED.equals(publisher.state.get())) {
206+
if(State.SUBSCRIBED == publisher.state.get()) {
207207
publisher.state.get().publishComplete(publisher);
208208
}
209209
}
210210
@Override
211211
void publishError(WriteResultPublisher publisher, Throwable ex) {
212212
publisher.errorBeforeSubscribed = ex;
213-
if(State.SUBSCRIBED.equals(publisher.state.get())) {
213+
if(State.SUBSCRIBED == publisher.state.get()) {
214214
publisher.state.get().publishError(publisher, ex);
215215
}
216216
}

0 commit comments

Comments
 (0)