Skip to content

Commit

Permalink
Issue #10731 wrong context attribute name javax.servlet instead of ja…
Browse files Browse the repository at this point in the history
…karta.servlet (#10735)

* Issue #10731 wrong context attribute name javax.servlet instead of jakarta.servlet

Signed-off-by: Olivier Lamy <olamy@apache.org>

* Update jetty-server/src/main/java/org/eclipse/jetty/server/MultiPartFormInputStream.java

Co-authored-by: Simone Bordet <simone.bordet@gmail.com>

* Update jetty-server/src/main/java/org/eclipse/jetty/server/Request.java

Co-authored-by: Simone Bordet <simone.bordet@gmail.com>

* fix javadoc

Signed-off-by: Olivier Lamy <olamy@apache.org>

* more usage of constant

Signed-off-by: Olivier Lamy <olamy@apache.org>

---------

Signed-off-by: Olivier Lamy <olamy@apache.org>
Co-authored-by: Simone Bordet <simone.bordet@gmail.com>
  • Loading branch information
olamy and sbordet authored Oct 16, 2023
1 parent 38a57e1 commit 3507e17
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import java.io.File;
import java.net.URI;

import jakarta.servlet.ServletContext;
import org.eclipse.jetty.webapp.WebAppContext;

/**
Expand All @@ -26,7 +27,7 @@ public class JspConfig
{
public static void init(WebAppContext context, URI baseUri, File scratchDir)
{
context.setAttribute("jakarta.servlet.context.tempdir", scratchDir);
context.setAttribute(ServletContext.TEMPDIR, scratchDir);
context.setAttribute("org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern",
".*/jetty-jakarta-servlet-api-[^/]*\\.jar$|.*jakarta.servlet.jsp.jstl-[^/]*\\.jar|.*taglibs-standard.*\\.jar");
context.setWar(baseUri.toASCIIString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ public String getContentDispositionFilename()
* @param in Request input stream
* @param contentType Content-Type header
* @param config MultipartConfigElement
* @param contextTmpDir jakarta.servlet.context.tempdir
* @param contextTmpDir {@value jakarta.servlet.ServletContext#TEMPDIR}
*/
public MultiPartFormInputStream(InputStream in, String contentType, MultipartConfigElement config, File contextTmpDir)
{
Expand All @@ -378,7 +378,7 @@ public MultiPartFormInputStream(InputStream in, String contentType, MultipartCon
* @param in Request input stream
* @param contentType Content-Type header
* @param config MultipartConfigElement
* @param contextTmpDir javax.servlet.context.tempdir
* @param contextTmpDir {@value jakarta.servlet.ServletContext#TEMPDIR}
* @param maxParts the maximum number of parts that can be parsed from the multipart content (0 for no parts allowed, -1 for unlimited parts).
*/
public MultiPartFormInputStream(InputStream in, String contentType, MultipartConfigElement config, File contextTmpDir, int maxParts)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ public String getContentDispositionFilename()
* @param in Request input stream
* @param contentType Content-Type header
* @param config MultipartConfigElement
* @param contextTmpDir jakarta.servlet.context.tempdir
* @param contextTmpDir {@value jakarta.servlet.ServletContext#TEMPDIR}
*/
public MultiPartInputStreamParser(InputStream in, String contentType, MultipartConfigElement config, File contextTmpDir)
{
Expand All @@ -386,7 +386,7 @@ public MultiPartInputStreamParser(InputStream in, String contentType, MultipartC
* @param in Request input stream
* @param contentType Content-Type header
* @param config MultipartConfigElement
* @param contextTmpDir javax.servlet.context.tempdir
* @param contextTmpDir {@value jakarta.servlet.ServletContext#TEMPDIR}
* @param maxParts the maximum number of parts that can be parsed from the multipart content (0 for no parts allowed, -1 for unlimited parts).
*/
public MultiPartInputStreamParser(InputStream in, String contentType, MultipartConfigElement config, File contextTmpDir, int maxParts)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2424,12 +2424,12 @@ private MultiParts newMultiParts(MultipartConfigElement config, int maxParts) th
{
case RFC7578:
return new MultiParts.MultiPartsHttpParser(getInputStream(), getContentType(), config,
(_context != null ? (File)_context.getAttribute("javax.servlet.context.tempdir") : null), this, maxParts);
(_context != null ? (File)_context.getAttribute(ServletContext.TEMPDIR) : null), this, maxParts);

case LEGACY:
default:
return new MultiParts.MultiPartsUtilParser(getInputStream(), getContentType(), config,
(_context != null ? (File)_context.getAttribute("javax.servlet.context.tempdir") : null), this, maxParts);
(_context != null ? (File)_context.getAttribute(ServletContext.TEMPDIR) : null), this, maxParts);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public void init(FilterConfig config) throws ServletException
{
_context = config.getServletContext();

_tmpdir = (File)_context.getAttribute("jakarta.servlet.context.tempdir");
_tmpdir = (File)_context.getAttribute(ServletContext.TEMPDIR);

String realPath = _context.getRealPath("/");
if (realPath == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1151,7 +1151,7 @@ public void setContextWhiteList(String... contextWhiteList)

/**
* Set temporary directory for context.
* The jakarta.servlet.context.tempdir attribute is also set.
* The {@value jakarta.servlet.ServletContext#TEMPDIR} attribute is also set.
*
* @param dir Writable temporary directory.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public void cloneConfigure(WebAppContext template, WebAppContext context) throws
* exit depends on value of persistTempDirectory.
* </li>
* <li>
* Iff jakarta.servlet.context.tempdir context attribute is set for
* Iff {@value jakarta.servlet.ServletContext#TEMPDIR} context attribute is set for
* this webapp &amp;&amp; exists &amp;&amp; writeable, then use it. Set delete on exit depends on
* value of persistTempDirectory.
* </li>
Expand Down

0 comments on commit 3507e17

Please sign in to comment.