You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by kw...@apache.org on 2022/11/15 17:10:38 UTC

[sling-org-apache-sling-engine] branch bugfix/service-ranking-slinghttpcontext created (now 2df54b3)

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

kwin pushed a change to branch bugfix/service-ranking-slinghttpcontext
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-engine.git


      at 2df54b3  SLING-11677 SlingHttpContext must use lowest possible service ranking

This branch includes the following new commits:

     new 2df54b3  SLING-11677 SlingHttpContext must use lowest possible service ranking

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[sling-org-apache-sling-engine] 01/01: SLING-11677 SlingHttpContext must use lowest possible service ranking

Posted by kw...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kwin pushed a commit to branch bugfix/service-ranking-slinghttpcontext
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-engine.git

commit 2df54b3bd54e8b36fe0b85cf22df895ec6131d2c
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Tue Nov 15 18:10:31 2022 +0100

    SLING-11677 SlingHttpContext must use lowest possible service ranking
    
    Otherwise Sling Main Servlet takes precedence over any servlets
    registered with the OSGi HTTP Whiteboard default context
---
 src/main/java/org/apache/sling/engine/impl/SlingHttpContext.java | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/main/java/org/apache/sling/engine/impl/SlingHttpContext.java b/src/main/java/org/apache/sling/engine/impl/SlingHttpContext.java
index 6169e31..0bb105a 100644
--- a/src/main/java/org/apache/sling/engine/impl/SlingHttpContext.java
+++ b/src/main/java/org/apache/sling/engine/impl/SlingHttpContext.java
@@ -35,6 +35,7 @@ import org.osgi.service.component.annotations.Component;
 import org.osgi.service.component.annotations.Reference;
 import org.osgi.service.component.annotations.ReferenceCardinality;
 import org.osgi.service.component.annotations.ReferencePolicy;
+import org.osgi.service.component.propertytypes.ServiceRanking;
 import org.osgi.service.http.context.ServletContextHelper;
 import org.osgi.service.http.whiteboard.annotations.RequireHttpWhiteboard;
 import org.osgi.service.http.whiteboard.propertytypes.HttpWhiteboardContext;
@@ -48,6 +49,14 @@ import org.slf4j.LoggerFactory;
 @RequireHttpWhiteboard
 @Component(service = ServletContextHelper.class)
 @HttpWhiteboardContext(name = SlingHttpContext.SERVLET_CONTEXT_NAME, path = "/")
+/**
+ * This context must have a lower ranking than all other contexts, particularly the default
+ * context used by OSGi HTTP Whiteboard (compare with https://issues.apache.org/jira/browse/SLING-11677)
+ * Otherwise the default Sling servlet always takes precedence!
+ * @see <a href="https://docs.osgi.org/specification/osgi.cmpn/7.0.0/service.http.whiteboard.html#service.http.whiteboard.servletcontext">
+ * OSGi Compendium R7, HTTP Whiteboard, The Servlet Context<a/>
+ */
+@ServiceRanking(Integer.MIN_VALUE)
 public class SlingHttpContext extends ServletContextHelper {
 
     /**