kezhenxu94 commented on a change in pull request #6727:
URL: https://github.com/apache/skywalking/pull/6727#discussion_r620289027



##########
File path: 
oap-server/oal-rt/src/main/java/org/apache/skywalking/oal/rt/OALRuntime.java
##########
@@ -194,7 +196,13 @@ private void generateClassAtRuntime(OALScripts oalScripts) 
throws OALCompileExce
         }
 
         for (Map.Entry<String, DispatcherContext> entry : 
allDispatcherContext.getAllContext().entrySet()) {
-            dispatcherClasses.add(generateDispatcherClass(entry.getKey(), 
entry.getValue()));
+            final String fullClassName = dispatcherClassName(entry.getKey(), 
true);
+            if (DISPATCHER_CLASS_CACHE.containsKey(fullClassName)) {
+                continue;
+            }
+            final Class dispatcherClass = 
generateDispatcherClass(entry.getKey(), entry.getValue());
+            dispatcherClasses.add(dispatcherClass);
+            DISPATCHER_CLASS_CACHE.put(fullClassName, dispatcherClass);

Review comment:
       > When could regenerate happen?
   
   Because we have tcp-related metrics rules in a separate `.oal` file, and 
need to load that file into OALRuntime, when this happens, the loader will try 
to define dispatcher classes for those entities in `tcp.oal`, which contains 
`Service`, `ServiceInstance`, etc., they exist in `core.oal` too, hence will be 
defined twice




-- 
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.

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


Reply via email to