diff --git a/arquillian/managed/src/main/java/cloud/piranha/arquillian/managed/ManagedPiranhaContainerConfiguration.java b/arquillian/managed/src/main/java/cloud/piranha/arquillian/managed/ManagedPiranhaContainerConfiguration.java index 8e6151a305..8ae5307c17 100644 --- a/arquillian/managed/src/main/java/cloud/piranha/arquillian/managed/ManagedPiranhaContainerConfiguration.java +++ b/arquillian/managed/src/main/java/cloud/piranha/arquillian/managed/ManagedPiranhaContainerConfiguration.java @@ -108,6 +108,12 @@ public class ManagedPiranhaContainerConfiguration implements ContainerConfigurat */ private boolean suspend = Boolean.parseBoolean(System.getProperty("piranha.suspend", "false")); + /** + * Constructor. + */ + public ManagedPiranhaContainerConfiguration() { + } + /** * Get the HTTP port. * @@ -138,6 +144,33 @@ public String getProtocol() { return protocol; } + /** + * Is the debug flag set. + * + * @return true if it is, false otherwise. + */ + public boolean isDebug() { + return debug; + } + + /** + * Is the suspend flag set. + * + * @return the suspend flag. + */ + public boolean isSuspend() { + return suspend; + } + + /** + * Set the debug flag. + * + * @param debug the debug flag. + */ + public void setDebug(boolean debug) { + this.debug = debug; + } + /** * Set the HTTP port. * @@ -165,36 +198,9 @@ public void setProtocol(String protocol) { this.protocol = protocol; } - /** - * Is the debug flag set? - * - * @return true if the debug flag is set, false otherwise. - */ - public boolean isDebug() { - return debug; - } - - /** - * Set the debug flag. - * - * @param debug the debug flag. - */ - public void setDebug(boolean debug) { - this.debug = debug; - } - - /** - * Is the suspend flag set? - * - * @return true if the suspend flag is set, false otherwise. - */ - public boolean isSuspend() { - return suspend; - } - /** * Set the suspend flag. - * + * * @param suspend the suspend flag. */ public void setSuspend(boolean suspend) { diff --git a/cli/cli/src/main/java/cloud/piranha/cli/Cli.java b/cli/cli/src/main/java/cloud/piranha/cli/Cli.java index 8aa9de746a..5ed9c56867 100644 --- a/cli/cli/src/main/java/cloud/piranha/cli/Cli.java +++ b/cli/cli/src/main/java/cloud/piranha/cli/Cli.java @@ -40,6 +40,12 @@ public class Cli { * Stores the arguments. */ private String[] arguments; + + /** + * Constructor. + */ + public Cli() { + } /** * Main method. diff --git a/core/api/src/main/java/cloud/piranha/core/api/WebApplicationResponse.java b/core/api/src/main/java/cloud/piranha/core/api/WebApplicationResponse.java index 858a4b58ea..5534d4a018 100644 --- a/core/api/src/main/java/cloud/piranha/core/api/WebApplicationResponse.java +++ b/core/api/src/main/java/cloud/piranha/core/api/WebApplicationResponse.java @@ -52,6 +52,8 @@ public interface WebApplicationResponse extends HttpServletResponse { /** * Get the content length. + * + * @return the content length. */ long getContentLength(); diff --git a/core/api/src/main/java/cloud/piranha/core/api/WebXmlFilter.java b/core/api/src/main/java/cloud/piranha/core/api/WebXmlFilter.java index d2d133fcd3..17ab255fba 100644 --- a/core/api/src/main/java/cloud/piranha/core/api/WebXmlFilter.java +++ b/core/api/src/main/java/cloud/piranha/core/api/WebXmlFilter.java @@ -62,6 +62,12 @@ public class WebXmlFilter { */ private String servletName; + /** + * Constructor. + */ + public WebXmlFilter() { + } + /** * Add init param. * diff --git a/core/api/src/main/java/cloud/piranha/core/api/WebXmlSecurityConstraint.java b/core/api/src/main/java/cloud/piranha/core/api/WebXmlSecurityConstraint.java index 710b9eb556..3e3c5fa648 100644 --- a/core/api/src/main/java/cloud/piranha/core/api/WebXmlSecurityConstraint.java +++ b/core/api/src/main/java/cloud/piranha/core/api/WebXmlSecurityConstraint.java @@ -74,6 +74,12 @@ public class WebXmlSecurityConstraint { */ private List webResourceCollections = new ArrayList<>(); + /** + * Constructor. + */ + public WebXmlSecurityConstraint() { + } + /** * Get the role names. * diff --git a/core/impl/src/main/java/cloud/piranha/core/impl/CookieParser.java b/core/impl/src/main/java/cloud/piranha/core/impl/CookieParser.java index 97e383d328..8a4587d76c 100644 --- a/core/impl/src/main/java/cloud/piranha/core/impl/CookieParser.java +++ b/core/impl/src/main/java/cloud/piranha/core/impl/CookieParser.java @@ -42,14 +42,17 @@ public class CookieParser { */ private static final String VERSION = "$Version="; - private CookieParser() {} + private CookieParser() { + } /** * Parse the Cookie header + * * @param cookieValues the Cookie header, without "Cookie:" * @return the {@link Cookie} array * @throws NullPointerException if cookieValues is null - * @throws IllegalArgumentException if some cookie contains a illegal character + * @throws IllegalArgumentException if some cookie contains a illegal + * character */ public static Cookie[] parse(String cookieValues) { Objects.requireNonNull(cookieValues); @@ -77,6 +80,7 @@ private static Cookie[] parseNetscape(String cookiesValue) { return cookieList.toArray(new Cookie[0]); } + @SuppressWarnings({"deprecation", "removal"}) private static Cookie[] parseRFC2109(String cookiesValue) { List cookieList = new ArrayList<>(); String[] cookieCandidates = cookiesValue.split("[;,]"); @@ -87,10 +91,10 @@ private static Cookie[] parseRFC2109(String cookiesValue) { String name = removeQuotes(values[0].trim()); String value = values.length == 2 ? removeQuotes(values[1].trim()) : null; - if (name.startsWith("$")) { - if (currentCookie == null) + if (currentCookie == null) { throw new IllegalArgumentException("Invalid Cookie"); + } if ("$Domain".equals(name)) { currentCookie.setDomain(value); diff --git a/core/impl/src/main/java/cloud/piranha/core/impl/DefaultHttpSessionManager.java b/core/impl/src/main/java/cloud/piranha/core/impl/DefaultHttpSessionManager.java index 04a29f5707..29d308b231 100644 --- a/core/impl/src/main/java/cloud/piranha/core/impl/DefaultHttpSessionManager.java +++ b/core/impl/src/main/java/cloud/piranha/core/impl/DefaultHttpSessionManager.java @@ -236,6 +236,7 @@ public String changeSessionId(HttpServletRequest request) { } @Override + @SuppressWarnings({"deprecation", "removal"}) public synchronized HttpSession createSession(HttpServletRequest request) { String sessionId = UUID.randomUUID().toString(); DefaultHttpSession session = new DefaultHttpSession(webApplication, sessionId, true); @@ -287,6 +288,7 @@ public String encodeURL(HttpServletResponse response, String url) { } @Override + @SuppressWarnings({"deprecation", "removal"}) public String getComment() { return comment; } @@ -380,6 +382,7 @@ protected void reapSessions() { } @Override + @SuppressWarnings({"deprecation", "removal"}) public void setComment(String comment) { if (webApplication.isInitialized()) { throw new IllegalStateException("You cannot call setComment once ServletContext is initialized"); diff --git a/core/impl/src/main/java/cloud/piranha/core/impl/DefaultWebApplicationOutputStream.java b/core/impl/src/main/java/cloud/piranha/core/impl/DefaultWebApplicationOutputStream.java index 4d260f81e4..20669868b6 100644 --- a/core/impl/src/main/java/cloud/piranha/core/impl/DefaultWebApplicationOutputStream.java +++ b/core/impl/src/main/java/cloud/piranha/core/impl/DefaultWebApplicationOutputStream.java @@ -328,6 +328,7 @@ private void writeContentType() throws IOException { * @param cookie the cookie. * @throws IOException when an I/O error occurs. */ + @SuppressWarnings({"deprecation", "removal"}) private void writeCookie(Cookie cookie) throws IOException { outputStream.write("Set-Cookie: ".getBytes()); outputStream.write(cookie.getName().getBytes()); diff --git a/core/impl/src/test/java/cloud/piranha/core/impl/CookieParserTest.java b/core/impl/src/test/java/cloud/piranha/core/impl/CookieParserTest.java index 3fbd4355c7..97354357c0 100644 --- a/core/impl/src/test/java/cloud/piranha/core/impl/CookieParserTest.java +++ b/core/impl/src/test/java/cloud/piranha/core/impl/CookieParserTest.java @@ -38,7 +38,7 @@ class CookieParserTest { /* - REVIEW FOR SERVLET 6 + TODO - REVIEW FOR SERVLET 6 @Nested class RFC2109 { @@ -75,6 +75,7 @@ void parseMultipleCookies() { */ @Nested + @SuppressWarnings({"deprecation", "removal"}) class Netscape { @Test void parseSingleCookie() { diff --git a/core/impl/src/test/java/cloud/piranha/core/impl/HttpSessionTest.java b/core/impl/src/test/java/cloud/piranha/core/impl/HttpSessionTest.java index e3644ebe98..9acc63b1fe 100644 --- a/core/impl/src/test/java/cloud/piranha/core/impl/HttpSessionTest.java +++ b/core/impl/src/test/java/cloud/piranha/core/impl/HttpSessionTest.java @@ -412,6 +412,7 @@ void testGetAttributeNames() { /** * Test getCookies method. */ + @SuppressWarnings({"deprecation", "removal"}) @Test void testGetCookies() { DefaultWebApplication webApplication = new DefaultWebApplication(); @@ -601,6 +602,7 @@ void testSetMaxInactiveInterval() { */ public static class TestSetCommentListener implements ServletContextListener { + @SuppressWarnings({"deprecation", "removal"}) @Override public void contextInitialized(ServletContextEvent event) { event.getServletContext().getSessionCookieConfig().setComment("MY COMMENT"); @@ -613,6 +615,7 @@ public void contextInitialized(ServletContextEvent event) { */ public static class TestSetCommentServlet extends HttpServlet { + @SuppressWarnings({"deprecation", "removal"}) @Override protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { @@ -821,6 +824,7 @@ void testIsSecure() { * * @throws Exception when a serious error occurs. */ + @SuppressWarnings({"deprecation", "removal"}) @Test void testSetComment() throws Exception { DefaultWebApplication webApplication = new DefaultWebApplication(); @@ -832,6 +836,7 @@ void testSetComment() throws Exception { /** * Test setComment. */ + @SuppressWarnings({"deprecation", "removal"}) @Test void testSetComment2() throws Exception { DefaultWebApplication webApplication = new DefaultWebApplication(); diff --git a/http/impl/src/main/java/cloud/piranha/http/impl/DefaultHttpServerProcessor.java b/http/impl/src/main/java/cloud/piranha/http/impl/DefaultHttpServerProcessor.java index 501a2f1ed9..b2042bfa68 100644 --- a/http/impl/src/main/java/cloud/piranha/http/impl/DefaultHttpServerProcessor.java +++ b/http/impl/src/main/java/cloud/piranha/http/impl/DefaultHttpServerProcessor.java @@ -67,6 +67,12 @@ public class DefaultHttpServerProcessor implements HttpServerProcessor { private static final String IO_ERROR_WRITING_RESPONSE = "An I/O error occurred while writing the response"; + /** + * Constructor. + */ + public DefaultHttpServerProcessor() { + } + @Override public HttpServerProcessorEndState process(HttpServerRequest request, HttpServerResponse response) { response.setStatus(200); diff --git a/http/tests/src/main/java/cloud/piranha/http/tests/HttpServerTest.java b/http/tests/src/main/java/cloud/piranha/http/tests/HttpServerTest.java index 38510c40c1..69f53dc593 100644 --- a/http/tests/src/main/java/cloud/piranha/http/tests/HttpServerTest.java +++ b/http/tests/src/main/java/cloud/piranha/http/tests/HttpServerTest.java @@ -84,6 +84,12 @@ public abstract class HttpServerTest { */ private static final String TEXT_PLAIN = "text/plain"; + /** + * Constructor. + */ + public HttpServerTest() { + } + /** * Create server with a port. * diff --git a/http/tests/src/main/java/cloud/piranha/http/tests/TestHttpServerProcessor.java b/http/tests/src/main/java/cloud/piranha/http/tests/TestHttpServerProcessor.java index 6d6d59b53b..021e0328be 100644 --- a/http/tests/src/main/java/cloud/piranha/http/tests/TestHttpServerProcessor.java +++ b/http/tests/src/main/java/cloud/piranha/http/tests/TestHttpServerProcessor.java @@ -69,6 +69,12 @@ public class TestHttpServerProcessor implements HttpServerProcessor { private static final String IO_ERROR_WRITING_RESPONSE = "An I/O error occurred while writing the response"; + /** + * Constructor. + */ + public TestHttpServerProcessor() { + } + @Override public HttpServerProcessorEndState process(HttpServerRequest request, HttpServerResponse response) { response.setStatus(200); diff --git a/maven/plugin/src/main/java/cloud/piranha/maven/plugin/BaseMojo.java b/maven/plugin/src/main/java/cloud/piranha/maven/plugin/BaseMojo.java index 742f036589..404fa9f2ec 100644 --- a/maven/plugin/src/main/java/cloud/piranha/maven/plugin/BaseMojo.java +++ b/maven/plugin/src/main/java/cloud/piranha/maven/plugin/BaseMojo.java @@ -139,11 +139,11 @@ public abstract class BaseMojo extends AbstractMojo { protected String warName; /** - * Default constructor. + * Constructor. */ public BaseMojo() { } - + /** * Convert a Maven groupId to a path snippet. * diff --git a/maven/plugin/src/main/java/cloud/piranha/maven/plugin/RunMojo.java b/maven/plugin/src/main/java/cloud/piranha/maven/plugin/RunMojo.java index 5eb8703dc4..6869cff724 100644 --- a/maven/plugin/src/main/java/cloud/piranha/maven/plugin/RunMojo.java +++ b/maven/plugin/src/main/java/cloud/piranha/maven/plugin/RunMojo.java @@ -45,11 +45,11 @@ public class RunMojo extends BaseMojo { /** - * Default constructor. + * Constructor. */ public RunMojo() { } - + @Override public void execute() throws MojoExecutionException { if (!skip) { diff --git a/maven/plugin/src/main/java/cloud/piranha/maven/plugin/StopMojo.java b/maven/plugin/src/main/java/cloud/piranha/maven/plugin/StopMojo.java index 4da6dc3fa2..4cce2e2bdd 100644 --- a/maven/plugin/src/main/java/cloud/piranha/maven/plugin/StopMojo.java +++ b/maven/plugin/src/main/java/cloud/piranha/maven/plugin/StopMojo.java @@ -59,11 +59,11 @@ public class StopMojo extends AbstractMojo { private boolean skip; /** - * Default constructor. + * Constructor. */ public StopMojo() { } - + @Override public void execute() throws MojoExecutionException { if (!skip) { @@ -71,14 +71,17 @@ public void execute() throws MojoExecutionException { /* * Get the PID from the PID file. */ - String pid = Files.readString((new File( - runtimeDirectory, "tmp/piranha.pid").toPath())); + File pidFile = new File(runtimeDirectory, "tmp/piranha.pid"); + String pid = ""; + + if (pidFile.exists()) { + pid = Files.readString(pidFile.toPath()); + } /* * Delete the PID file. */ - if (!Files.deleteIfExists(new File( - runtimeDirectory, "tmp/piranha.pid").toPath())) { + if (!Files.deleteIfExists(pidFile.toPath())) { try { TimeUnit.SECONDS.sleep(5); } catch (InterruptedException ex) {