Add MongoDB 5.x plugin, Jedis 5.x support, fix Spring MVC javax/jakarta detection#803
Merged
Add MongoDB 5.x plugin, Jedis 5.x support, fix Spring MVC javax/jakarta detection#803
Conversation
MongoDB 5.2+ replaced MongoClientDelegate with package-private MongoClusterImpl. New mongodb-5.x-plugin module with: - MongoClusterImplInstrumentation: intercept constructor (Cluster at arg[1]) and getOperationExecutor() to propagate remotePeer - MongoClusterOperationExecutorInstrumentation: intercept inner class OperationExecutorImpl constructor (enclosing instance at synthetic arg[0]) and execute() methods (reuses 4.x MongoDBOperationExecutorInterceptor) Key challenge: OperationExecutorImpl is created inside MongoClusterImpl's constructor before onConstruct fires. Solved by calling getOperationExecutor() via setAccessible reflection in onConstruct to set peer on the stored executor. TODO: Add @InternalAccessor annotation to core framework to allow plugin helper classes in target library packages, bypassing checkstyle package rules. Locally verified: 5.0.1, 5.1.4 (4.x plugin), 5.2.0, 5.5.1 (5.x plugin) all passed.
MongoDB 5.2+ replaced MongoClientDelegate with package-private MongoClusterImpl. New mongodb-5.x-plugin module with: - MongoClusterImplInstrumentation: intercept constructor (Cluster at arg[1]) and getOperationExecutor() to propagate remotePeer - MongoClusterOperationExecutorInstrumentation: intercept inner class OperationExecutorImpl constructor and execute() methods Key challenge: OperationExecutorImpl is created inside MongoClusterImpl's constructor before onConstruct fires. Solved by calling getOperationExecutor() via setAccessible reflection in onConstruct. Note: Same-package helper classes (@InternalAccessor approach) do NOT work because agent and application use different classloaders — Java treats them as different runtime packages even with identical package names. Locally verified: 5.0.1, 5.1.4 (4.x plugin), 5.2.0, 5.5.1 (5.x plugin) all passed.
3 tasks
Jedis 5.x is API-compatible with 4.x (all intercepted classes and methods unchanged). The only blocker was the witness method: Pipeline.persist(1 arg) was no longer declared on Pipeline in 5.x (moved to PipeliningBase parent). Fix: change witness to Connection.executeCommand(1 arg) which is declared in both 4.x and 5.x but not in 3.x, correctly distinguishing the versions. Resolves apache/skywalking#11747 Locally verified: Jedis 5.2.0 passed.
adeecf1 to
856a656
Compare
When both javax.servlet and jakarta.servlet exist on the classpath
(e.g., Spring MVC 6.x app with javax.servlet as transitive dependency),
the exclusive if/else in the static initializer set IS_JAVAX=true and
skipped the Jakarta check. At runtime, the request was jakarta type but
IS_JAKARTA was false, causing IllegalStateException("this line should
not be reached").
Fix: check both servlet APIs independently. Both IS_JAVAX and IS_JAKARTA
can be true. The runtime isAssignableFrom checks on the actual request
object type already select the correct branch.
kezhenxu94
approved these changes
Apr 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
MongoDB 5.0-5.1 (4.x plugin extended)
Added versions to support-version.list. Same MongoClientDelegate API.
MongoDB 5.2+ (new mongodb-5.x-plugin module)
MongoClusterImpl replaces MongoClientDelegate. New interceptors with remotePeer propagation via setAccessible reflection (MongoClusterImpl is package-private).
Jedis 5.x (4.x plugin witness fix)
All intercepted classes unchanged in 5.x. Plugin was silently not activating because witness Pipeline.persist(1 arg) moved to parent PipeliningBase. Changed witness to Connection.executeCommand(1 arg).
Resolves apache/skywalking#11747
Spring MVC javax/jakarta fix
When both javax.servlet and jakarta.servlet exist on classpath, the exclusive if/else set IS_JAVAX=true and skipped Jakarta check. Fix: check both independently.
Ref: apache/skywalking#13425
Test plan