github-advanced-security[bot] commented on code in PR #18184:
URL: https://github.com/apache/druid/pull/18184#discussion_r2178346107


##########
extensions-core/lookups-cached-global/src/main/java/org/apache/druid/server/lookup/namespace/cache/OffHeapNamespaceExtractionCacheManager.java:
##########
@@ -181,31 +182,19 @@
         .commitFileSyncDisable()
         .cacheSize(config.getNumBufferedEntries())
         .make();
-    try {
-      lifecycle.addMaybeStartHandler(
-          new Lifecycle.Handler()
-          {
-            @Override
-            public void start()
-            {
-              // NOOP
-            }
+  }
 
-            @Override
-            public synchronized void stop()
-            {
-              if (!mmapDB.isClosed()) {
-                mmapDB.close();
-                if (!tmpFile.delete()) {
-                  log.warn("Unable to delete file at [%s]", 
tmpFile.getAbsolutePath());
-                }
-              }
-            }
-          }
-      );
-    }
-    catch (Exception e) {
-      throw new RuntimeException(e);
+  @LifecycleStop
+  public synchronized void stop()
+  {
+    super.stopExecutor();
+    synchronized (this) {
+      if (!mmapDB.isClosed()) {
+        mmapDB.close();

Review Comment:
   ## Time-of-check time-of-use race condition
   
   This uses the state of [mmapDB](1) which [is checked at a previous call](2). 
But these are not jointly synchronized.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/9324)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to