[tomcat] branch 9.0.x updated: SpotBugs - remove unnecessary code

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[tomcat] branch 9.0.x updated: SpotBugs - remove unnecessary code

markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/9.0.x by this push:
     new 8d5846e  SpotBugs - remove unnecessary code
8d5846e is described below

commit 8d5846ecaaf316c1628315de9ba75a2a07881ac3
Author: Mark Thomas <[hidden email]>
AuthorDate: Fri Oct 16 11:32:04 2020 +0100

    SpotBugs - remove unnecessary code
---
 .../apache/tomcat/jdbc/test/TestGetConnection.java |  1 -
 .../el/TestImportHandlerStandardPackages.java      |  2 --
 test/javax/el/TestResourceBundleELResolver.java    |  1 -
 .../catalina/loader/TestWebappClassLoader.java     |  2 --
 test/org/apache/el/lang/TestELSupport.java         |  2 --
 .../apache/el/stream/TestCollectionOperations.java |  2 --
 .../jasper/compiler/TestTagPluginManager.java      |  2 --
 test/org/apache/tomcat/util/buf/TestUDecoder.java  | 24 ++++++++--------------
 8 files changed, 8 insertions(+), 28 deletions(-)

diff --git a/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestGetConnection.java b/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestGetConnection.java
index 480882e..7a58097 100644
--- a/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestGetConnection.java
+++ b/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestGetConnection.java
@@ -28,7 +28,6 @@ public class TestGetConnection extends DefaultTestCase {
     @Test
     public void testGetConnection() throws Exception {
         Connection con = this.datasource.getConnection();
-        Assert.assertTrue("Connection should implement javax.sql.PooledConnection",con instanceof PooledConnection);
         Connection actual = ((PooledConnection)con).getConnection();
         Assert.assertNotNull("Connection delegate should not be null.",actual);
         System.out.println("Actual connection:"+actual.getClass().getName());
diff --git a/test/javax/el/TestImportHandlerStandardPackages.java b/test/javax/el/TestImportHandlerStandardPackages.java
index 79972df..660f665 100644
--- a/test/javax/el/TestImportHandlerStandardPackages.java
+++ b/test/javax/el/TestImportHandlerStandardPackages.java
@@ -42,8 +42,6 @@ public class TestImportHandlerStandardPackages {
         f.setAccessible(true);
         Object obj = f.get(null);
 
-        Assert.assertTrue("Not Map", obj instanceof Map);
-
         @SuppressWarnings("unchecked")
         Map<String,Set<String>> standardPackageName = (Map<String, Set<String>>) obj;
 
diff --git a/test/javax/el/TestResourceBundleELResolver.java b/test/javax/el/TestResourceBundleELResolver.java
index 5acf029..2dec8a4 100644
--- a/test/javax/el/TestResourceBundleELResolver.java
+++ b/test/javax/el/TestResourceBundleELResolver.java
@@ -52,7 +52,6 @@ public class TestResourceBundleELResolver {
 
         // Check that the method expression does return the keys
         Object result2 = me.invoke(context, null);
-        Assert.assertTrue(result2 instanceof Enumeration);
         @SuppressWarnings("unchecked")
         Enumeration<String> e = (Enumeration<String>) result2;
 
diff --git a/test/org/apache/catalina/loader/TestWebappClassLoader.java b/test/org/apache/catalina/loader/TestWebappClassLoader.java
index 3bba4cc..a81d4c6 100644
--- a/test/org/apache/catalina/loader/TestWebappClassLoader.java
+++ b/test/org/apache/catalina/loader/TestWebappClassLoader.java
@@ -48,8 +48,6 @@ public class TestWebappClassLoader extends TomcatBaseTest {
 
         ClassLoader cl = ctx.getLoader().getClassLoader();
 
-        Assert.assertTrue(cl instanceof URLClassLoader);
-
         try (URLClassLoader ucl = (URLClassLoader) cl) {
             URL[] urls = ucl.getURLs();
             Assert.assertEquals(expected.length, urls.length);
diff --git a/test/org/apache/el/lang/TestELSupport.java b/test/org/apache/el/lang/TestELSupport.java
index 3276aff..f7f8a26 100644
--- a/test/org/apache/el/lang/TestELSupport.java
+++ b/test/org/apache/el/lang/TestELSupport.java
@@ -215,7 +215,6 @@ public class TestELSupport {
         PropertyEditorManager.registerEditor(TesterType.class, TesterTypeEditorNoError.class);
         Object result = ELManager.getExpressionFactory().coerceToType(
                 "Foo", TesterType.class);
-        Assert.assertTrue(result instanceof TesterType);
         Assert.assertEquals("Foo", ((TesterType) result).getValue());
     }
 
@@ -224,7 +223,6 @@ public class TestELSupport {
         PropertyEditorManager.registerEditor(TesterType.class, TesterTypeEditorError.class);
         Object result = ELManager.getExpressionFactory().coerceToType(
                 "Foo", TesterType.class);
-        Assert.assertTrue(result instanceof TesterType);
         Assert.assertEquals("Foo", ((TesterType) result).getValue());
     }
 
diff --git a/test/org/apache/el/stream/TestCollectionOperations.java b/test/org/apache/el/stream/TestCollectionOperations.java
index a0a7de3..d204043 100644
--- a/test/org/apache/el/stream/TestCollectionOperations.java
+++ b/test/org/apache/el/stream/TestCollectionOperations.java
@@ -123,8 +123,6 @@ public class TestCollectionOperations {
                 "beans.stream().filter(b->b.valLong > 1).map(b->[b.name, b.valLong]).toList()",
                 List.class);
 
-        Assert.assertTrue(result instanceof List);
-
         @SuppressWarnings("unchecked")
         List<List<Object>> list = (List<List<Object>>) result;
 
diff --git a/test/org/apache/jasper/compiler/TestTagPluginManager.java b/test/org/apache/jasper/compiler/TestTagPluginManager.java
index 3e3b000..8e91196 100644
--- a/test/org/apache/jasper/compiler/TestTagPluginManager.java
+++ b/test/org/apache/jasper/compiler/TestTagPluginManager.java
@@ -56,7 +56,6 @@ public class TestTagPluginManager extends TomcatBaseTest {
 
         Node n = nodes.getNode(0);
         Assert.assertNotNull(n);
-        Assert.assertTrue(n instanceof Node.CustomTag);
 
         Node.CustomTag t = (Node.CustomTag)n;
         Assert.assertNotNull(t.getAtSTag());
@@ -64,7 +63,6 @@ public class TestTagPluginManager extends TomcatBaseTest {
         Node.Nodes sTag = c.getAtSTag();
         Node scriptlet = sTag.getNode(0);
         Assert.assertNotNull(scriptlet);
-        Assert.assertTrue(scriptlet instanceof Node.Scriptlet);
         Node.Scriptlet s = (Node.Scriptlet)scriptlet;
         Assert.assertEquals("//Just a comment", s.getText());
     }
diff --git a/test/org/apache/tomcat/util/buf/TestUDecoder.java b/test/org/apache/tomcat/util/buf/TestUDecoder.java
index f3957b9..b2ca73d 100644
--- a/test/org/apache/tomcat/util/buf/TestUDecoder.java
+++ b/test/org/apache/tomcat/util/buf/TestUDecoder.java
@@ -25,25 +25,17 @@ import org.junit.Test;
 
 public class TestUDecoder {
 
-    @Test
-    public void testURLDecodeStringInvalid() {
+    @Test(expected = IllegalArgumentException.class)
+    public void testURLDecodeStringInvalid01() {
         // %n rather than %nn should throw an IAE according to the Javadoc
-        Exception exception = null;
-        try {
-            UDecoder.URLDecode("%5xxxxx", StandardCharsets.UTF_8);
-        } catch (Exception e) {
-            exception = e;
-        }
-        Assert.assertTrue(exception instanceof IllegalArgumentException);
+        UDecoder.URLDecode("%5xxxxx", StandardCharsets.UTF_8);
+    }
 
+
+    @Test(expected = IllegalArgumentException.class)
+    public void testURLDecodeStringInvalid02() {
         // Edge case trying to trigger ArrayIndexOutOfBoundsException
-        exception = null;
-        try {
-            UDecoder.URLDecode("%5", StandardCharsets.UTF_8);
-        } catch (Exception e) {
-            exception = e;
-        }
-        Assert.assertTrue(exception instanceof IllegalArgumentException);
+        UDecoder.URLDecode("%5", StandardCharsets.UTF_8);
     }
 
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]