vert.x icon indicating copy to clipboard operation
vert.x copied to clipboard

Quarkus needs the ability to change the ClassLoader

Open stuartwdouglas opened this issue 2 years ago • 3 comments

Describe the feature

Quarkus Development mode works by dropping and re-creating a class loader every time code is changed. As this is triggered by a HTTP request vert.x is not restarted each time, so the HTTP requests work as expected.

This is causing issues such as https://github.com/quarkusio/quarkus/issues/18299 where vert.x is hanging onto the original ClassLoader that was passed in at creation time. With Vert.x 3 we worked around this by manually scheduling a task on each IO thread that updated the Thread context ClassLoader, however this no longer works in Vert.x 4, as Vert.x is resetting the CL each time.

For now we are likely going to work around it via vertx.disableTCCL=true and filtering out the resulting warnings.

In terms of implementation I was thinking maybe instead of Vert.x taking a ClassLoader it could take a Supplier<ClassLoader>, and this could be use to obtain the correct TCCL each time.

Contribution

I can implement it if there is consensus on what it should look like.

stuartwdouglas avatar Jul 20 '21 23:07 stuartwdouglas

I am assuming this is the class loader hold by the Context that is used to be set as TCCL ?

vietj avatar Jul 21 '21 06:07 vietj

Yes, although ideally this will apply everywhere so that the original CL does not leak.

stuartwdouglas avatar Jul 21 '21 06:07 stuartwdouglas

would the ability to disable the TCCL with a flag in VertxOptions work (instead of using a system property) ?

vietj avatar Jul 22 '21 09:07 vietj