Skip to content

Commit 73a3aa7

Browse files
[cuebot] Complete the gRPC response in ShowInterface.SetCommentEmail (#2409)
## Related Issues - #2408 ## Summarize your change. ManageShow.setCommentEmail called responseObserver.onNext(...) but never responseObserver.onCompleted(), so the gRPC stream was never closed and callers hung until they timed out (the email was still written to the database). Every other setter in this servant closes the stream. Add the missing onCompleted() so the RPC returns promptly, and add a ManageShowTests.testSetCommentEmail regression test - using a recording StreamObserver that asserts onCompleted() was called (the existing FakeStreamObserver has empty methods and wouldn't catch this) and that the comment email is persisted. Fixes the hang in CueGUI's and CueWeb's Show Properties "Comment Notification Email" field.
1 parent 4c2f72b commit 73a3aa7

2 files changed

Lines changed: 55 additions & 0 deletions

File tree

cuebot/src/main/java/com/imageworks/spcue/servant/ManageShow.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,7 @@ public void setCommentEmail(ShowSetCommentEmailRequest request,
448448
adminManager.updateShowCommentEmail(getShowEntity(request.getShow()),
449449
request.getEmail().split(","));
450450
responseObserver.onNext(ShowSetCommentEmailResponse.newBuilder().build());
451+
responseObserver.onCompleted();
451452
}
452453

453454
public AdminManager getAdminManager() {

cuebot/src/test/java/com/imageworks/spcue/test/servant/ManageShowTests.java

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,15 @@
2828
import com.imageworks.spcue.config.TestAppConfig;
2929
import com.imageworks.spcue.dao.ShowDao;
3030
import com.imageworks.spcue.grpc.show.Show;
31+
import com.imageworks.spcue.grpc.show.ShowSetCommentEmailRequest;
32+
import com.imageworks.spcue.grpc.show.ShowSetCommentEmailResponse;
3133
import com.imageworks.spcue.grpc.show.ShowSetSchedulerManagedRequest;
3234
import com.imageworks.spcue.grpc.show.ShowSetSchedulerManagedResponse;
3335
import com.imageworks.spcue.servant.ManageShow;
3436

37+
import io.grpc.stub.StreamObserver;
38+
39+
import static org.junit.Assert.assertArrayEquals;
3540
import static org.junit.Assert.assertFalse;
3641
import static org.junit.Assert.assertTrue;
3742

@@ -47,6 +52,55 @@ public class ManageShowTests extends AbstractTransactionalJUnit4SpringContextTes
4752

4853
private static final String SHOW_NAME = "pipe";
4954

55+
/**
56+
* StreamObserver that records whether onNext / onCompleted were called, so a servant method
57+
* that forgets to close the stream (onCompleted) is caught.
58+
*/
59+
private static class RecordingStreamObserver<T> implements StreamObserver<T> {
60+
boolean nextCalled = false;
61+
boolean completed = false;
62+
Throwable error = null;
63+
64+
@Override
65+
public void onNext(T value) {
66+
nextCalled = true;
67+
}
68+
69+
@Override
70+
public void onError(Throwable t) {
71+
error = t;
72+
}
73+
74+
@Override
75+
public void onCompleted() {
76+
completed = true;
77+
}
78+
}
79+
80+
@Test
81+
@Transactional
82+
@Rollback(true)
83+
public void testSetCommentEmail() {
84+
ShowEntity show = showDao.findShowDetail(SHOW_NAME);
85+
Show showProto = Show.newBuilder().setId(show.id).setName(show.name).build();
86+
87+
ShowSetCommentEmailRequest request = ShowSetCommentEmailRequest.newBuilder()
88+
.setShow(showProto).setEmail("first@example.com,second@example.com").build();
89+
RecordingStreamObserver<ShowSetCommentEmailResponse> observer =
90+
new RecordingStreamObserver<ShowSetCommentEmailResponse>();
91+
92+
manageShow.setCommentEmail(request, observer);
93+
94+
// The RPC must both emit a response and CLOSE the stream; a missing
95+
// onCompleted() leaves callers hanging until they time out.
96+
assertTrue(observer.nextCalled);
97+
assertTrue(observer.completed);
98+
99+
// And the email is persisted (split on comma, matching the servant).
100+
assertArrayEquals(new String[] {"first@example.com", "second@example.com"},
101+
showDao.findShowDetail(SHOW_NAME).commentMail);
102+
}
103+
50104
@Test
51105
@Transactional
52106
@Rollback(true)

0 commit comments

Comments
 (0)