scala-kit icon indicating copy to clipboard operation
scala-kit copied to clipboard

Application won't close after Api.get

Open zipon opened this issue 9 years ago • 5 comments

Hi

When running sbt run the main method does not exit after api.get(...).onComplete() but instead hangs. It seems some thread is still active and not cleaned up. I don't see this behaviour in the Java kit.

zipon avatar Jan 22 '16 14:01 zipon

The Java kit is a completely different code base, so it's not really surprising.

Could you give me some code snippet where you can consistently reproduce the problem?

erwan avatar Jan 22 '16 14:01 erwan

Here is an example https://gist.github.com/zipon/224455e586acbc205419

zipon avatar Jan 22 '16 14:01 zipon

I see, it's probably in the HttpClient:

https://github.com/prismicio/scala-kit/blob/master/src/main/scala/io/prismic/HttpClient.scala

erwan avatar Jan 22 '16 15:01 erwan

Looks like you're not closing the channels?

When googling I came across the following: channel.write( ... ).addListener(ChannelFutureListener.CLOSE)

magnusart avatar Jan 22 '16 15:01 magnusart

I think ctx.close() is supposed to do it but maybe I'm wrong

erwan avatar Jan 22 '16 16:01 erwan