From 1eab04986497d8234d8916fe7574a50a2e0cbbc2 Mon Sep 17 00:00:00 2001
From: Prashant <prashant.thakre@gmail.com>
Date: Sat, 21 Nov 2026 08:55:38 +0000
Subject: [PATCH] Close the OAuth2 token directory stream after checks (#1315)

---
 opendj-server-legacy/src/main/java/org/opends/server/protocols/http/authz/HttpOAuth2FileAuthorizationMechanism.java |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/server/protocols/http/authz/HttpOAuth2FileAuthorizationMechanism.java b/opendj-server-legacy/src/main/java/org/opends/server/protocols/http/authz/HttpOAuth2FileAuthorizationMechanism.java
index f97aaf4..92b62c9 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/protocols/http/authz/HttpOAuth2FileAuthorizationMechanism.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/protocols/http/authz/HttpOAuth2FileAuthorizationMechanism.java
@@ -19,7 +19,9 @@
 import static org.opends.messages.ConfigMessages.ERR_CONFIG_OAUTH2_NON_EXISTING_DIRECTORY;
 import static org.opends.server.util.StaticUtils.getFileForPath;
 
+import java.nio.file.DirectoryStream;
 import java.nio.file.Files;
+import java.nio.file.Path;
 import java.nio.file.Paths;
 
 import org.forgerock.http.oauth2.AccessTokenResolver;
@@ -41,9 +43,10 @@
   AccessTokenResolver newAccessTokenResolver() throws ConfigException
   {
     final String absoluteTokenDir = getFileForPath(config.getAccessTokenDirectory()).getAbsolutePath();
-    try
+    // Opened only to check the directory is readable, then closed.
+    try (DirectoryStream<Path> ignored = Files.newDirectoryStream(Paths.get(absoluteTokenDir)))
     {
-      Files.newDirectoryStream(Paths.get(absoluteTokenDir));
+      // Nothing to do.
     }
     catch (Exception e)
     {

--
Gitblit v1.10.0