clj-commons / clj-commons/aleph
KQueue class loading issues with netty 4.2.2.Final
Nobody has claimed this yet.
- Dominant language
- Clojure
- Stars
- 2.6k
- Forks
- 242
- Avg merge
- 4d 5h
- Merged PRs (30d)
- 1
Description
I realize the aleph repo isn't officially using 4.2.x yet, but aleph works perfectly for our use cases on 4.2.1.Final at least so figured it'd be helpful to report this issue here.
With 4.2.2.Final, building uberjars on Linux systems throws errors like this:
```
Syntax error macroexpanding def at (netty.clj:1326:1).
Execution error (IllegalStateException) at io.netty.channel.kqueue.Native/loadNativeLibrary (Native.java:150).
Only supported on OSX/BSD
```
Looks like the issue is that these functions force KQueue classes to be loaded at build time:
https://github.com/clj-commons/aleph/blob/bb3a1f1a10acb50ff68b87185f04d3f5cd2eccc4/src/aleph/netty.clj#L1327-L1332
https://github.com/clj-commons/aleph/blob/bb3a1f1a10acb50ff68b87185f04d3f5cd2eccc4/src/aleph/netty.clj#L1398-L1410
This starts failing on 4.2.2.Final because that version added some new static fields to `AbstractKQueueChannel` that force `io.netty.channel.kqueue.Native` to be loaded here, even on non-OSX systems.
I've reported the root cause upstream in https://github.com/netty/netty/issues/15392 already since this seems like a netty regression (and they've fixed similar issues in the past).
While I wait on a response from the netty maintainers, would the maintainers here be open to a PR to guard against issues like this?
I've worked around this locally by replacing the class names in the functions above with calls like `(eval 'io.netty.channel.kqueue.KQueueServerSocketChannel)` to ensure that the classes aren't loaded until they're actually needed, but wasn't sure on the right approach to adding a test here since this issue doesn't show up in the netty version currently set in `project.clj`.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/aleph/netty.clj at the referenced lines 1327-1332 and 1398-1410, then check the Netty version in project.clj. Reproduce the uberjar build on Linux with Netty 4.2.2.Final and determine how to defer KQueue class loading. Done means the build no longer triggers Native/loadNativeLibrary on non-OSX systems, with a regression test if the existing test setup supports it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- clojure
- Domain
- backend, build-system, networking
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100