hi all, I've came across this issue with the serve...
# ktor
v
hi all, I've came across this issue with the server I have, and I get an exception about
ClosedWatchServiceException
, when running multiple tests all together. I'm using ktor:
1.5.2
, and having a
jetty
server. The issue is thrown when the server is restarted in following tests. here's a code snippet to exemplify the error:
Copy code
class StartStopServerTest : FreeSpec({  
    "server" - {
        val server = embeddedServer(
            factory = Jetty,
            port = 8080,
            module = {}
        )

        "start" {
            server.start()
        }

        "stop" {
            server.stop(1000, 1000)
        }

        "restart" {
            server.start()  // this fails with the error as shown in the picture
        }

        "stop again" {
            server.stop(1000, 1000)
        }
    }
})
Did anybody face this as well? Appreciate any suggestions and help, thank you 🙏
found a solution: this will work if I'll use different server instances
so here's an example:
Copy code
"scratch server" - {
        var server = server() // instantiate

        "start" {
            server.start()
        }

        "stop" {
            server.stop(10000, 10000)
        }

        "restart" {
            server = server() // new instance
            server.start()
        }

        "stop again" {
            server.stop(1000, 1000)
        }
    }

fun server() =
    embeddedServer(
        factory = Jetty,
        port = 8080,
        module = {}
    )