You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "Andreas Lemmer (Jira)" <ji...@apache.org> on 2024/12/20 21:33:00 UTC

[jira] [Comment Edited] (FELIX-6745) HttpService: Cannot unregister javaxwrappers.ServletWrapper

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

Andreas Lemmer edited comment on FELIX-6745 at 12/20/24 9:32 PM:
-----------------------------------------------------------------

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 holds the (original) javax.Servlet and then a new getter getJavaxServlet() can easily return the correct javax.Servlet.


was (Author: alemmer):
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)