Skip to content

Commit

Permalink
Fix race condition in WriteResultPublisher
Browse files Browse the repository at this point in the history
between subscription and error from the Publish

Closes gh-25096
  • Loading branch information
rstoyanchev committed May 28, 2020
1 parent bb96bd4 commit e25e6a6
Showing 1 changed file with 7 additions and 1 deletion.
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -182,6 +182,9 @@ void publishComplete(WriteResultPublisher publisher) {
@Override
void publishError(WriteResultPublisher publisher, Throwable ex) {
publisher.errorBeforeSubscribed = ex;
if(State.SUBSCRIBED.equals(publisher.state.get())) {
publisher.state.get().publishError(publisher, ex);
}
}
},

Expand All @@ -200,6 +203,9 @@ void publishComplete(WriteResultPublisher publisher) {
@Override
void publishError(WriteResultPublisher publisher, Throwable ex) {
publisher.errorBeforeSubscribed = ex;
if(State.SUBSCRIBED.equals(publisher.state.get())) {
publisher.state.get().publishError(publisher, ex);
}
}
},

Expand Down

0 comments on commit e25e6a6

Please sign in to comment.