-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #10084 - Implementing fix for ee9
- Loading branch information
Showing
11 changed files
with
266 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
jetty-ee9/jetty-ee9-webapp/src/test/java/org/acme/webapp/GetRealPathsServlet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// | ||
// ======================================================================== | ||
// Copyright (c) 1995 Mort Bay Consulting Pty Ltd and others. | ||
// | ||
// This program and the accompanying materials are made available under the | ||
// terms of the Eclipse Public License v. 2.0 which is available at | ||
// https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 | ||
// which is available at https://www.apache.org/licenses/LICENSE-2.0. | ||
// | ||
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 | ||
// ======================================================================== | ||
// | ||
|
||
package org.acme.webapp; | ||
|
||
import java.io.IOException; | ||
import java.util.LinkedHashSet; | ||
import java.util.Set; | ||
|
||
import jakarta.servlet.http.HttpServlet; | ||
import jakarta.servlet.http.HttpServletRequest; | ||
import jakarta.servlet.http.HttpServletResponse; | ||
|
||
public class GetRealPathsServlet extends HttpServlet | ||
{ | ||
@Override | ||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException | ||
{ | ||
collectResourcePaths("/").stream() | ||
.map(p -> getServletContext().getRealPath(p)) | ||
.forEach(resp.getWriter()::println); | ||
resp.getWriter().flush(); | ||
} | ||
|
||
private Set<String> collectResourcePaths(String path) | ||
{ | ||
Set<String> allResourcePaths = new LinkedHashSet<>(); | ||
Set<String> pathsForPath = getServletContext().getResourcePaths(path); | ||
if (pathsForPath != null) | ||
{ | ||
for (String resourcePath : pathsForPath) | ||
{ | ||
allResourcePaths.add(resourcePath); | ||
allResourcePaths.addAll(collectResourcePaths(resourcePath)); | ||
} | ||
} | ||
return allResourcePaths; | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
jetty-ee9/jetty-ee9-webapp/src/test/java/org/acme/webapp/GetResourcePathsServlet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// | ||
// ======================================================================== | ||
// Copyright (c) 1995 Mort Bay Consulting Pty Ltd and others. | ||
// | ||
// This program and the accompanying materials are made available under the | ||
// terms of the Eclipse Public License v. 2.0 which is available at | ||
// https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 | ||
// which is available at https://www.apache.org/licenses/LICENSE-2.0. | ||
// | ||
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 | ||
// ======================================================================== | ||
// | ||
|
||
package org.acme.webapp; | ||
|
||
import java.io.IOException; | ||
import java.util.LinkedHashSet; | ||
import java.util.Set; | ||
|
||
import jakarta.servlet.http.HttpServlet; | ||
import jakarta.servlet.http.HttpServletRequest; | ||
import jakarta.servlet.http.HttpServletResponse; | ||
|
||
public class GetResourcePathsServlet extends HttpServlet | ||
{ | ||
@Override | ||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException | ||
{ | ||
collectResourcePaths("/").forEach(resp.getWriter()::println); | ||
resp.getWriter().flush(); | ||
} | ||
|
||
private Set<String> collectResourcePaths(String path) | ||
{ | ||
Set<String> allResourcePaths = new LinkedHashSet<>(); | ||
Set<String> pathsForPath = getServletContext().getResourcePaths(path); | ||
if (pathsForPath != null) | ||
{ | ||
for (String resourcePath : pathsForPath) | ||
{ | ||
allResourcePaths.add(resourcePath); | ||
allResourcePaths.addAll(collectResourcePaths(resourcePath)); | ||
} | ||
} | ||
return allResourcePaths; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
1 change: 1 addition & 0 deletions
1
jetty-ee9/jetty-ee9-webapp/src/test/resources/wars/with_dirs/WEB-INF/bar/main.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This is the "main.txt" in the /bar/ directory for war "with_dirs" |
1 change: 1 addition & 0 deletions
1
jetty-ee9/jetty-ee9-webapp/src/test/resources/wars/with_dirs/WEB-INF/foo/alt.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This is the "alt.txt" in the /foo/ directory for war "with_dirs" |
Binary file added
BIN
+479 Bytes
jetty-ee9/jetty-ee9-webapp/src/test/webapp-with-resources/WEB-INF/lib/odd-resource.jar
Binary file not shown.
30 changes: 30 additions & 0 deletions
30
jetty-ee9/jetty-ee9-webapp/src/test/webapp-with-resources/WEB-INF/web.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<web-app | ||
xmlns="https://jakarta.ee/xml/ns/jakartaee" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_6_0.xsd" | ||
metadata-complete="false" | ||
version="6.0"> | ||
|
||
<servlet> | ||
<servlet-name>GetResourcePathsServlet</servlet-name> | ||
<servlet-class>org.acme.webapp.GetResourcePathsServlet</servlet-class> | ||
<load-on-startup>1</load-on-startup> | ||
</servlet> | ||
<servlet> | ||
<servlet-name>GetRealPathsServlet</servlet-name> | ||
<servlet-class>org.acme.webapp.GetRealPathsServlet</servlet-class> | ||
<load-on-startup>1</load-on-startup> | ||
</servlet> | ||
|
||
<servlet-mapping> | ||
<servlet-name>GetResourcePathsServlet</servlet-name> | ||
<url-pattern>/resource/*</url-pattern> | ||
</servlet-mapping> | ||
<servlet-mapping> | ||
<servlet-name>GetRealPathsServlet</servlet-name> | ||
<url-pattern>/real/*</url-pattern> | ||
</servlet-mapping> | ||
</web-app> | ||
|
||
|