This is an automated email from the ASF dual-hosted git repository.

mattsicker pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git


The following commit(s) were added to refs/heads/main by this push:
     new 838f562f7e Avoid NPE in extension code
838f562f7e is described below

commit 838f562f7e185668d5575e347637ce2302ee3b82
Author: Matt Sicker <[email protected]>
AuthorDate: Mon Jan 1 20:02:20 2024 -0600

    Avoid NPE in extension code
    
    Signed-off-by: Matt Sicker <[email protected]>
---
 .../org/apache/logging/log4j/test/junit/TempLoggingDirectory.java    | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git 
a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/TempLoggingDirectory.java
 
b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/TempLoggingDirectory.java
index 6259ddf734..0b65f3ef88 100644
--- 
a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/TempLoggingDirectory.java
+++ 
b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/TempLoggingDirectory.java
@@ -103,8 +103,9 @@ public class TempLoggingDirectory implements 
BeforeAllCallback, BeforeEachCallba
     @Override
     public Object resolveParameter(ParameterContext parameterContext, 
ExtensionContext extensionContext)
             throws ParameterResolutionException {
-        final TempLoggingDir annotation =
-                parameterContext.findAnnotation(TempLoggingDir.class).get();
+        final TempLoggingDir annotation = parameterContext
+                .findAnnotation(TempLoggingDir.class)
+                .orElseThrow(() -> new ParameterResolutionException("No 
@TempLoggingDir annotation found"));
         // Get or create temporary directory
         PathHolder holder = 
ExtensionContextAnchor.getAttribute(PathHolder.class, PathHolder.class, 
extensionContext);
         if (holder == null || 
!extensionContext.equals(holder.getMainContext())) {

Reply via email to