Dev Workflow: Hotswap issue: Too many open files

Hi,

I have a new Mac and the project moved to Java 21, and since then I can’t seem to get Hotswap to work.

Both " Debug with Hotswap agent" from the Vaadin plugin and just doing Debug with the hotswap flags set, doesn’t work.

I see that the Vaadin plugin uses Hotswap Agent 2.0.2, while I’ve picked 2.0.1 from the Hotswap Github page and installed it in my JBR libs/hotswap folder as documented.

When I run using Hotswap 2.0.2 (from the Vaadin Intellij plugin) I get

java.nio.file.FileSystemException: /<path-to>/out/production/resources/hotswap-agent.properties: Too many open files

Immediately followed by a bunch of NoClassDefFoundErrors.

To try and fixed this, I played with setting ulimit -n, I also try to add the -XX:-MaxFDLimit flag.
I tried overriding the limit on OS level in different ways (adding ulimit cmd in .zshrc) but also adding a file limit.maxfiles.plist in /Library/LaunchDaemons.

Although ulimit -n returns 65536, I see that my app crashes when it reaches about 12500 open files.

As a side note: on JBR 17 this worked just fine, since migrating to 21 and can’t get around this issue.

When I use Hotswap Agent 2.0.1, I don’t get the " Too Many Files" error. It immediately shows me the ClassDefNotFoundErrors. So I guess 2.0.2 just outputs a bit more logging.

I’ve been messing around with this for 2 days now, and I’m tired of it.
I think by now on my team the Vaadin / Hotswap plugin has cost us more than it has saved.
Is there someone with some experience with this?

Any help is appreciated.

Kind regards,
Kristof.

I remembered seeing this, seems similar : Too many open files exception for jbr-17 · Issue #440 · HotswapProjects/HotswapAgent · GitHub

Good find! If adding -XX:-MaxFDLimit helps then the plugin should add that automatically.

Edit: Although this seems more like an issue with JBR 21 if 17 worked

Hi Jorg and Artur,

The -XX:-MaxFDLimit I already have on my run config. That didn’t do the trick.

I also tried to limit the amount of open files by only watching the package where the UI is sitting, but that did not resolve it. I still see the amount of open file pointers going to 12k plus and then it’s crashing with " too many open files" and ClassDefNotFoundErrors.

I tried other JDK’s as well, like GraalVM and Temurin, but then, in the Vaadin plugin I see “Hotswap enabled partially”. I don’t think it’s really usable. I tried to change a text in a H1, and that didn’t work, so …

I’m currently on 24.8.1 with JBR 21.

Hope I can figure it out soon …
I really don’t want to be the guy that’s asking the team to move back to Java17 :scream:

JetBrainsRuntime is the only JDK that supports proper hotswapping of almost any change in Java code. The other ones are limited to about only changing the code inside a single method.

If you have a test case for this and think its a JBR issue, post an issue to GitHub · Where software is built. The only slightly related I could find was "too many open files" when using java.nio.file.WatchService · Issue #431 · JetBrains/JetBrainsRuntime · GitHub