Skip to content

feat: add per-connection attachment storage to HttpConnectionInternal - #6235

Open
Harshal96 wants to merge 4 commits into
eclipse-vertx:masterfrom
Harshal96:http-connection-local-storage
Open

feat: add per-connection attachment storage to HttpConnectionInternal#6235
Harshal96 wants to merge 4 commits into
eclipse-vertx:masterfrom
Harshal96:http-connection-local-storage

Conversation

@Harshal96

Copy link
Copy Markdown
Contributor

Motivation:

vert-x3/vertx-web#2910 needs per-connection state (announced Alt-Svc origins) scoped to the connection's lifecycle. The current workaround in vertx-web is a WeakHashMap<HttpConnection, T>, which can't reliably clean up stale connections (see discussion in that PR).

Changes

New HttpConnectionInternal interface in io.vertx.core.internal.http, following the existing HttpServerRequestInternal / HttpClientRequestInternal pattern:

<T> T get(Object key);
void set(Object key, Object value);

Backed by a lazily-created map stored directly on the connection object (not an external map keyed by connection), so entries are naturally scoped to the connection's own lifecycle — no leak risk, no weak references needed.

Wired into all four connection implementations:
ConnectionBase (shared by Http1Connection, Http2ConnectionImpl, Http2MultiplexConnection), cleared in handleClosed(). Http3Connection, which doesn't extend ConnectionBase, gets its own field and clears it in its own handleClosed().

Fixes #6234

@Harshal96

Copy link
Copy Markdown
Contributor Author

@vietj something like this?

Comment thread vertx-core/src/main/java/io/vertx/core/internal/http/HttpConnectionInternal.java Outdated
Comment thread vertx-core/src/main/java/io/vertx/core/internal/http/HttpConnectionInternal.java Outdated
@vietj vietj added this to the 5.2.0 milestone Jul 15, 2026
Comment thread vertx-core/src/main/java/io/vertx/core/net/impl/ConnectionBase.java Outdated
@vietj

vietj commented Jul 20, 2026

Copy link
Copy Markdown
Member

ping @Harshal96

@vietj
vietj force-pushed the http-connection-local-storage branch from 5a4d59b to 38ba1f3 Compare July 27, 2026 10:13

@vietj vietj 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.

Can you instead of using a map with synchronization around instead use a ConcurrentHashMap implementation ?

@Harshal96

Copy link
Copy Markdown
Contributor Author

@vietj done

@vietj
vietj force-pushed the http-connection-local-storage branch from 743f6e6 to 73c8713 Compare July 28, 2026 09:39
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