This is an automated email from the ASF dual-hosted git repository.
chaokunyang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/fury.git
The following commit(s) were added to refs/heads/main by this push:
new 8ce3953f fix(java): fix fury logger log exception (#2153)
8ce3953f is described below
commit 8ce3953f99ceea71b5b21ad9992e00422d72d810
Author: Shawn Yang <[email protected]>
AuthorDate: Fri Apr 18 00:18:05 2025 +0800
fix(java): fix fury logger log exception (#2153)
## What does this PR do?
<!-- Describe the purpose of this PR. -->
## Related issues
Closes #2152
## Does this PR introduce any user-facing change?
<!--
If any user-facing interface changes, please [open an
issue](https://github.com/apache/fury/issues/new/choose) describing the
need to do so and update the document if necessary.
-->
- [ ] Does this PR introduce any public API change?
- [ ] Does this PR introduce any binary protocol compatibility change?
## Benchmark
<!--
When the PR has an impact on performance (if you don't know whether the
PR will have an impact on performance, you can submit the PR first, and
if it will have impact on performance, the code reviewer will explain
it), be sure to attach a benchmark data here.
-->
---
.../src/main/java/org/apache/fury/logging/FuryLogger.java | 11 ++++++++++-
.../test/java/org/apache/fury/logging/Slf4jLoggerTest.java | 2 ++
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git
a/java/fury-core/src/main/java/org/apache/fury/logging/FuryLogger.java
b/java/fury-core/src/main/java/org/apache/fury/logging/FuryLogger.java
index f99b48b8..864d239a 100644
--- a/java/fury-core/src/main/java/org/apache/fury/logging/FuryLogger.java
+++ b/java/fury-core/src/main/java/org/apache/fury/logging/FuryLogger.java
@@ -146,11 +146,20 @@ public class FuryLogger implements Logger {
msg = "null";
}
int len = msg.length();
+ int argLen = args.length;
+ if (argLen > 0 && args[argLen - 1] instanceof Throwable) {
+ argLen -= 1;
+ }
int count = 0;
for (int i = 0; i < len; i++) {
char c = msg.charAt(i);
if (c == '{' && msg.charAt(i + 1) == '}') {
- builder.append(args[count++]);
+ int cnt = count++;
+ if (cnt < argLen) {
+ builder.append(args[cnt]);
+ } else {
+ builder.append("{}");
+ }
i++;
} else {
builder.append(c);
diff --git
a/java/fury-core/src/test/java/org/apache/fury/logging/Slf4jLoggerTest.java
b/java/fury-core/src/test/java/org/apache/fury/logging/Slf4jLoggerTest.java
index 32c0d916..61d43cc2 100644
--- a/java/fury-core/src/test/java/org/apache/fury/logging/Slf4jLoggerTest.java
+++ b/java/fury-core/src/test/java/org/apache/fury/logging/Slf4jLoggerTest.java
@@ -31,10 +31,12 @@ public class Slf4jLoggerTest {
logger.info("testInfo {}", "placeHolder");
logger.warn("testInfo {}", "placeHolder");
logger.error("testInfo {}", "placeHolder", new Exception("test log"));
+ logger.error("testInfo {}", "placeHolder", new Exception("test log"));
furyLogger.info("testInfo");
furyLogger.info("testInfo {}", "placeHolder");
furyLogger.warn("testInfo {}", "placeHolder");
furyLogger.error("testInfo {}", "placeHolder", new Exception("test log"));
furyLogger.error(null, new Exception("test log"));
+ furyLogger.error("test log {} {}", new Exception("test log {} {}"));
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]