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

wusheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/skywalking.git


The following commit(s) were added to refs/heads/master by this push:
     new d036224d72 Fix NPE and IllegalArgument in AI-based formatting (#10973)
d036224d72 is described below

commit d036224d7274d93beb76da9f6330409826bdb46d
Author: Superskyyy <[email protected]>
AuthorDate: Wed Jun 21 01:01:15 2023 -0400

    Fix NPE and IllegalArgument in AI-based formatting (#10973)
---
 docs/en/changes/changes.md                           |  1 +
 .../core/config/group/EndpointNameGrouping.java      | 20 +++++++++-----------
 2 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/docs/en/changes/changes.md b/docs/en/changes/changes.md
index 5564d78ca4..683bdeec14 100644
--- a/docs/en/changes/changes.md
+++ b/docs/en/changes/changes.md
@@ -13,6 +13,7 @@
 * [Breaking change] Remove `matchedCounter` from 
`HttpUriRecognitionService#feedRawData`.
 * Remove patterns from `HttpUriRecognitionService#feedRawData` and add max 10 
candidates of raw URIs for each pattern.
 * Add component ID for WebSphere.
+* Fix AI Pipeline uri caching NullPointer and IllegalArgument Exceptions.
 
 #### UI
 
diff --git 
a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/config/group/EndpointNameGrouping.java
 
b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/config/group/EndpointNameGrouping.java
index a2c1bc8e0d..8ac88b391e 100644
--- 
a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/config/group/EndpointNameGrouping.java
+++ 
b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/config/group/EndpointNameGrouping.java
@@ -90,26 +90,24 @@ public class EndpointNameGrouping {
         if (!formattedName._2() && quickUriGroupingRule != null) {
             formattedName = formatByQuickUriPattern(serviceName, endpointName);
 
-            ConcurrentHashMap<String, ArrayBlockingQueue<String>> svrHttpUris 
= cachedHttpUris.get(serviceName);
-            if (svrHttpUris == null) {
-                cachedHttpUris.putIfAbsent(serviceName, new 
ConcurrentHashMap<>());
-                svrHttpUris = cachedHttpUris.get(serviceName);
-            }
-            // Only cache first N(determined by maxHttpUrisNumberPerService) 
URIs per 30 mins.
+            ConcurrentHashMap<String, ArrayBlockingQueue<String>> svrHttpUris =
+                    cachedHttpUris.computeIfAbsent(serviceName, k -> new 
ConcurrentHashMap<>());
+
+            // Only cache first N (determined by maxHttpUrisNumberPerService) 
URIs per 30 mins.
             if (svrHttpUris.size() < maxHttpUrisNumberPerService) {
                 if (formattedName._2()) {
+                    // Algorithm side should not return a pattern that has no 
{var} in it else this
+                    // code may accidentally retreive the size 1 queue created 
by unformatted endpoint
                     // The queue size is 10, which means only cache the first 
10 formatted names.
-                    final ArrayBlockingQueue<String> formattedURIs = 
svrHttpUris.putIfAbsent(
-                        formattedName._1(), new ArrayBlockingQueue<>(10));
+                    final ArrayBlockingQueue<String> formattedURIs = 
svrHttpUris.computeIfAbsent(
+                            formattedName._1(), k -> new 
ArrayBlockingQueue<>(10));
                     if (formattedURIs.size() < 10) {
                         // Try to push the raw URI as a candidate of formatted 
name.
                         formattedURIs.offer(endpointName);
                     }
                 } else {
-                    svrHttpUris.putIfAbsent(
-                        formattedName._1(), new ArrayBlockingQueue<>(0));
+                    svrHttpUris.computeIfAbsent(endpointName, k -> new 
ArrayBlockingQueue<>(1));
                 }
-
             }
         }
 

Reply via email to