Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

baseResource/resourceBase is no longer extracted from ServletContext #11312

Closed
benleers opened this issue Jan 24, 2024 · 2 comments · Fixed by #11314
Closed

baseResource/resourceBase is no longer extracted from ServletContext #11312

benleers opened this issue Jan 24, 2024 · 2 comments · Fixed by #11314
Assignees
Labels
Bug For general bugs on Jetty side

Comments

@benleers
Copy link

benleers commented Jan 24, 2024

Jetty version(s)
12.0.5

Jetty Environment
ee10

Java version/vendor
21.0.1

OS type/version
MacOS 14.2.1

Description
We use the Spring boot ServletContextInitializer to set the init parameter baseResource/resourceBase.

servletContext.setInitParameter("org.eclipse.jetty.servlet.Default.resourceBase", "/location");

This no longer works using Jetty 12, as the way this init parameter is loaded in the DefaultServlet has changed. The parameter is renamed, but there is also a new getInitParameter method is added, to provide backwards compatibility for the old name.

    private String getInitParameter(String name, String... deprecated)
    {
        String value = super.getInitParameter(name);
        if (value != null)
            return value;

        for (String d : deprecated)
        {
            value = super.getInitParameter(d);
            if (value != null)
            {
                LOG.warn("Deprecated {} used instead of {}", d, name);
                return value;
            }
        }

        return null;
    }

This method does not use the getInitParameter(String) from the DefaultServlet.

    public String getInitParameter(String name)
    {
        String value = getServletContext().getInitParameter(CONTEXT_INIT + name);
        if (value == null)
            value = super.getInitParameter(name);
        return value;
    }

The method tries to fetch init parameters from the ServletContext (with the CONTEXT_INIT prefix) first and then falls back to the ServletConfig.

I think the getInitParameter(String,String) should be altered so that it uses the getInitParameter(String) from the DefaultServlet

@benleers benleers added the Bug For general bugs on Jetty side label Jan 24, 2024
@joakime
Copy link
Contributor

joakime commented Jan 24, 2024

Do you have access to either the ServletContextHandler or the WebAppContext during your init?

@joakime
Copy link
Contributor

joakime commented Jan 24, 2024

Opened PR #11314

joakime added a commit that referenced this issue Jan 25, 2024
…eprecated-init-params

Issue #11312 - fix deprecated init-param detection in DefaultServlet
@github-project-automation github-project-automation bot moved this from 🏗 In progress to ✅ Done in Jetty 12.0.6 FROZEN Jan 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For general bugs on Jetty side
Projects
No open projects
Status: ✅ Done
Development

Successfully merging a pull request may close this issue.

2 participants