File tree Expand file tree Collapse file tree 2 files changed +18
-6
lines changed
runtime_impl_jetty121/src/test/java/com/google/apphosting/runtime/http
runtime_impl_jetty9/src/test/java/com/google/apphosting/runtime/http Expand file tree Collapse file tree 2 files changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -40,16 +40,21 @@ public class InterruptedApiCallTest extends HttpApiProxyImplTestBase {
4040 * it only gets expected exceptions.
4141 */
4242 @ Test
43- public void interruptedApiCall () {
43+ public void interruptedApiCall () throws InterruptedException {
4444 AtomicBoolean stop = new AtomicBoolean ();
45+ Thread apiClientThread = null ;
4546 try {
46- interruptedApiCall (stop );
47+ apiClientThread = interruptedApiCall (stop );
4748 } finally {
4849 stop .set (true );
50+ if (apiClientThread != null ) {
51+ apiClientThread .interrupt (); // Ensure it wakes up from any blocking call
52+ apiClientThread .join ();
53+ }
4954 }
5055 }
5156
52- private void interruptedApiCall (AtomicBoolean stop ) {
57+ private Thread interruptedApiCall (AtomicBoolean stop ) {
5358 HttpApiHostClient .Config interruptibleConfig =
5459 config .toBuilder ()
5560 // With the Jetty client, this test occasionally gets ClosedChannelException. Since
@@ -77,6 +82,7 @@ private void interruptedApiCall(AtomicBoolean stop) {
7782 }
7883 assertThat (apiClientTask .exceptionInMakeAsyncCall .get ()).isNull ();
7984 assertThat (apiClientTask .exceptionInFutureGet .get ()).isNull ();
85+ return apiClientThread ;
8086 }
8187
8288 private static class ApiClientTask implements Runnable {
Original file line number Diff line number Diff line change @@ -40,16 +40,21 @@ public class InterruptedApiCallTest extends HttpApiProxyImplTestBase {
4040 * it only gets expected exceptions.
4141 */
4242 @ Test
43- public void interruptedApiCall () {
43+ public void interruptedApiCall () throws InterruptedException {
4444 AtomicBoolean stop = new AtomicBoolean ();
45+ Thread apiClientThread = null ;
4546 try {
46- interruptedApiCall (stop );
47+ apiClientThread = interruptedApiCall (stop );
4748 } finally {
4849 stop .set (true );
50+ if (apiClientThread != null ) {
51+ apiClientThread .interrupt (); // Ensure it wakes up from any blocking call
52+ apiClientThread .join ();
53+ }
4954 }
5055 }
5156
52- private void interruptedApiCall (AtomicBoolean stop ) {
57+ private Thread interruptedApiCall (AtomicBoolean stop ) {
5358 HttpApiHostClient .Config interruptibleConfig =
5459 config .toBuilder ()
5560 // With the Jetty client, this test occasionally gets ClosedChannelException. Since
@@ -77,6 +82,7 @@ private void interruptedApiCall(AtomicBoolean stop) {
7782 }
7883 assertThat (apiClientTask .exceptionInMakeAsyncCall .get ()).isNull ();
7984 assertThat (apiClientTask .exceptionInFutureGet .get ()).isNull ();
85+ return apiClientThread ;
8086 }
8187
8288 private static class ApiClientTask implements Runnable {
You can’t perform that action at this time.
0 commit comments