quarkus icon indicating copy to clipboard operation
quarkus copied to clipboard

Use the new Vertx local context storage

Open franz1981 opened this issue 2 months ago • 5 comments

This is to keep up with the Vertx API changes for https://github.com/eclipse-vertx/vert.x/commit/88cf77bfe4f44c3dc5ee89d65b8891674088de46, although I'm not very happy with the current state (that's why is in draft):

  1. VertxLocalsHelper. is "stealthy" using the new API by intercepting when users are passing ContextLocal-like keys, which means performing 2 instanceof checks (one being an interface check too, which is not yet safe with JDK till 21...)
  2. As written in the TODO parts, we have some ordering issue: we need the keys statically defined as ACCESS_TOGGLE_KEY to be initialized before instantiating the Vertx instance has to use them, due to https://github.com/eclipse-vertx/vert.x/blob/4.5.7/src/main/java/io/vertx/core/impl/VertxImpl.java#L194 which is forcing every new context creation to dedicate the fixed amount of "optimized" keys in the context's local storage
  3. The new AccessMode I've defined is good enough that having a new method in AccessMode::putRelease, would have been better IMO (@vietj )

For @mkouba and @Ladicek : the new "optimized" API for local storage is double edge sword because it needs some care on init ordering, need some care in dev mode (I think, @geoand ? @sanne ?) and requires to create local "permanent" keys only for the ones we're 100% are going to be stored on each context (and I need some help from @Ladicek and @mkouba for such, I have no IDEA!)

Additionally there are some weird things in the original API (but is ok, the purpose of dog fooding is indeed to try things and found how to use them!): @vietj see https://github.com/quarkusio/quarkus/compare/main...franz1981:quarkus:local_ctx?expand=1#diff-af571e338cf42e877b9b99b70840f0842b293365f18c24d5fb24c930e5b0b064R64: this one is just wrong, because we cannot query all the local storage ContextLocal's values stored in the source context...we cannot do it unless we have a new method as ContextInternal::addLocals(ContextInternal from, AccessMode accessMode)

franz1981 avatar May 20 '24 16:05 franz1981