|
13 | 13 | import org.slf4j.Logger;
|
14 | 14 | import org.slf4j.LoggerFactory;
|
15 | 15 |
|
16 |
| -import javax.servlet.*; |
| 16 | +import javax.servlet.AsyncContext; |
| 17 | +import javax.servlet.AsyncEvent; |
| 18 | +import javax.servlet.AsyncListener; |
| 19 | +import javax.servlet.Servlet; |
| 20 | +import javax.servlet.ServletException; |
17 | 21 | import javax.servlet.http.HttpServlet;
|
18 | 22 | import javax.servlet.http.HttpServletRequest;
|
19 | 23 | import javax.servlet.http.HttpServletResponse;
|
@@ -264,11 +268,19 @@ private void mapMultipartVariables(GraphQLRequest request,
|
264 | 268 | }
|
265 | 269 |
|
266 | 270 | public void addListener(GraphQLServletListener servletListener) {
|
267 |
| - configuration.add(servletListener); |
| 271 | + if (configuration != null) { |
| 272 | + configuration.add(servletListener); |
| 273 | + } else { |
| 274 | + listeners.add(servletListener); |
| 275 | + } |
268 | 276 | }
|
269 | 277 |
|
270 | 278 | public void removeListener(GraphQLServletListener servletListener) {
|
271 |
| - configuration.remove(servletListener); |
| 279 | + if (configuration != null) { |
| 280 | + configuration.remove(servletListener); |
| 281 | + } else { |
| 282 | + listeners.remove(servletListener); |
| 283 | + } |
272 | 284 | }
|
273 | 285 |
|
274 | 286 | @Override
|
@@ -454,23 +466,28 @@ default void accept(HttpServletRequest request, HttpServletResponse response) {
|
454 | 466 |
|
455 | 467 | private static class SubscriptionAsyncListener implements AsyncListener {
|
456 | 468 | private final AtomicReference<Subscription> subscriptionRef;
|
| 469 | + |
457 | 470 | public SubscriptionAsyncListener(AtomicReference<Subscription> subscriptionRef) {
|
458 | 471 | this.subscriptionRef = subscriptionRef;
|
459 | 472 | }
|
460 | 473 |
|
461 |
| - @Override public void onComplete(AsyncEvent event) { |
| 474 | + @Override |
| 475 | + public void onComplete(AsyncEvent event) { |
462 | 476 | subscriptionRef.get().cancel();
|
463 | 477 | }
|
464 | 478 |
|
465 |
| - @Override public void onTimeout(AsyncEvent event) { |
| 479 | + @Override |
| 480 | + public void onTimeout(AsyncEvent event) { |
466 | 481 | subscriptionRef.get().cancel();
|
467 | 482 | }
|
468 | 483 |
|
469 |
| - @Override public void onError(AsyncEvent event) { |
| 484 | + @Override |
| 485 | + public void onError(AsyncEvent event) { |
470 | 486 | subscriptionRef.get().cancel();
|
471 | 487 | }
|
472 | 488 |
|
473 |
| - @Override public void onStartAsync(AsyncEvent event) { |
| 489 | + @Override |
| 490 | + public void onStartAsync(AsyncEvent event) { |
474 | 491 | }
|
475 | 492 | }
|
476 | 493 |
|
|
0 commit comments