kwin commented on code in PR #35:
URL: 
https://github.com/apache/sling-org-apache-sling-engine/pull/35#discussion_r1207046502


##########
src/main/java/org/apache/sling/engine/impl/SlingRequestProcessorImpl.java:
##########
@@ -308,9 +330,37 @@ public void processRequest(final HttpServletRequest 
servletRequest,
             } else {
                 
servletRequest.removeAttribute(ParameterSupport.MARKER_IS_SERVICE_PROCESSING);
             }
+            requestListenersForSyntheticRequest.forEach(l -> 
l.requestDestroyed(event));
+            
requestListenerServiceReferencesForSyntheticRequest.forEach(bundleContext::ungetService);
+        }
+    }
+
+    private Collection<ServiceReference<ServletRequestListener>> 
getRequestListenersForSyntheticRequest(HttpServletRequest servletRequest) {
+        if (!isSyntheticRequest(servletRequest)) {
+            return Collections.emptyList();
+        } else {
+            return Stream.of(getSlingServletContextDTO().listenerDTOs)
+                .filter(l -> 
Arrays.stream(l.types).anyMatch(ServletRequestListener.class.getName()::equals))
+                .map(l -> {
+                    try {
+                        return 
bundleContext.getServiceReferences(ServletRequestListener.class, "(service.id=" 
+ l.serviceId + ")").iterator().next();
+                    } catch (InvalidSyntaxException e) {
+                        // should not happen
+                        throw new IllegalStateException(e);
+                    }
+                })
+                .collect(Collectors.toSet());
         }
     }
 
+    private boolean isSyntheticRequest(HttpServletRequest servletRequest) {
+        return 
servletRequest.getServletContext().getClass().getName().equals(ServletContextImpl.class.getName());

Review Comment:
   This needs some tweaking probably



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

To unsubscribe, e-mail: [email protected]

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

Reply via email to