|
84 | 84 | import io.netty.handler.codec.http2.Http2Stream; |
85 | 85 | import io.netty.util.AsciiString; |
86 | 86 | import java.io.InputStream; |
| 87 | +import java.text.MessageFormat; |
87 | 88 | import java.util.LinkedList; |
88 | 89 | import java.util.List; |
89 | 90 | import java.util.Queue; |
90 | 91 | import java.util.concurrent.atomic.AtomicBoolean; |
| 92 | +import java.util.concurrent.atomic.AtomicReference; |
| 93 | +import java.util.logging.Handler; |
| 94 | +import java.util.logging.LogRecord; |
| 95 | +import java.util.logging.Logger; |
| 96 | +import java.util.logging.SimpleFormatter; |
| 97 | + |
91 | 98 | import org.junit.Before; |
92 | 99 | import org.junit.Rule; |
93 | 100 | import org.junit.Test; |
@@ -459,6 +466,37 @@ public void run() { |
459 | 466 | assertTrue(b.get()); |
460 | 467 | } |
461 | 468 |
|
| 469 | + @Test |
| 470 | + public void receivedGoAway_enhanceYourCalmShouldLogDebugData() throws Exception { |
| 471 | + final AtomicReference<LogRecord> logRef = new AtomicReference<>(); |
| 472 | + Handler handler = new Handler() { |
| 473 | + @Override |
| 474 | + public void publish(LogRecord record) { |
| 475 | + logRef.set(record); |
| 476 | + } |
| 477 | + |
| 478 | + @Override |
| 479 | + public void flush() { |
| 480 | + } |
| 481 | + |
| 482 | + @Override |
| 483 | + public void close() throws SecurityException { |
| 484 | + } |
| 485 | + }; |
| 486 | + Logger logger = Logger.getLogger(NettyClientHandler.class.getName()); |
| 487 | + try { |
| 488 | + logger.addHandler(handler); |
| 489 | + enqueue(newCreateStreamCommand(grpcHeaders, streamTransportState)); |
| 490 | + channelRead(goAwayFrame(0, 11 /* Enhance your calm */, |
| 491 | + Unpooled.copiedBuffer("this is a test", UTF_8))); |
| 492 | + assertNotNull(logRef); |
| 493 | + assertTrue(MessageFormat.format(logRef.get().getMessage(), logRef.get().getParameters()) |
| 494 | + .contains("Debug data: this is a test")); |
| 495 | + } finally { |
| 496 | + logger.removeHandler(handler); |
| 497 | + } |
| 498 | + } |
| 499 | + |
462 | 500 | @Test |
463 | 501 | public void cancelStreamShouldCreateAndThenFailBufferedStream() throws Exception { |
464 | 502 | receiveMaxConcurrentStreams(0); |
|
0 commit comments