Skip to content

Improve cleanable proxies by removing any strong reference to the resource.#6109

Merged
vietj merged 1 commit into
masterfrom
cleanable-improvements
May 7, 2026
Merged

Improve cleanable proxies by removing any strong reference to the resource.#6109
vietj merged 1 commit into
masterfrom
cleanable-improvements

Conversation

@vietj

@vietj vietj commented May 7, 2026

Copy link
Copy Markdown
Member

No description provided.

@tsegismont tsegismont left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you @vietj !

…ource.

Motivation:

Cleanable objects (HttpClient and NetClient) still hold a strong reference to the actual client.

Cleanable objects and its cleanable action were still retaining a reference to the actual resource holding it in heap through cleaner reference queue.

During the test suite, many vertx instances and associated resources were held in heap because of the cleaner queue.

Changes:

Cleanable objects now keep a weak reference to the resource instead.
@vietj vietj force-pushed the cleanable-improvements branch from 2e9ffef to 3c5a64c Compare May 7, 2026 10:11
@vietj vietj added this to the 5.1.0 milestone May 7, 2026
@vietj vietj self-assigned this May 7, 2026
@vietj vietj merged commit 7f64333 into master May 7, 2026
7 checks passed
@vietj vietj deleted the cleanable-improvements branch May 7, 2026 13:05
tsegismont added a commit to vert-x3/vertx-dropwizard-metrics that referenced this pull request May 18, 2026
In CI, there was an ISE thrown:

Error:  io.vertx.ext.dropwizard.tests.MetricsTest.testNetMetricsOnClose -- Time elapsed: 0.012 s <<< ERROR!
java.lang.IllegalStateException
	at io.vertx.core@5.1.0-SNAPSHOT/io.vertx.core.impl.CleanableObject.getOrDie(CleanableObject.java:61)
	at io.vertx.core@5.1.0-SNAPSHOT/io.vertx.core.net.impl.tcp.CleanableNetClient.getMetrics(CleanableNetClient.java:89)
	at io.vertx.metrics.dropwizard@5.1.0-SNAPSHOT/io.vertx.ext.dropwizard.impl.AbstractMetrics.unwrap(AbstractMetrics.java:48)
	at io.vertx.metrics.dropwizard@5.1.0-SNAPSHOT/io.vertx.ext.dropwizard.impl.MetricsServiceImpl.getMetricsSnapshot(MetricsServiceImpl.java:32)
	at io.vertx.metrics.dropwizard.tests/io.vertx.ext.dropwizard.tests.MetricsTest.testNetMetricsOnClose(MetricsTest.java:796)

This was due to the changes in eclipse-vertx/vert.x#6109

 In this test, we can use the clientBaseName instead of the client reference. This is functionally equivalent and robust.

Signed-off-by: Thomas Segismont <tsegismont@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants