From 90f8f5c4ab704dfa9a3d3b9a6a4d8540c4c08845 Mon Sep 17 00:00:00 2001 From: "Ross A. Baker" Date: Wed, 25 Jan 2023 00:50:10 -0500 Subject: [PATCH] Expose bug with parallel dispatcher --- .../scala/org/http4s/servlet/ServletIoSuite.scala | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/servlet/src/test/scala/org/http4s/servlet/ServletIoSuite.scala b/servlet/src/test/scala/org/http4s/servlet/ServletIoSuite.scala index 462489c1..51a6a699 100644 --- a/servlet/src/test/scala/org/http4s/servlet/ServletIoSuite.scala +++ b/servlet/src/test/scala/org/http4s/servlet/ServletIoSuite.scala @@ -18,6 +18,7 @@ package org.http4s package servlet import cats.effect.IO +import cats.effect.std.Dispatcher import munit.CatsEffectSuite import java.io.ByteArrayInputStream @@ -33,8 +34,10 @@ class ServletIoSuite extends CatsEffectSuite { HttpServletRequestStub(inputStream = new TestServletInputStream("test".getBytes(UTF_8))) val io = NonBlockingServletIo[IO](10) - val body = io.reader(request) - body.compile.toList.map(bytes => new String(bytes.toArray, UTF_8)).assertEquals("test") + Dispatcher.parallel[IO].use { dispatcher => + val body = io.requestBody(request, dispatcher) + body.compile.to(Array).map(bytes => new String(bytes, UTF_8)).assertEquals("test") + } } test( @@ -45,8 +48,10 @@ class ServletIoSuite extends CatsEffectSuite { ) val io = NonBlockingServletIo[IO](10) - val body = io.reader(request) - body.compile.toList.map(bytes => new String(bytes.toArray, UTF_8)).assertEquals("testtesttest") + Dispatcher.parallel[IO].use { dispatcher => + val body = io.requestBody(request, dispatcher) + body.compile.to(Array).map(bytes => new String(bytes, UTF_8)).assertEquals("testtesttest") + } } class TestServletInputStream(body: Array[Byte]) extends ServletInputStream {