KTOR-646 Log client-disconnect IOException at TRACE in Netty HTTP/1 handler#5563
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughIOException handling in the Netty HTTP/1 handler now logs at TRACE (not DEBUG). A new unit test asserts a single TRACE-level "I/O operation failed" log is emitted for a client-disconnect IOException using an EmbeddedChannel and Logback ListAppender. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
ktor-server/ktor-server-netty/jvm/test/io/ktor/tests/server/netty/NettySpecificTest.kt (1)
210-226: Optional: remove redundant appender detachment.
logger.detachAppender(listAppender)runs both before assertions (Line 210) and again infinally(Line 225). Keeping it only infinallysimplifies cleanup without changing behavior.♻️ Suggested simplification
try { channel.pipeline().fireExceptionCaught(IOException("Connection reset by peer")) - - logger.detachAppender(listAppender) val ioOpFailedEvents = listAppender.list.filter { it.formattedMessage == "I/O operation failed" } assertEquals( 1, ioOpFailedEvents.size, @@ } finally { logger.detachAppender(listAppender) logger.level = previousLevel channel.finishAndReleaseAll() }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@ktor-server/ktor-server-netty/jvm/test/io/ktor/tests/server/netty/NettySpecificTest.kt` around lines 210 - 226, The test currently calls logger.detachAppender(listAppender) twice (once before the assertions and again in the finally block); remove the earlier redundant call and keep only the cleanup in the finally block so the appender is always detached and cleanup is centralized—update the block around the ioOpFailedEvents assertions to stop calling logger.detachAppender(listAppender) before assertions and rely on the existing finally that restores logger.level and detaches the appender.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In
`@ktor-server/ktor-server-netty/jvm/test/io/ktor/tests/server/netty/NettySpecificTest.kt`:
- Around line 210-226: The test currently calls
logger.detachAppender(listAppender) twice (once before the assertions and again
in the finally block); remove the earlier redundant call and keep only the
cleanup in the finally block so the appender is always detached and cleanup is
centralized—update the block around the ioOpFailedEvents assertions to stop
calling logger.detachAppender(listAppender) before assertions and rely on the
existing finally that restores logger.level and detaches the appender.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 548cf7fe-8a06-4e1d-9f6f-89aba19033ae
📒 Files selected for processing (2)
ktor-server/ktor-server-netty/jvm/src/io/ktor/server/netty/http1/NettyHttp1Handler.ktktor-server/ktor-server-netty/jvm/test/io/ktor/tests/server/netty/NettySpecificTest.kt
bjhham
left a comment
There was a problem hiding this comment.
Thanks for the fix. One small comment wrt naming
| } | ||
|
|
||
| @Test | ||
| fun `KTOR-646 client-disconnect IOException is logged at TRACE not DEBUG`() { |
There was a problem hiding this comment.
Best to simplify the test name here to describe the high-level behavior like client disconnect is logged and leave the level as an implementation detail. We generally avoid referencing YouTrack issue numbers in fixes too.
|
Thanks for the review! Addressed both points in d616231:
|
Subsystem
Server, Netty
Motivation
KTOR-646 / #1030 —
NettyHttp1Handler.exceptionCaughtlogs everyIOExceptionat DEBUG, so routine client disconnects ("Connection reset by peer") show up as noise in default DEBUG logs.Solution
Lower the log level to TRACE. Information stays available for deep debugging without polluting DEBUG output.