Skip to content

Add MongoDB 5.x plugin, Jedis 5.x support, fix Spring MVC javax/jakarta detection#803

Merged
wu-sheng merged 5 commits intomainfrom
extend-mongodb-5.x
Apr 9, 2026
Merged

Add MongoDB 5.x plugin, Jedis 5.x support, fix Spring MVC javax/jakarta detection#803
wu-sheng merged 5 commits intomainfrom
extend-mongodb-5.x

Conversation

@wu-sheng
Copy link
Copy Markdown
Member

@wu-sheng wu-sheng commented Apr 9, 2026

Summary

  • Add MongoDB driver 5.x support (new plugin module for 5.2+, extend 4.x for 5.0-5.1)
  • Extend Jedis 4.x plugin to support Jedis 5.x (witness method fix)
  • Fix Spring MVC plugin javax/jakarta servlet detection when both exist on classpath
  • Document package-private class access pattern for plugins

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

  • mongodb-4.x-scenario: 5.0.1, 5.1.4 passed locally
  • mongodb-5.x-scenario: 5.2.0, 5.5.1 passed locally
  • jedis-4.x-scenario: 5.2.0 passed locally
  • Spring MVC: CI verification (needs both javax+jakarta on classpath to reproduce)
  • CI verification

wu-sheng added 3 commits April 9, 2026 15:53
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.
@wu-sheng wu-sheng added bug Something isn't working plugin feature and removed bug Something isn't working labels Apr 9, 2026
@wu-sheng wu-sheng added this to the 9.7.0 milestone Apr 9, 2026
@wu-sheng wu-sheng changed the title Add MongoDB 5.x plugin (5.2-5.5) and extend 4.x to cover 5.0-5.1 Add MongoDB 5.x plugin, extend Jedis 4.x to support 5.x Apr 9, 2026
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.
@wu-sheng wu-sheng force-pushed the extend-mongodb-5.x branch from adeecf1 to 856a656 Compare April 9, 2026 09:39
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.
@wu-sheng wu-sheng changed the title Add MongoDB 5.x plugin, extend Jedis 4.x to support 5.x Add MongoDB 5.x plugin, Jedis 5.x support, fix Spring MVC javax/jakarta detection Apr 9, 2026
@wu-sheng wu-sheng merged commit e8795e9 into main Apr 9, 2026
212 checks passed
@wu-sheng wu-sheng deleted the extend-mongodb-5.x branch April 9, 2026 12:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] support jedis-5.x

2 participants