You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/02/18 07:07:40 UTC

[GitHub] [pulsar] gaozhangmin commented on a change in pull request #14346: [Pulsar-Functions]Remove unnecessary synchronized-block in FunctionCacheManagerImpl

gaozhangmin commented on a change in pull request #14346:
URL: https://github.com/apache/pulsar/pull/14346#discussion_r809725074



##########
File path: pulsar-functions/utils/src/main/java/org/apache/pulsar/functions/utils/functioncache/FunctionCacheManagerImpl.java
##########
@@ -73,39 +71,37 @@ public void registerFunctionInstance(String fid,
             throw new NullPointerException("FunctionID not set");
         }
 
-        synchronized (cacheFunctions) {
-            FunctionCacheEntry entry = cacheFunctions.get(fid);
+        FunctionCacheEntry entry = cacheFunctions.get(fid);
 
-            if (null == entry) {
-                URL[] urls = new URL[requiredJarFiles.size() + requiredClasspaths.size()];
-                int count = 0;
-                try {
-                    // add jar files to urls
-                    for (String jarFile : requiredJarFiles) {
-                        urls[count++] = new File(jarFile).toURI().toURL();
-                    }
+        if (null == entry) {
+            URL[] urls = new URL[requiredJarFiles.size() + requiredClasspaths.size()];
+            int count = 0;
+            try {
+                // add jar files to urls
+                for (String jarFile : requiredJarFiles) {
+                    urls[count++] = new File(jarFile).toURI().toURL();
+                }
 
-                    // add classpaths
-                    for (URL url : requiredClasspaths) {
-                        urls[count++] = url;
-                    }
+                // add classpaths
+                for (URL url : requiredClasspaths) {
+                    urls[count++] = url;
+                }
 
-                    cacheFunctions.put(
+                cacheFunctions.put(
                         fid,
                         new FunctionCacheEntry(
-                            requiredJarFiles,
-                            requiredClasspaths,
-                            urls,
-                            eid, rootClassLoader));
-                } catch (Throwable cause) {
-                    Exceptions.rethrowIOException(cause);
-                }

Review comment:
       @BewareMyPower  pTAL

##########
File path: pulsar-functions/utils/src/main/java/org/apache/pulsar/functions/utils/functioncache/FunctionCacheManagerImpl.java
##########
@@ -116,43 +112,35 @@ public void registerFunctionInstanceWithArchive(String fid, String eid,
             throw new NullPointerException("FunctionID not set");
         }
 
-        synchronized (cacheFunctions) {
-            FunctionCacheEntry entry = cacheFunctions.get(fid);
+        FunctionCacheEntry entry = cacheFunctions.get(fid);
 
-            if (null != entry) {
-                entry.register(eid, Collections.singleton(narArchive), Collections.emptyList());
-                return;
-            }
+        if (null != entry) {
+            entry.register(eid, Collections.singleton(narArchive), Collections.emptyList());
+            return;
+        }
 
-            // Create new cache entry
-            try {
-                cacheFunctions.put(fid, new FunctionCacheEntry(narArchive, eid, rootClassLoader, narExtractionDirectory));
-            } catch (Throwable cause) {
-                Exceptions.rethrowIOException(cause);
-            }
+        // Create new cache entry
+        try {
+            cacheFunctions.put(fid, new FunctionCacheEntry(narArchive, eid, rootClassLoader, narExtractionDirectory));
+        } catch (Throwable cause) {
+            Exceptions.rethrowIOException(cause);
         }

Review comment:
       @BewareMyPower pTAL




-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org