Skip to content

Commit 54acdc2

Browse files
committed
Add PMD suppressions with reason where appropriate.
1 parent 496a2b1 commit 54acdc2

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

powertools-logging/src/main/java/software/amazon/lambda/powertools/logging/internal/LambdaLoggingAspect.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ public Object around(ProceedingJoinPoint pjp,
142142
isOnRequestStreamHandler);
143143
}
144144

145+
@SuppressWarnings("PMD.CloseResource") // Lambda-owned stream, not ours to close
145146
OutputStream backupOutputStream = null;
146147
if (isOnRequestStreamHandler) {
147148
// To log the result of a RequestStreamHandler (OutputStream), we need to do the following:
@@ -155,7 +156,7 @@ public Object around(ProceedingJoinPoint pjp,
155156
Object lambdaFunctionResponse;
156157
try {
157158
lambdaFunctionResponse = pjp.proceed(proceedArgs);
158-
} catch (Throwable t) {
159+
} catch (Throwable t) { // NOPMD - AspectJ proceed() throws Throwable
159160
handleException(pjp, logging, t);
160161
throw t;
161162
} finally {

powertools-logging/src/test/java/software/amazon/lambda/powertools/logging/internal/KeyBufferTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,9 +334,9 @@ void shouldUseDefaultWarningLoggerWhenNotProvided() {
334334
// Capture System.err output
335335
ByteArrayOutputStream errCapture = new ByteArrayOutputStream();
336336
PrintStream originalErr = System.err;
337-
System.setErr(new PrintStream(errCapture));
337+
try (PrintStream newErr = new PrintStream(errCapture)) {
338+
System.setErr(newErr);
338339

339-
try {
340340
KeyBuffer<String, String> defaultBuffer = new KeyBuffer<>(5, String::length);
341341

342342
// Cause overflow

0 commit comments

Comments
 (0)