typelevel / typelevel/fs2

fs2-io is not closing ports when a DatagramChannel is used

Open
#3,762 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Scala
Stars
2.5k
Forks
636
Avg merge
2d 4h
Merged PRs (30d)
7

Description

On fs2 3.13.0. I was testing usage of DatagramChannel with some code of mine in an integration test and noted that subsequent tests/suites would fail with the error java.net.BindException: Address already in use.

Attached is a minimal test case that shows the failure. It's not sufficient to merely create the DatagramChannel, it has to be used in a read/write. I believe the Selector registration may be at fault, it may not be being closed:

https://stackoverflow.com/questions/12977164/datagramchannel-close-keeps-port-open-on-windows

https://scastie.scala-lang.org/GD6QuczvSRitJaMBrLyZPw

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the minimal DatagramChannel test case linked in the issue, especially the read/write path that leaves the port bound. Trace fs2-io's DatagramChannel handling and Selector registration through close, then verify that repeated tests or suites can bind the same port after the channel is closed.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, scala
Domain
networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.