Skip to content

Commit

Permalink
Polishing
Browse files Browse the repository at this point in the history
  • Loading branch information
rstoyanchev authored and lxbzmy committed Mar 26, 2022
1 parent ec25f48 commit f7fd7ea
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -222,15 +222,15 @@ 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();
}
}
}

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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ public <T> void writeComplete(AbstractListenerWriteFlushProcessor<T> processor)
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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -430,7 +430,7 @@ else if (processor.changeState(this, WRITING)) {
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);
}
}
Expand All @@ -441,7 +441,7 @@ public <T> void onComplete(AbstractListenerWriteProcessor<T> processor) {
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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,14 @@ void subscribe(WriteResultPublisher publisher, Subscriber<? super Void> 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);
}
}
Expand All @@ -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);
}
}
Expand Down

0 comments on commit f7fd7ea

Please sign in to comment.