Skip to content

Commit dc5c155

Browse files
authored
Skip empty lines (#89)
1 parent 9b5c69f commit dc5c155

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/commonMain/kotlin/io/modelcontextprotocol/kotlin/sdk/shared/ReadBuffer.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public class ReadBuffer {
2424
-1L -> return null
2525
0L -> {
2626
buffer.skip(1)
27-
""
27+
return null
2828
}
2929

3030
else -> {

src/jvmTest/kotlin/shared/ReadBufferTest.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ class ReadBufferTest {
4141
assertNull(readBuffer.readMessage())
4242
}
4343

44+
@Test
45+
fun `skip empty line`() {
46+
val readBuffer = ReadBuffer()
47+
readBuffer.append("\n".toByteArray(StandardCharsets.UTF_8))
48+
assertNull(readBuffer.readMessage())
49+
}
50+
4451
@Test
4552
fun `should be reusable after clearing`() {
4653
val readBuffer = ReadBuffer()

0 commit comments

Comments
 (0)