Author: markt
Date: Fri Oct 13 16:50:39 2017
New Revision: 1812151
URL: http://svn.apache.org/viewvc?rev=1812151&view=rev
Log:
Fix remaining SpotBugs failures in the test code when the rank is set to 16
(the maximum rank is 20 so there are still quite a few other issues to look at)
Modified:
tomcat/trunk/res/findbugs/filter-false-positives.xml
tomcat/trunk/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java
tomcat/trunk/test/org/apache/catalina/startup/SimpleHttpClient.java
tomcat/trunk/test/org/apache/juli/TestFileHandler.java
Modified: tomcat/trunk/res/findbugs/filter-false-positives.xml
URL:
http://svn.apache.org/viewvc/tomcat/trunk/res/findbugs/filter-false-positives.xml?rev=1812151&r1=1812150&r2=1812151&view=diff
==============================================================================
--- tomcat/trunk/res/findbugs/filter-false-positives.xml (original)
+++ tomcat/trunk/res/findbugs/filter-false-positives.xml Fri Oct 13 16:50:39
2017
@@ -1183,6 +1183,12 @@
<Bug pattern="DLS_DEAD_LOCAL_STORE"/>
</Match>
<Match>
+ <!-- Result is negated to compare result when order is reversed -->
+ <Class name="org.apache.el.TestELEvaluation" />
+ <Method name="compareBoth" />
+ <Bug pattern="RV_NEGATING_RESULT_OF_COMPARETO" />
+ </Match>
+ <Match>
<!-- Use of statics is unavoidable in all cases -->
<!-- Better to use it consistently rather than only where necessary -->
<Class name="org.apache.tomcat.jdbc.pool.interceptor.TestInterceptor" />
@@ -1229,6 +1235,12 @@
<Bug pattern="XSS_REQUEST_PARAMETER_TO_SERVLET_WRITER"/>
</Match>
<Match>
+ <!-- No performance issue as there is no DNS resolution -->
+ <Class name="org.apache.tomcat.util.bcel.TesterPerformance" />
+ <Method name="testClassParserPerformance" />
+ <Bug pattern="DMI_COLLECTION_OF_URLS" />
+ </Match>
+ <Match>
<Class name="org.apache.tomcat.util.net.TestSsl" />
<Or>
<Method name="testRenegotiateFail" />
Modified:
tomcat/trunk/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java?rev=1812151&r1=1812150&r2=1812151&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java
(original)
+++ tomcat/trunk/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java
Fri Oct 13 16:50:39 2017
@@ -19,6 +19,7 @@ package org.apache.catalina.nonblocking;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.io.Serializable;
import java.net.HttpURLConnection;
import java.net.Socket;
import java.net.URL;
@@ -154,7 +155,13 @@ public class TestNonBlockingAPI extends
"Host: localhost:" + getPort() + "\r\n" +
"\r\n").getBytes(StandardCharsets.ISO_8859_1));
os.flush();
- is.read(buffer);
+ // Make sure the entire response has been read.
+ int read = is.read(buffer);
+ // The response should end with CRLFCRLF
+ Assert.assertEquals(buffer[read - 4], '\r');
+ Assert.assertEquals(buffer[read - 3], '\n');
+ Assert.assertEquals(buffer[read - 2], '\r');
+ Assert.assertEquals(buffer[read - 1], '\n');
}
os.write(("GET / HTTP/1.1\r\n" +
"Host: localhost:" + getPort() + "\r\n" +
@@ -843,7 +850,7 @@ public class TestNonBlockingAPI extends
private static final class DelayedNBWriteServlet extends TesterServlet {
private static final long serialVersionUID = 1L;
private final Set<Emitter> emitters = new HashSet<>();
- private final CountDownLatch latch;
+ private transient final CountDownLatch latch;
public DelayedNBWriteServlet(CountDownLatch latch) {
this.latch = latch;
@@ -870,8 +877,11 @@ public class TestNonBlockingAPI extends
}
- private static final class Emitter {
- private final AsyncContext ctx;
+ private static final class Emitter implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ private transient final AsyncContext ctx;
Emitter(AsyncContext ctx) {
this.ctx = ctx;
Modified: tomcat/trunk/test/org/apache/catalina/startup/SimpleHttpClient.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/startup/SimpleHttpClient.java?rev=1812151&r1=1812150&r2=1812151&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/startup/SimpleHttpClient.java
(original)
+++ tomcat/trunk/test/org/apache/catalina/startup/SimpleHttpClient.java Fri Oct
13 16:50:39 2017
@@ -33,6 +33,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
+import org.junit.Assert;
+
/**
* Simple client for unit testing. It isn't robust, it isn't secure and
* should not be used as the basis for production code. Its only purpose
@@ -298,7 +300,8 @@ public abstract class SimpleHttpClient {
if (wantBody) {
if (useContentLength && (contentLength > -1)) {
char[] body = new char[contentLength];
- reader.read(body);
+ int read = reader.read(body);
+ Assert.assertEquals(contentLength, read);
builder.append(body);
}
else {
Modified: tomcat/trunk/test/org/apache/juli/TestFileHandler.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/juli/TestFileHandler.java?rev=1812151&r1=1812150&r2=1812151&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/juli/TestFileHandler.java (original)
+++ tomcat/trunk/test/org/apache/juli/TestFileHandler.java Fri Oct 13 16:50:39
2017
@@ -70,9 +70,9 @@ public class TestFileHandler {
File[] files = logsDir.listFiles();
if (files != null) {
for (File file : files) {
- file.delete();
+ Assert.assertTrue("Failed to create [" + file + "]",
file.delete());
}
- logsDir.delete();
+ Assert.assertTrue("Failed to create [" + logsDir + "]",
logsDir.delete());
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]