You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2019/11/13 18:13:02 UTC
[tomcat] branch master updated: Fix SpotBugs warnings
This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/master by this push:
new 35e4aaa Fix SpotBugs warnings
35e4aaa is described below
commit 35e4aaa02b2587a77d303e8e46fda2ba5ccb835e
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Wed Nov 13 17:59:04 2019 +0000
Fix SpotBugs warnings
---
.../org/apache/catalina/startup/ContextConfig.java | 2 +-
.../apache/tomcat/buildutil/translate/Utils.java | 6 ++-
res/findbugs/filter-false-positives.xml | 62 +++++++++++++++++++++-
.../apache/catalina/core/TestAsyncContextImpl.java | 16 +++---
4 files changed, 75 insertions(+), 11 deletions(-)
diff --git a/java/org/apache/catalina/startup/ContextConfig.java b/java/org/apache/catalina/startup/ContextConfig.java
index c35c354..39fb25d 100644
--- a/java/org/apache/catalina/startup/ContextConfig.java
+++ b/java/org/apache/catalina/startup/ContextConfig.java
@@ -2692,7 +2692,7 @@ public class ContextConfig implements LifecycleListener {
@Override
public void lifecycleEvent(LifecycleEvent event) {
- if (event.getType() == Lifecycle.AFTER_DESTROY_EVENT) {
+ if (Lifecycle.AFTER_DESTROY_EVENT.equals(event.getType())) {
Host host = (Host) event.getSource();
hostWebXmlCache.remove(host);
}
diff --git a/java/org/apache/tomcat/buildutil/translate/Utils.java b/java/org/apache/tomcat/buildutil/translate/Utils.java
index 8b69c79..5eb015f 100644
--- a/java/org/apache/tomcat/buildutil/translate/Utils.java
+++ b/java/org/apache/tomcat/buildutil/translate/Utils.java
@@ -78,7 +78,11 @@ public class Utils {
static void processDirectory(File root, File dir, Map<String,Properties> translations) throws IOException {
- for (File f : dir.listFiles()) {
+ File[] files = dir.listFiles();
+ if (files == null) {
+ throw new IllegalArgumentException("Not a directory [" + dir.getAbsolutePath() + "]");
+ }
+ for (File f : files) {
if (f.isDirectory()) {
processDirectory(root, f, translations);
} else if (f.isFile()) {
diff --git a/res/findbugs/filter-false-positives.xml b/res/findbugs/filter-false-positives.xml
index 1c290b2..7fcc6bd 100644
--- a/res/findbugs/filter-false-positives.xml
+++ b/res/findbugs/filter-false-positives.xml
@@ -836,6 +836,18 @@
</Or>
</Match>
<Match>
+ <!-- Monitor is used for a single condition. -->
+ <Class name="org.apache.coyote.http2.WindowAllocationManager" />
+ <Method name="notify" />
+ <Bug pattern="NO_NOTIFY_NOT_NOTIFYALL" />
+ </Match>
+ <Match>
+ <!-- Monitor is used for a single condition. -->
+ <Class name="org.apache.coyote.http2.WindowAllocationManager" />
+ <Method name="waitFor" />
+ <Bug pattern="WA_NOT_IN_LOOP" />
+ </Match>
+ <Match>
<!-- Returning null is required by the EL specification -->
<Class name="org.apache.el.lang.ELSupport" />
<Method name="coerceToBoolean"/>
@@ -1389,6 +1401,13 @@
<Bug code="ML" />
</Match>
<Match>
+ <!-- Sync is on closed to ensure that actions taken because the socket -->
+ <!-- open remain valid until the action is completed. -->
+ <Class name="org.apache.tomcat.util.net.AprEndpoint$AprSocketWrapper"/>
+ <Field name="closed"/>
+ <Bug pattern="JLM_JSR166_UTILCONCURRENT_MONITORENTER"/>
+ </Match>
+ <Match>
<!-- Return value is ignored at this point but logic further up call -->
<!-- stack will ensure that a SocketTimeoutException is thrown -->
<Class name="org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper"/>
@@ -1440,6 +1459,21 @@
<Bug code="SF" />
</Match>
<Match>
+ <!-- Single condition so fine -->
+ <Class name="org.apache.tomcat.util.net.SocketWrapperBase" />
+ <Method name="vectoredOperation"/>
+ <Bug pattern="WA_NOT_IN_LOOP" />
+ </Match>
+ <Match>
+ <!-- Single condition so notify is fine -->
+ <Class name="org.apache.tomcat.util.net.SocketWrapperBase$VectoredIOCompletionHandler" />
+ <Or>
+ <Method name="completed"/>
+ <Method name="failed"/>
+ </Or>
+ <Bug pattern="NO_NOTIFY_NOT_NOTIFYALL" />
+ </Match>
+ <Match>
<!-- Stream will be closed -->
<Class name="org.apache.tomcat.util.net.jsse.PEMFile" />
<Method name="<init>" />
@@ -1552,9 +1586,17 @@
<Bug pattern="DLS_DEAD_LOCAL_STORE"/>
</Match>
<Match>
+ <!-- Name is consistent in context -->
+ <Class name="javax.servlet.http.TestHttpServletResponseSendError$ErrorServletStaticException" />
+ <Bug pattern="NM_CLASS_NOT_EXCEPTION"/>
+ </Match>
+ <Match>
<!-- Code is intentionally unused -->
<Class name="org.apache.catalina.authenticator.TestBasicAuthParser"/>
- <Method name="testAuthMethodBadMethod"/>
+ <Or>
+ <Method name="testAuthMethodBadMethod"/>
+ <Method name="testBadBase64Char"/>
+ </Or>
<Bug pattern="DLS_DEAD_LOCAL_STORE"/>
</Match>
<Match>
@@ -1606,11 +1648,23 @@
</Match>
<Match>
<!-- Deliberate hack for the purposes of the test -->
+ <Class name="org.apache.catalina.core.TestAsyncContextImpl$AsyncIoEndServlet"/>
+ <Field name="asyncIoEndWriteListener"/>
+ <Bug pattern="MSF_MUTABLE_SERVLET_FIELD"/>
+ </Match>
+ <Match>
+ <!-- Deliberate hack for the purposes of the test -->
<Class name="org.apache.catalina.core.TestAsyncContextImpl$AsyncISEServlet"/>
<Field name="asyncContext"/>
<Bug pattern="MSF_MUTABLE_SERVLET_FIELD"/>
</Match>
<Match>
+ <!-- Deliberate use of run() for the purposes of the test -->
+ <Class name="org.apache.catalina.core.TestAsyncContextStateChanges$AsyncServlet"/>
+ <Method name="doGet"/>
+ <Bug pattern="RU_INVOKE_RUN"/>
+ </Match>
+ <Match>
<!-- Hard-coded absolute path is intentional -->
<Class name="org.apache.catalina.core.TestStandardContext"/>
<Method name="testBug57556b"/>
@@ -1688,6 +1742,12 @@
<Bug pattern="ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD"/>
</Match>
<Match>
+ <!-- Test code - array is safe -->
+ <Class name="org.apache.catalina.startup.TomcatBaseTest"/>
+ <Field name="booleans"/>
+ <Bug pattern="MS_MUTABLE_ARRAY"/>
+ </Match>
+ <Match>
<Class name="org.apache.catalina.tribes.demos.EchoRpcTest" />
<Method name="run"/>
<Bug code="REC" />
diff --git a/test/org/apache/catalina/core/TestAsyncContextImpl.java b/test/org/apache/catalina/core/TestAsyncContextImpl.java
index 56e86ae..ea156ba 100644
--- a/test/org/apache/catalina/core/TestAsyncContextImpl.java
+++ b/test/org/apache/catalina/core/TestAsyncContextImpl.java
@@ -564,7 +564,7 @@ public class TestAsyncContextImpl extends TomcatBaseTest {
private static final long serialVersionUID = 1L;
private final Boolean completeOnTimeout;
- private final TrackingListener trackingListener;
+ private final transient TrackingListener trackingListener;
public static final long ASYNC_TIMEOUT = 100;
@@ -694,7 +694,7 @@ public class TestAsyncContextImpl extends TomcatBaseTest {
private static final long serialVersionUID = 1L;
private static final String ITER_PARAM = "iter";
private static final String DISPATCH_CHECK = "check";
- private final TrackingListener trackingListener;
+ private final transient TrackingListener trackingListener;
public DispatchingServlet(boolean addTrackingListener,
boolean completeOnError) {
@@ -1905,7 +1905,7 @@ public class TestAsyncContextImpl extends TomcatBaseTest {
private static final long serialVersionUID = 1L;
- private final TrackingListener trackingListener = new TrackingListener(true, false, "/async");
+ private final transient TrackingListener trackingListener = new TrackingListener(true, false, "/async");
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
@@ -2756,7 +2756,7 @@ public class TestAsyncContextImpl extends TomcatBaseTest {
private final boolean useThread;
private final boolean useComplete;
- private AsyncIoEndWriteListener asyncIoEndWriteListener;
+ private transient AsyncIoEndWriteListener asyncIoEndWriteListener;
public AsyncIoEndServlet(boolean useThread, boolean useComplete) {
this.useThread = useThread;
@@ -2775,7 +2775,7 @@ public class TestAsyncContextImpl extends TomcatBaseTest {
}
AsyncContext ac = req.startAsync();
ServletOutputStream sos = resp.getOutputStream();
- asyncIoEndWriteListener= new AsyncIoEndWriteListener(ac, useThread, useComplete);
+ asyncIoEndWriteListener = new AsyncIoEndWriteListener(ac, useThread, useComplete);
sos.setWriteListener(asyncIoEndWriteListener);
}
@@ -2930,9 +2930,9 @@ public class TestAsyncContextImpl extends TomcatBaseTest {
private static final long serialVersionUID = 1L;
- private final CountDownLatch doGetLatch;
- private final CountDownLatch clientCloseLatch;
- private final CountDownLatch threadCompleteLatch;
+ private final transient CountDownLatch doGetLatch;
+ private final transient CountDownLatch clientCloseLatch;
+ private final transient CountDownLatch threadCompleteLatch;
private final AtomicBoolean ise;
public Bug63816Servlet(CountDownLatch doGetLatch, CountDownLatch clientCloseLatch,
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org