[ 
https://issues.apache.org/jira/browse/FELIX-6745?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17907498#comment-17907498
 ] 

Andreas Lemmer commented on FELIX-6745:
---------------------------------------

Double-wrapping seems to be a solution but that doesn't sound nice.

The core problem is that the HttpServiceServletHandler constructor "loses" the 
given javax servlet when it is a javaxwrappers.ServletWrapper.
Perhaps the HttpServiceServletHandler should be extended so that it contains 
both the (original) javax.Servlet and the jakarta.Servlet (either a new wrapper 
or the wrapped servlet as in my case) and then a new getter getJavaxServlet() 
can easily return the correct javax.Servlet.

> HttpService: Cannot unregister javaxwrappers.ServletWrapper
> -----------------------------------------------------------
>
>                 Key: FELIX-6745
>                 URL: https://issues.apache.org/jira/browse/FELIX-6745
>             Project: Felix
>          Issue Type: Bug
>          Components: HTTP Service
>    Affects Versions: http.jetty12-1.0.19
>            Reporter: Andreas Lemmer
>            Priority: Critical
>
> When (manually) registering an 
> {{org.apache.felix.http.javaxwrappers.ServletWrapper}} servlet at 
> {{{}org.osgi.service.http.HttpService{}}}, it cannot be unregistered anymore:
> {{java.lang.ClassCastException: class (WrappedServlet) cannot be cast to 
> class org.apache.felix.http.jakartawrappers.ServletWrapper}}
> {{at 
> org.apache.felix.http.base.internal.service.SharedHttpServiceImpl.getServlet(SharedHttpServiceImpl.java:117)}}
> {{at 
> org.apache.felix.http.base.internal.service.SharedHttpServiceImpl.unregister(SharedHttpServiceImpl.java:100)}}
> This is because registering the ServletWrapper actually registers the wrapped 
> servlet (see 
> {{{}org.apache.felix.http.jakartawrappers.ServletWrapper#getRegisteredServlet){}}},
>  but unregistering assumes that the registered servlet is an 
> {{org.apache.felix.http.jakartawrappers.ServletWrapper}} (see 
> {{{}org.apache.felix.http.base.internal.service.{}}}{{{}SharedHttpServiceImpl{}}}{{{}#getServlet{}}}
>  where the CCE happens).



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to