From 9cc78f2daa0eef099de183621dc2c01788b71ff1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 Sep 2025 16:41:15 +0000 Subject: [PATCH 1/2] Bump spotbugs.version from 4.9.3 to 4.9.5 Bumps `spotbugs.version` from 4.9.3 to 4.9.5. Updates `com.github.spotbugs:spotbugs-annotations` from 4.9.3 to 4.9.5 - [Release notes](https://github.com/spotbugs/spotbugs/releases) - [Changelog](https://github.com/spotbugs/spotbugs/blob/master/CHANGELOG.md) - [Commits](https://github.com/spotbugs/spotbugs/compare/4.9.3...4.9.5) Updates `com.github.spotbugs:spotbugs` from 4.9.3 to 4.9.5 - [Release notes](https://github.com/spotbugs/spotbugs/releases) - [Changelog](https://github.com/spotbugs/spotbugs/blob/master/CHANGELOG.md) - [Commits](https://github.com/spotbugs/spotbugs/compare/4.9.3...4.9.5) --- updated-dependencies: - dependency-name: com.github.spotbugs:spotbugs-annotations dependency-version: 4.9.5 dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: com.github.spotbugs:spotbugs dependency-version: 4.9.5 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ab6c1fc8..8785bf2f 100644 --- a/pom.xml +++ b/pom.xml @@ -54,7 +54,7 @@ false - 4.9.3 + 4.9.5 3.18.0 2.20.0 1.17.7 From 3b5a024831be0c01bc84a6064d0f98d50f12abba Mon Sep 17 00:00:00 2001 From: Ulli Hafner Date: Tue, 16 Sep 2025 09:14:16 +0200 Subject: [PATCH 2/2] Fix synchronization of error methods --- .../java/edu/hm/hafner/util/FilteredLog.java | 39 ++++++++++++------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/src/main/java/edu/hm/hafner/util/FilteredLog.java b/src/main/java/edu/hm/hafner/util/FilteredLog.java index edd0150f..84acbbb0 100644 --- a/src/main/java/edu/hm/hafner/util/FilteredLog.java +++ b/src/main/java/edu/hm/hafner/util/FilteredLog.java @@ -1,5 +1,10 @@ package edu.hm.hafner.util; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.exception.ExceptionUtils; + +import com.google.errorprone.annotations.FormatMethod; + import java.io.Serial; import java.io.Serializable; import java.util.ArrayList; @@ -9,11 +14,6 @@ import java.util.Objects; import java.util.concurrent.locks.ReentrantLock; -import org.apache.commons.lang3.StringUtils; -import org.apache.commons.lang3.exception.ExceptionUtils; - -import com.google.errorprone.annotations.FormatMethod; - /** * Provides a log of info messages and a limited number of error messages. If the number of errors exceeds this limit, * then further error messages will be skipped. This class is thread-safe and can be used in a distributed @@ -120,13 +120,7 @@ public void logInfo(final String format, final Object... args) { public void logError(final String message) { lock.lock(); try { - if (lines < maxLines) { - if (StringUtils.isNotBlank(title) && errorMessages.isEmpty()) { - errorMessages.add(title); - } - errorMessages.add(message); - } - lines++; + logErrorWithGuard(message); } finally { lock.unlock(); @@ -162,10 +156,9 @@ public void logError(final String format, final Object... args) { */ @FormatMethod public void logException(final Exception exception, final String format, final Object... args) { - logError(format, args); - lock.lock(); try { + logErrorWithGuard(format.formatted(args)); if (lines <= maxLines) { errorMessages.addAll(Arrays.asList(ExceptionUtils.getRootCauseStackTrace(exception))); } @@ -175,13 +168,29 @@ public void logException(final Exception exception, final String format, final O } } + private void logErrorWithGuard(final String message) { + if (lines < maxLines) { + if (StringUtils.isNotBlank(title) && errorMessages.isEmpty()) { + errorMessages.add(title); + } + errorMessages.add(message); + } + lines++; + } + /** * Returns the total number of errors that have been reported. * * @return the total number of errors */ public int size() { - return lines; + lock.lock(); + try { + return lines; + } + finally { + lock.unlock(); + } } /**