Ignore HTTP Whiteboard Filters 21/102421/1
authorRobert Varga <robert.varga@pantheon.tech>
Thu, 22 Sep 2022 09:19:39 +0000 (11:19 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Thu, 22 Sep 2022 09:22:03 +0000 (11:22 +0200)
CustomFilterAdapterConfigurationImpl is listening for all servlet
filters being published to OSGi registry. This unfortunately means
it picks up also filters destined for HTTP Whiteboard -- such as
CustomFilterAdapter, which in turn uses ConfigurationImpl to get
its list of filters -- leading to the filter referencing itself.

Exclude Filters properly marked for HTTP Whiteboard from contributing to
the list and drop a FIXME for a future enhancement.

JIRA: AAA-235
Change-Id: I80c1264889b42a105a62cd5da4238a54554839dd
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
aaa-filterchain/src/main/java/org/opendaylight/aaa/filterchain/configuration/impl/CustomFilterAdapterConfigurationImpl.java

index 9191ced463568c45242af0b0ff0aa4072784d66e..1aa2dac62f30f1b72706b0a0f71da3c6c22fed63 100644 (file)
@@ -91,7 +91,14 @@ public final class CustomFilterAdapterConfigurationImpl implements CustomFilterA
 
     // Invoked when a Filter OSGi service is added
     @Reference(cardinality = ReferenceCardinality.MULTIPLE,
-            policy = ReferencePolicy.DYNAMIC, policyOption = ReferencePolicyOption.GREEDY)
+            policy = ReferencePolicy.DYNAMIC, policyOption = ReferencePolicyOption.GREEDY,
+            // Needed to exclude any filters that is published for HTTP Whiteboard
+            // FIXME: it would be much better if we had a whitelist property to prevent confusion
+            target = "(!(|"
+                + "(osgi.http.whiteboard.filter.pattern=*)"
+                + "(osgi.http.whiteboard.filter.regex=*)"
+                + "(osgi.http.whiteboard.filter.servlet=*)"
+                + "))")
     public void addFilter(final Filter filter) {
         if (filter == null) {
             return;