Search before asking
Apache SkyWalking Component
Java Agent (apache/skywalking-java)
What happened
The replaceParam method of AbstractLogger behaves unexpectedly when the replaced string contains a replacement marker.
What you expected to happen
log.info("sample rule update: {} -> {}", "Config{a={}}", "Config{b={}}")
expect: sample rule update: Config{a={}} -> Config{b={}}
but actual: sample rule update: Config{a=Config{b={}}} -> {}
How to reproduce
just run code above
Anything else
https://github.com/apache/skywalking-java/blob/67ab8b222fbb9a71b450665eb9f733380d813b8a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/logging/core/AbstractLogger.java#L185-L203
tmpMessage = tmpMessage.replaceFirst("\\{\\}", Matcher.quoteReplacement(String.valueOf(parameters[parametersIndex++])));
startSize = index + 2;
The index should not just increase by 2, but should increase by the length of the string to be replaced.
Are you willing to submit a pull request to fix on your own?
Code of Conduct