diff --git a/src/commonMain/kotlin/io/modelcontextprotocol/kotlin/sdk/shared/ReadBuffer.kt b/src/commonMain/kotlin/io/modelcontextprotocol/kotlin/sdk/shared/ReadBuffer.kt index 639f5bea..c901ed28 100644 --- a/src/commonMain/kotlin/io/modelcontextprotocol/kotlin/sdk/shared/ReadBuffer.kt +++ b/src/commonMain/kotlin/io/modelcontextprotocol/kotlin/sdk/shared/ReadBuffer.kt @@ -24,7 +24,7 @@ public class ReadBuffer { -1L -> return null 0L -> { buffer.skip(1) - "" + return null } else -> { diff --git a/src/jvmTest/kotlin/shared/ReadBufferTest.kt b/src/jvmTest/kotlin/shared/ReadBufferTest.kt index 23dcd3fb..850e2efb 100644 --- a/src/jvmTest/kotlin/shared/ReadBufferTest.kt +++ b/src/jvmTest/kotlin/shared/ReadBufferTest.kt @@ -41,6 +41,13 @@ class ReadBufferTest { assertNull(readBuffer.readMessage()) } + @Test + fun `skip empty line`() { + val readBuffer = ReadBuffer() + readBuffer.append("\n".toByteArray(StandardCharsets.UTF_8)) + assertNull(readBuffer.readMessage()) + } + @Test fun `should be reusable after clearing`() { val readBuffer = ReadBuffer()