Skip to content

Commit 468dadf

Browse files
committed
Responder: Check if a message need to be sent (responsePublisher == null)
1 parent 8ab7391 commit 468dadf

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

src/main/java/io/reactivesocket/internal/Responder.java

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -279,23 +279,25 @@ public void onNext(Frame requestFrame) {
279279
final RejectedException exception = new RejectedException("No associated lease");
280280
responsePublisher = PublisherUtils.errorFrame(streamId, exception);
281281
}
282-
283-
connection.addOutput(responsePublisher, new Completable() {
284-
@Override
285-
public void success() {
286-
// TODO Auto-generated method stub
287-
}
288282

289-
@Override
290-
public void error(Throwable e) {
291-
// TODO validate with unit tests
292-
if (childTerminated.compareAndSet(false, true)) {
293-
errorStream.accept(new RuntimeException("Error writing", e)); // TODO should we have typed RuntimeExceptions?
294-
cancel();
283+
if (responsePublisher != null) {
284+
connection.addOutput(responsePublisher, new Completable() {
285+
@Override
286+
public void success() {
287+
// TODO Auto-generated method stub
295288
}
296-
}
297289

298-
});
290+
@Override
291+
public void error(Throwable e) {
292+
// TODO validate with unit tests
293+
if (childTerminated.compareAndSet(false, true)) {
294+
errorStream.accept(new RuntimeException("Error writing", e)); // TODO should we have typed RuntimeExceptions?
295+
cancel();
296+
}
297+
}
298+
299+
});
300+
}
299301
}
300302
}
301303

0 commit comments

Comments
 (0)