java

Linus Ericsson 2021-10-15T13:59:46.001100Z

Is it possible to do any network stack introspection in java? like getting the Socket-object using a certain port inside the JVM?

2021-10-19T14:06:34.013500Z

*1 *2 and *3 are also your friends if you forget to hold it somewhere; but only if you remember to bind it or close it before you’ve entered 3 things in your REPL 🙂

Linus Ericsson 2021-10-19T14:07:32.013800Z

I would just want to have the ability to go somewhere in jetty and kill everything. Or just interrupt the thread from the JVM or something similar.

2021-10-19T14:10:49.014Z

you may be able to find something in jetty, if it holds things in a static variable or something… However it’s also a general problem, so better solved with general solutions. FWIW you’ll rarely lose the reference if you use a component system; something like integrant with its repl tools etc.

jumar 2021-10-19T14:57:41.018900Z

You can list all the threads and try to find the right one and interrupt it. You can also use advanced stuff like hotspot serviceability agent and do all sorts of crazy stuff but you don’t want that. I’d really question your project/workflow setup - once I got it right I’ve never had such problem or it was very rare and I could just restart the repl

jumar 2021-10-16T15:12:30.001800Z

What problem are you trying to solve?

Linus Ericsson 2021-10-16T15:23:19.003200Z

I just dropped a running Jetty server and had to restart the jvm for the nth time.

jumar 2021-10-16T15:36:50.004500Z

So to make Jetty stop listening on the port you have to restart the process?

Linus Ericsson 2021-10-16T15:37:28.005600Z

Yes, i drop the thread (running in the repl/development)

jumar 2021-10-16T15:37:54.006200Z

What you mean by “drop”?

Linus Ericsson 2021-10-16T15:38:40.007900Z

I start the server, then i loose the reference to the running server, cannot stop it and it blocks the port.

jumar 2021-10-16T15:39:12.008800Z

Ah, so you should then save the reference in a var.

Linus Ericsson 2021-10-16T15:40:13.010200Z

Yes. But the problem is that it easy to reload the namespace or similar and drop the server anyway. Defonce doesnt always work either.

jumar 2021-10-16T15:42:16.011200Z

When defonce doesn’t work? Tools.refresh?

jumar 2021-10-16T15:44:04.012600Z

If you are just playing around you can save the reference inside a comment block.