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

cziegeler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/felix-dev.git


The following commit(s) were added to refs/heads/master by this push:
     new 07823aeb19 FELIX-6683 : Reduce requests to service registry
07823aeb19 is described below

commit 07823aeb19753bf93b60c08eb55256a5d6db900d
Author: Carsten Ziegeler <cziege...@apache.org>
AuthorDate: Sat Jan 20 15:57:37 2024 +0100

    FELIX-6683 : Reduce requests to service registry
---
 .../internal/whiteboard/WhiteboardManager.java     | 43 ++++++++++------------
 http/bridge/pom.xml                                |  2 +-
 2 files changed, 21 insertions(+), 24 deletions(-)

diff --git 
a/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/WhiteboardManager.java
 
b/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/WhiteboardManager.java
index 93422105ba..f082122f7c 100644
--- 
a/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/WhiteboardManager.java
+++ 
b/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/WhiteboardManager.java
@@ -470,35 +470,32 @@ public final class WhiteboardManager
     /**
      * Find the list of matching contexts for the whiteboard service
      */
-    private List<WhiteboardContextHandler> getMatchingContexts(final 
WhiteboardServiceInfo<?> info)
-    {
+    private List<WhiteboardContextHandler> getMatchingContexts(final 
WhiteboardServiceInfo<?> info) {
         final List<WhiteboardContextHandler> result = new ArrayList<>();
-        for(final List<WhiteboardContextHandler> handlerList : 
this.contextMap.values())
-        {
+        for(final List<WhiteboardContextHandler> handlerList : 
this.contextMap.values()) {
             final WhiteboardContextHandler h = handlerList.get(0);
-            // check whether the servlet context helper is visible to the 
whiteboard bundle
-            // see chapter 140.2
-            boolean visible = h.getContextInfo().getServiceId() < 0; // 
internal ones are always visible
-            if ( !visible )
-            {
-                final String filterString = "(" + Constants.SERVICE_ID + "=" + 
String.valueOf(h.getContextInfo().getServiceId()) + ")";
-                try
-                {
-                    final ServiceReference<?>[] col = 
info.getServiceReference().getBundle().getBundleContext().getServiceReferences(h.getContextInfo().getServiceType(),
 filterString);
-                    if ( col !=null && col.length > 0 )
-                    {
-                        visible = true;
+
+            // check if the context matches
+            final boolean matches = h.getContextInfo().match(info);
+            if (matches) {
+                // check whether the servlet context helper is visible to the 
whiteboard bundle
+                // see chapter 140.2
+                boolean visible = h.getContextInfo().getServiceId() < 0; // 
internal ones are always visible
+                if ( !visible ) {
+                    final String filterString = "(" + Constants.SERVICE_ID + 
"=" + String.valueOf(h.getContextInfo().getServiceId()) + ")";
+                    try {
+                        final ServiceReference<?>[] col = 
info.getServiceReference().getBundle().getBundleContext().getServiceReferences(h.getContextInfo().getServiceType(),
 filterString);
+                        if ( col !=null && col.length > 0 ) {
+                            visible = true;
+                        }
+                    } catch ( final InvalidSyntaxException ise ) {
+                        // we ignore this and treat it as an invisible service
                     }
                 }
-                catch ( final InvalidSyntaxException ise )
-                {
-                    // we ignore this and treat it as an invisible service
+                if ( visible ) {
+                    result.add(h);
                 }
             }
-            if ( visible && h.getContextInfo().match(info) )
-            {
-                result.add(h);
-            }
         }
         return result;
     }
diff --git a/http/bridge/pom.xml b/http/bridge/pom.xml
index 91cb19faee..801c372886 100644
--- a/http/bridge/pom.xml
+++ b/http/bridge/pom.xml
@@ -184,7 +184,7 @@
         <dependency>
             <groupId>org.apache.felix</groupId>
             <artifactId>org.apache.felix.http.base</artifactId>
-            <version>5.1.4</version>
+            <version>5.1.5-SNAPSHOT</version>
         </dependency>
         <dependency>
             <groupId>org.apache.felix</groupId>

Reply via email to