This is an automated email from the ASF dual-hosted git repository.
pandalee pushed a commit to branch releases-0.11
in repository https://gitbox.apache.org/repos/asf/fury.git
The following commit(s) were added to refs/heads/releases-0.11 by this push:
new 97f9ab22 fix(java): Fix logger error (#2154)
97f9ab22 is described below
commit 97f9ab2240b1f9f7f8bb3c2dfec223e5270559f5
Author: Shawn Yang <[email protected]>
AuthorDate: Sat Apr 19 07:44:54 2025 +0800
fix(java): Fix logger error (#2154)
## 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.
-->
<!--
**Thanks for contributing to Fury.**
**If this is your first time opening a PR on fury, you can refer to
[CONTRIBUTING.md](https://github.com/apache/fury/blob/main/CONTRIBUTING.md).**
Contribution Checklist
- The **Apache Fury (incubating)** community has restrictions on the
naming of pr titles. You can also find instructions in
[CONTRIBUTING.md](https://github.com/apache/fury/blob/main/CONTRIBUTING.md).
- Fury has a strong focus on performance. If the PR you submit will have
an impact on performance, please benchmark it first and provide the
benchmark result here.
-->
## What does this PR do?
<!-- Describe the purpose of this PR. -->
## Related issues
<!--
Is there any related issue? Please attach here.
- #xxxx0
- #xxxx1
- #xxxx2
-->
## 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.
-->
---
.github/workflows/ci.yml | 2 +-
.../src/main/java/org/apache/fury/logging/FuryLogger.java | 11 ++++++++++-
.../test/java/org/apache/fury/logging/Slf4jLoggerTest.java | 2 ++
3 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index d4e6b6b3..c1238531 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -240,7 +240,7 @@ jobs:
strategy:
matrix:
python-version: [3.8, 3.12, 3.13]
- os: [ubuntu-20.04, macos-13, macos-14, windows-2022]
+ os: [ubuntu-latest, macos-13, macos-14, windows-2022]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
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]