arextest / arextest/arex-agent-java
[Bug] 请求mocker保存报错:“send mock data unhandled error”
- Dominant language
- Java
- Stars
- 564
- Forks
- 140
- Avg merge
- 36m
- Merged PRs (30d)
- 2
Description
### Search before asking
- [X] I have searched the existing [issues](https://github.com/arextest/arex-agent-java/issues) before asking.
### AREX Test Service
AREX Java Agent (arextest/arex-agent-java)
### Current Behavior
报错截图如下
日志信息
```log
2024-07-11 21:43:28:558 [arex-data-save-handler-4-thread-1] WARN io.arex.inst.runtime.log.LogManager - [[title=arex.saveDataLoop]]send mock data unhandled error: Cannot invoke "String.getBytes(java.nio.charset.Charset)" because "original" is null
2024-07-11 21:43:28:558 [arex-data-save-handler-4-thread-1] WARN io.arex.inst.runtime.log.LogManager - [[title=arex.saveDataLoop]]send mock data unhandled error: Cannot invoke "String.getBytes(java.nio.charset.Charset)" because "original" is null
```
问题排查:defaultSerializer 为空导致,debug跟踪代码发现 ServiceLoader 只加载了两个serializer,不包含 `io.arex.foundation.serializer.jackson.JacksonSerializer#JacksonSerializer`;后续在保存 mocker 时,由于 defaultSerializer 为空导致程序执行异常,后续录制的mocker无法保存
**截图中的 classLoader 是 appClassLoader,如果是 spring 程序的话,是 tomcat loader,不会有问题**
### Expected Behavior
一般的场景:tomcat loader 加载时,会包含 `io.arex.foundation.serializer.jackson.JacksonSerializer#JacksonSerializer`
### Steps To Reproduce
非 tomcate 程序:如下截图的的 xxl 实例程序(jdk17):
复现:
1、构建 arex agent,用jdk17
2、指定 agent 挂载参数启动 `xxl-job-executor-sample-frameless`
3、下发一个调度请求到 `xxl-job-executor-sample-frameless` 程序(开始录制)
4、接着会看到报错日志:
### Anything else
_No response_
### Are you willing to submit a pull request to fix on your own?
- [ ] Yes I am willing to submit a pull request on my own!
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by tracing the ServiceLoader setup for defaultSerializer and the loading of io.arex.foundation.serializer.jackson.JacksonSerializer in the mock-save path. Reproduce with the JDK 17 xxl-job-executor-sample-frameless program and the agent attached, then verify that a non-Tomcat application loads the serializer and saves recorded mock data without the unhandled error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- devtools, testing-qa
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100