You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gravitino.apache.org by "LuciferYang (via GitHub)" <gi...@apache.org> on 2026/08/17 05:43:21 UTC

[I] [Improvement] Make CallerContext an immutable value object [gravitino]

LuciferYang opened a new issue, #12475:
URL: https://github.com/apache/gravitino/issues/12475

   ### What would you like to be improved?
   
   `CallerContext` (`common/.../audit/CallerContext.java`) is an audit/credential context published into a `ThreadLocal` and read across modules (server fileset/credential ops, `FilesetEventDispatcher`, GVFS clients). Its Javadoc says it is forked from Hadoop's `org.apache.hadoop.ipc.CallerContext`, which is fully immutable — but the Gravitino copy has lost that immutability:
   
   - `withContext(Map)` stores the caller's map by reference and `context()` returns it directly, so a caller's later mutation, or a reader calling `put`/`remove` on `context()`, can silently alter an already-published context.
   - The `context` field is non-final and the `Builder` mutates a pre-built instance, so a retained `Builder` can change an instance already handed out / stored in the `ThreadLocal`.
   
   No live bug today (all call sites pass fresh maps and only read), but it is a latent footgun on a shared, security-sensitive value object and diverges from the immutable design it claims to mirror.
   
   ### How should we improve?
   
   Store a defensive unmodifiable copy in `withContext`, and make the `context` field `final` with constructor injection so `build()` returns a distinct, truly immutable instance. Keep the public API signatures unchanged (`context()` would return an unmodifiable map).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Improvement] Make CallerContext an immutable value object [gravitino]

Posted by "yuqi1129 (via GitHub)" <gi...@apache.org>.
yuqi1129 closed issue #12475: [Improvement] Make CallerContext an immutable value object
URL: https://github.com/apache/gravitino/issues/12475


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org