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

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

commit 46a7a536e10efcf4d0331353f52f8579ca6da819
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Fri May 31 21:49:49 2019 +0100

    Align checkstyle config with 8.5.x and fix resulting warnings
    
    All warnings were "Avoid nested blocks". Took the opportunity to
    back-port additional clean-up such as improving Javadoc and removing
    unecessary null checks when comparing 7.0.x to 8.5.x.
---
 java/org/apache/catalina/ha/ClusterRuleSet.java    | 148 ++++++++++-----------
 .../apache/catalina/manager/util/SessionUtils.java |  98 +++++++-------
 java/org/apache/catalina/util/Base64.java          |  40 +++---
 res/checkstyle/checkstyle.xml                      |  26 ++--
 .../apache/catalina/filters/TestExpiresFilter.java | 144 +++++++++-----------
 test/org/apache/juli/TestDateFormatCache.java      |  12 +-
 6 files changed, 216 insertions(+), 252 deletions(-)

diff --git a/java/org/apache/catalina/ha/ClusterRuleSet.java 
b/java/org/apache/catalina/ha/ClusterRuleSet.java
index 0335bcc..088a106 100644
--- a/java/org/apache/catalina/ha/ClusterRuleSet.java
+++ b/java/org/apache/catalina/ha/ClusterRuleSet.java
@@ -110,80 +110,80 @@ public class ClusterRuleSet extends RuleSetBase {
 
 
         String channelPrefix = prefix + "Channel/";
-        { //channel properties
-            digester.addObjectCreate(channelPrefix + "Membership",
-                                     null, // MUST be specified in the element
-                                     "className");
-            digester.addSetProperties(channelPrefix + "Membership");
-            digester.addSetNext(channelPrefix + "Membership",
-                                "setMembershipService",
-                                
"org.apache.catalina.tribes.MembershipService");
-
-            digester.addObjectCreate(channelPrefix + "MembershipListener",
-                                     null, // MUST be specified in the element
-                                     "className");
-            digester.addSetProperties(channelPrefix + "MembershipListener");
-            digester.addSetNext(channelPrefix + "MembershipListener",
-                                "addMembershipListener",
-                                
"org.apache.catalina.tribes.MembershipListener");
-
-            digester.addObjectCreate(channelPrefix + "Sender",
-                                     null, // MUST be specified in the element
-                                     "className");
-            digester.addSetProperties(channelPrefix + "Sender");
-            digester.addSetNext(channelPrefix + "Sender",
-                                "setChannelSender",
-                                "org.apache.catalina.tribes.ChannelSender");
-
-            digester.addObjectCreate(channelPrefix + "Sender/Transport",
-                                     null, // MUST be specified in the element
-                                     "className");
-            digester.addSetProperties(channelPrefix + "Sender/Transport");
-            digester.addSetNext(channelPrefix + "Sender/Transport",
-                                "setTransport",
-                                
"org.apache.catalina.tribes.transport.MultiPointSender");
-
-
-            digester.addObjectCreate(channelPrefix + "Receiver",
-                                     null, // MUST be specified in the element
-                                     "className");
-            digester.addSetProperties(channelPrefix + "Receiver");
-            digester.addSetNext(channelPrefix + "Receiver",
-                                "setChannelReceiver",
-                                "org.apache.catalina.tribes.ChannelReceiver");
-
-            digester.addObjectCreate(channelPrefix + "Interceptor",
-                                     null, // MUST be specified in the element
-                                     "className");
-            digester.addSetProperties(channelPrefix + "Interceptor");
-            digester.addSetNext(channelPrefix + "Interceptor",
-                                "addInterceptor",
-                                
"org.apache.catalina.tribes.ChannelInterceptor");
-
-            digester.addObjectCreate(channelPrefix + "Interceptor/LocalMember",
-                                     null, // MUST be specified in the element
-                                     "className");
-            digester.addSetProperties(channelPrefix + 
"Interceptor/LocalMember");
-            digester.addSetNext(channelPrefix + "Interceptor/LocalMember",
-                                "setLocalMember",
-                                "org.apache.catalina.tribes.Member");
-
-            digester.addObjectCreate(channelPrefix + "Interceptor/Member",
-                                     null, // MUST be specified in the element
-                                     "className");
-            digester.addSetProperties(channelPrefix + "Interceptor/Member");
-            digester.addSetNext(channelPrefix + "Interceptor/Member",
-                                "addStaticMember",
-                                "org.apache.catalina.tribes.Member");
-
-            digester.addObjectCreate(channelPrefix + "ChannelListener",
-                                     null, // MUST be specified in the element
-                                     "className");
-            digester.addSetProperties(channelPrefix + "ChannelListener");
-            digester.addSetNext(channelPrefix + "ChannelListener",
-                                "addChannelListener",
-                                "org.apache.catalina.tribes.ChannelListener");
-        }
+
+        //channel properties
+        digester.addObjectCreate(channelPrefix + "Membership",
+                                 null, // MUST be specified in the element
+                                 "className");
+        digester.addSetProperties(channelPrefix + "Membership");
+        digester.addSetNext(channelPrefix + "Membership",
+                            "setMembershipService",
+                            "org.apache.catalina.tribes.MembershipService");
+
+        digester.addObjectCreate(channelPrefix + "MembershipListener",
+                                 null, // MUST be specified in the element
+                                 "className");
+        digester.addSetProperties(channelPrefix + "MembershipListener");
+        digester.addSetNext(channelPrefix + "MembershipListener",
+                            "addMembershipListener",
+                            "org.apache.catalina.tribes.MembershipListener");
+
+        digester.addObjectCreate(channelPrefix + "Sender",
+                                 null, // MUST be specified in the element
+                                 "className");
+        digester.addSetProperties(channelPrefix + "Sender");
+        digester.addSetNext(channelPrefix + "Sender",
+                            "setChannelSender",
+                            "org.apache.catalina.tribes.ChannelSender");
+
+        digester.addObjectCreate(channelPrefix + "Sender/Transport",
+                                 null, // MUST be specified in the element
+                                 "className");
+        digester.addSetProperties(channelPrefix + "Sender/Transport");
+        digester.addSetNext(channelPrefix + "Sender/Transport",
+                            "setTransport",
+                            
"org.apache.catalina.tribes.transport.MultiPointSender");
+
+
+        digester.addObjectCreate(channelPrefix + "Receiver",
+                                 null, // MUST be specified in the element
+                                 "className");
+        digester.addSetProperties(channelPrefix + "Receiver");
+        digester.addSetNext(channelPrefix + "Receiver",
+                            "setChannelReceiver",
+                            "org.apache.catalina.tribes.ChannelReceiver");
+
+        digester.addObjectCreate(channelPrefix + "Interceptor",
+                                 null, // MUST be specified in the element
+                                 "className");
+        digester.addSetProperties(channelPrefix + "Interceptor");
+        digester.addSetNext(channelPrefix + "Interceptor",
+                            "addInterceptor",
+                            "org.apache.catalina.tribes.ChannelInterceptor");
+
+        digester.addObjectCreate(channelPrefix + "Interceptor/LocalMember",
+                                 null, // MUST be specified in the element
+                                 "className");
+        digester.addSetProperties(channelPrefix + "Interceptor/LocalMember");
+        digester.addSetNext(channelPrefix + "Interceptor/LocalMember",
+                            "setLocalMember",
+                            "org.apache.catalina.tribes.Member");
+
+        digester.addObjectCreate(channelPrefix + "Interceptor/Member",
+                                 null, // MUST be specified in the element
+                                 "className");
+        digester.addSetProperties(channelPrefix + "Interceptor/Member");
+        digester.addSetNext(channelPrefix + "Interceptor/Member",
+                            "addStaticMember",
+                            "org.apache.catalina.tribes.Member");
+
+        digester.addObjectCreate(channelPrefix + "ChannelListener",
+                                 null, // MUST be specified in the element
+                                 "className");
+        digester.addSetProperties(channelPrefix + "ChannelListener");
+        digester.addSetNext(channelPrefix + "ChannelListener",
+                            "addChannelListener",
+                            "org.apache.catalina.tribes.ChannelListener");
 
         digester.addObjectCreate(prefix + "Valve",
                                  null, // MUST be specified in the element
diff --git a/java/org/apache/catalina/manager/util/SessionUtils.java 
b/java/org/apache/catalina/manager/util/SessionUtils.java
index 7d790ed..74865e0 100644
--- a/java/org/apache/catalina/manager/util/SessionUtils.java
+++ b/java/org/apache/catalina/manager/util/SessionUtils.java
@@ -71,8 +71,8 @@ public class SessionUtils {
      * Try to get user locale from the session, if possible.
      * IMPLEMENTATION NOTE: this method has explicit support for Tapestry 3, 
Struts 1.x and Spring
      * JSF check the browser meta tag "accept languages" to choose what 
language to display.
-     * @param in_session
-     * @return String
+     * @param in_session The session
+     * @return the locale
      */
     public static Locale guessLocaleFromSession(final Session in_session) {
         return guessLocaleFromSession(in_session.getSession());
@@ -87,17 +87,17 @@ public class SessionUtils {
             // First search "known locations"
             for (int i = 0; i < LOCALE_TEST_ATTRIBUTES.length; ++i) {
                 Object obj = 
in_session.getAttribute(LOCALE_TEST_ATTRIBUTES[i]);
-                if (null != obj && obj instanceof Locale) {
+                if (obj instanceof Locale) {
                     locale = (Locale) obj;
                     break;
                 }
                 obj = 
in_session.getAttribute(LOCALE_TEST_ATTRIBUTES[i].toLowerCase(Locale.ENGLISH));
-                if (null != obj && obj instanceof Locale) {
+                if (obj instanceof Locale) {
                     locale = (Locale) obj;
                     break;
                 }
                 obj = 
in_session.getAttribute(LOCALE_TEST_ATTRIBUTES[i].toUpperCase(Locale.ENGLISH));
-                if (null != obj && obj instanceof Locale) {
+                if (obj instanceof Locale) {
                     locale = (Locale) obj;
                     break;
                 }
@@ -109,31 +109,29 @@ public class SessionUtils {
 
             // Tapestry 3.0: Engine stored in session under 
"org.apache.tapestry.engine:" + config.getServletName()
             // TODO: Tapestry 4+
-            {
-                final List<Object> tapestryArray = new ArrayList<Object>();
-                for (Enumeration<String> enumeration = 
in_session.getAttributeNames(); enumeration.hasMoreElements();) {
-                    String name = enumeration.nextElement();
-                    if (name.indexOf("tapestry") > -1 && 
name.indexOf("engine") > -1 && null != in_session.getAttribute(name)) 
{//$NON-NLS-1$ //$NON-NLS-2$
-                        tapestryArray.add(in_session.getAttribute(name));
-                    }
+            final List<Object> tapestryArray = new ArrayList<Object>();
+            for (Enumeration<String> enumeration = 
in_session.getAttributeNames(); enumeration.hasMoreElements();) {
+                String name = enumeration.nextElement();
+                if (name.indexOf("tapestry") > -1 && name.indexOf("engine") > 
-1 && null != in_session.getAttribute(name)) {//$NON-NLS-1$ //$NON-NLS-2$
+                    tapestryArray.add(in_session.getAttribute(name));
                 }
-                if (tapestryArray.size() == 1) {
-                    // found a potential Engine! Let's call getLocale() on it.
-                    Object probableEngine = tapestryArray.get(0);
-                    if (null != probableEngine) {
-                        try {
-                            Method readMethod = 
probableEngine.getClass().getMethod("getLocale", (Class<?>[])null);//$NON-NLS-1$
-                            // Call the property getter and return the value
-                            Object possibleLocale = 
readMethod.invoke(probableEngine, (Object[]) null);
-                            if (null != possibleLocale && possibleLocale 
instanceof Locale) {
-                                locale = (Locale) possibleLocale;
-                            }
-                        } catch (Exception e) {
-                            Throwable t = ExceptionUtils
-                                    .unwrapInvocationTargetException(e);
-                            ExceptionUtils.handleThrowable(t);
-                            // stay silent
+            }
+            if (tapestryArray.size() == 1) {
+                // found a potential Engine! Let's call getLocale() on it.
+                Object probableEngine = tapestryArray.get(0);
+                if (null != probableEngine) {
+                    try {
+                        Method readMethod = 
probableEngine.getClass().getMethod("getLocale", (Class<?>[])null);//$NON-NLS-1$
+                        // Call the property getter and return the value
+                        Object possibleLocale = 
readMethod.invoke(probableEngine, (Object[]) null);
+                        if (possibleLocale instanceof Locale) {
+                            locale = (Locale) possibleLocale;
                         }
+                    } catch (Exception e) {
+                        Throwable t = ExceptionUtils
+                                .unwrapInvocationTargetException(e);
+                        ExceptionUtils.handleThrowable(t);
+                        // stay silent
                     }
                 }
             }
@@ -144,19 +142,17 @@ public class SessionUtils {
 
             // Last guess: iterate over all attributes, to find a Locale
             // If there is only one, consider it to be /the/ locale
-            {
-                final List<Object> localeArray = new ArrayList<Object>();
-                for (Enumeration<String> enumeration = 
in_session.getAttributeNames(); enumeration.hasMoreElements();) {
-                    String name = enumeration.nextElement();
-                    Object obj = in_session.getAttribute(name);
-                    if (null != obj && obj instanceof Locale) {
-                        localeArray.add(obj);
-                    }
-                }
-                if (localeArray.size() == 1) {
-                    locale = (Locale) localeArray.get(0);
+            final List<Object> localeArray = new ArrayList<Object>();
+            for (Enumeration<String> enumeration = 
in_session.getAttributeNames(); enumeration.hasMoreElements();) {
+                String name = enumeration.nextElement();
+                Object obj = in_session.getAttribute(name);
+                if (obj instanceof Locale) {
+                    localeArray.add(obj);
                 }
             }
+            if (localeArray.size() == 1) {
+                locale = (Locale) localeArray.get(0);
+            }
 
             return locale;
         } catch (IllegalStateException ise) {
@@ -167,8 +163,8 @@ public class SessionUtils {
 
     /**
      * Try to get user from the session, if possible.
-     * @param in_session
-     * @return Object
+     * @param in_session The session
+     * @return the user
      */
     public static Object guessUserFromSession(final Session in_session) {
         if (null == in_session) {
@@ -208,19 +204,17 @@ public class SessionUtils {
 
             // Last guess: iterate over all attributes, to find a 
java.security.Principal or javax.security.auth.Subject
             // If there is only one, consider it to be /the/ user
-            {
-                final List<Object> principalArray = new ArrayList<Object>();
-                for (Enumeration<String> enumeration = 
httpSession.getAttributeNames(); enumeration.hasMoreElements();) {
-                    String name = enumeration.nextElement();
-                    Object obj = httpSession.getAttribute(name);
-                    if (null != obj && (obj instanceof Principal || obj 
instanceof Subject)) {
-                        principalArray.add(obj);
-                    }
-                }
-                if (principalArray.size() == 1) {
-                    user = principalArray.get(0);
+            final List<Object> principalArray = new ArrayList<Object>();
+            for (Enumeration<String> enumeration = 
httpSession.getAttributeNames(); enumeration.hasMoreElements();) {
+                String name = enumeration.nextElement();
+                Object obj = httpSession.getAttribute(name);
+                if (obj instanceof Principal || obj instanceof Subject) {
+                    principalArray.add(obj);
                 }
             }
+            if (principalArray.size() == 1) {
+                user = principalArray.get(0);
+            }
 
             if (null != user) {
                 return user;
diff --git a/java/org/apache/catalina/util/Base64.java 
b/java/org/apache/catalina/util/Base64.java
index 666f505..0a19aa1 100644
--- a/java/org/apache/catalina/util/Base64.java
+++ b/java/org/apache/catalina/util/Base64.java
@@ -119,21 +119,19 @@ public final class  Base64
         int dataIndex = start;
         char[] decodedData = null;
 
+        // this sizes the output array properly - rlw
+        int lastData = end - start;
+        // ignore the '=' padding
+        while (base64Data[start+lastData-1] == PAD)
         {
-            // this sizes the output array properly - rlw
-            int lastData = end - start;
-            // ignore the '=' padding
-            while (base64Data[start+lastData-1] == PAD)
+            if (--lastData == 0)
             {
-                if (--lastData == 0)
-                {
-                    return;
-                }
+                return;
             }
-            decodedDataCC.allocate(lastData - numberQuadruple, -1);
-            decodedDataCC.setEnd(lastData - numberQuadruple);
-            decodedData = decodedDataCC.getBuffer();
         }
+        decodedDataCC.allocate(lastData - numberQuadruple, -1);
+        decodedDataCC.setEnd(lastData - numberQuadruple);
+        decodedData = decodedDataCC.getBuffer();
 
         for (int i = 0; i < numberQuadruple; i++)
         {
@@ -200,21 +198,19 @@ public final class  Base64
         int dataIndex = start;
         byte[] decodedData = null;
 
+        // this sizes the output array properly - rlw
+        int lastData = end - start;
+        // ignore the '=' padding
+        while (base64Data[start+lastData-1] == PAD)
         {
-            // this sizes the output array properly - rlw
-            int lastData = end - start;
-            // ignore the '=' padding
-            while (base64Data[start+lastData-1] == PAD)
+            if (--lastData == 0)
             {
-                if (--lastData == 0)
-                {
-                    return;
-                }
+                return;
             }
-            decodedDataBC.allocate(lastData - numberQuadruple, -1);
-            decodedDataBC.setEnd(lastData - numberQuadruple);
-            decodedData = decodedDataBC.getBuffer();
         }
+        decodedDataBC.allocate(lastData - numberQuadruple, -1);
+        decodedDataBC.setEnd(lastData - numberQuadruple);
+        decodedData = decodedDataBC.getBuffer();
 
         for (int i = 0; i < numberQuadruple; i++)
         {
diff --git a/res/checkstyle/checkstyle.xml b/res/checkstyle/checkstyle.xml
index da4b852..3bbcb43 100644
--- a/res/checkstyle/checkstyle.xml
+++ b/res/checkstyle/checkstyle.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0"?>
+<?xml version="1.0" encoding="UTF-8"?>
 <!--
   Licensed to the Apache Software Foundation (ASF) under one or more
   contributor license agreements.  See the NOTICE file distributed with
@@ -36,26 +36,27 @@
 
   <!-- Whitespace -->
   <module name="FileTabCharacter"/>
+  <module name="RegexpSingleline">
+    <!-- No trailing whitespace -->
+    <property name="format" value="\s+$"/>
+  </module>
 
   <module name="TreeWalker">
 
     <!-- Annotations -->
     <module name="AnnotationLocation"/>
-    <!-- 1 false positive, fixed in later Checkstyle release but can't upgrade
-         as it requires Java 7.
     <module name="AnnotationUseStyle"/>
-    -->
     <module name="MissingOverride"/>
     <module name="PackageAnnotation"/>
 
     <!-- Block Checks -->
-    <!--  ~60 errors
-    <module name="AvoidNestedBlocks"/>
-    -->
+    <module name="AvoidNestedBlocks">
+      <property name="allowInSwitchCase" value="true"/>
+    </module>
 
     <!-- Coding -->
     <module name="IllegalInstantiation"/>
-    
+
     <!-- Imports -->
     <module name="AvoidStarImport"/>
     <module name="AvoidStaticImport">
@@ -73,23 +74,20 @@
     </module>
     <module name="RedundantImport"/>
     <module name="UnusedImports"/>
-    
+
     <!--  Modifiers -->
     <module name="ModifierOrder"/>
     <!-- ~1750 errors
     <module name="RedundantModifier"/>
     -->
-    
+
     <!-- Whitespace -->
-    <!-- Can't handle HashMap<String,Class<?>[]>
-    
https://sourceforge.net/tracker/?func=detail&aid=3039718&group_id=29721&atid=397078
     <module name="GenericWhitespace"/>
-    -->
     <module name="EmptyForInitializerPad"/>
     <module name="EmptyForIteratorPad"/>
     <!--  ~ 1000 errors
     <module name="OperatorWrap">
-      <property name="option" value="oel"/>
+      <property name="option" value="eol"/>
     </module>
     -->
   </module>
diff --git a/test/org/apache/catalina/filters/TestExpiresFilter.java 
b/test/org/apache/catalina/filters/TestExpiresFilter.java
index 05dee16..8b7217d 100644
--- a/test/org/apache/catalina/filters/TestExpiresFilter.java
+++ b/test/org/apache/catalina/filters/TestExpiresFilter.java
@@ -79,108 +79,86 @@ public class TestExpiresFilter extends TomcatBaseTest {
         tomcat.start();
         try {
             // VERIFY EXCLUDED RESPONSE STATUS CODES
-            {
-                int[] excludedResponseStatusCodes = 
expiresFilter.getExcludedResponseStatusCodesAsInts();
-                Assert.assertEquals(2, excludedResponseStatusCodes.length);
-                Assert.assertEquals(304, excludedResponseStatusCodes[0]);
-                Assert.assertEquals(503, excludedResponseStatusCodes[1]);
-            }
+            int[] excludedResponseStatusCodes = 
expiresFilter.getExcludedResponseStatusCodesAsInts();
+            Assert.assertEquals(2, excludedResponseStatusCodes.length);
+            Assert.assertEquals(304, excludedResponseStatusCodes[0]);
+            Assert.assertEquals(503, excludedResponseStatusCodes[1]);
 
             // VERIFY DEFAULT CONFIGURATION
-            {
-                ExpiresConfiguration expiresConfiguration = 
expiresFilter.getDefaultExpiresConfiguration();
-                Assert.assertEquals(StartingPoint.ACCESS_TIME,
-                        expiresConfiguration.getStartingPoint());
-                Assert.assertEquals(1,
-                        expiresConfiguration.getDurations().size());
-                Assert.assertEquals(DurationUnit.MONTH,
-                        expiresConfiguration.getDurations().get(0).getUnit());
-                Assert.assertEquals(1, expiresConfiguration.getDurations().get(
-                        0).getAmount());
-            }
+            ExpiresConfiguration expiresConfigurationDefault =
+                    expiresFilter.getDefaultExpiresConfiguration();
+            Assert.assertEquals(StartingPoint.ACCESS_TIME,
+                    expiresConfigurationDefault.getStartingPoint());
+            Assert.assertEquals(1, 
expiresConfigurationDefault.getDurations().size());
+            Assert.assertEquals(DurationUnit.MONTH,
+                    
expiresConfigurationDefault.getDurations().get(0).getUnit());
+            Assert.assertEquals(1, 
expiresConfigurationDefault.getDurations().get(0).getAmount());
 
             // VERIFY TEXT/HTML
-            {
-                ExpiresConfiguration expiresConfiguration = 
expiresFilter.getExpiresConfigurationByContentType().get(
-                        "text/html");
-                Assert.assertEquals(StartingPoint.ACCESS_TIME,
-                        expiresConfiguration.getStartingPoint());
-
-                Assert.assertEquals(3,
-                        expiresConfiguration.getDurations().size());
-
-                Duration oneMonth = expiresConfiguration.getDurations().get(0);
-                Assert.assertEquals(DurationUnit.MONTH, oneMonth.getUnit());
-                Assert.assertEquals(1, oneMonth.getAmount());
-
-                Duration fifteenDays = expiresConfiguration.getDurations().get(
-                        1);
-                Assert.assertEquals(DurationUnit.DAY, fifteenDays.getUnit());
-                Assert.assertEquals(15, fifteenDays.getAmount());
-
-                Duration twoHours = expiresConfiguration.getDurations().get(2);
-                Assert.assertEquals(DurationUnit.HOUR, twoHours.getUnit());
-                Assert.assertEquals(2, twoHours.getAmount());
-            }
+            ExpiresConfiguration expiresConfigurationTextHtml =
+                    
expiresFilter.getExpiresConfigurationByContentType().get("text/html");
+            Assert.assertEquals(StartingPoint.ACCESS_TIME,
+                    expiresConfigurationTextHtml.getStartingPoint());
+
+            Assert.assertEquals(3, 
expiresConfigurationTextHtml.getDurations().size());
+
+            Duration oneMonth = 
expiresConfigurationTextHtml.getDurations().get(0);
+            Assert.assertEquals(DurationUnit.MONTH, oneMonth.getUnit());
+            Assert.assertEquals(1, oneMonth.getAmount());
+
+            Duration fifteenDays = 
expiresConfigurationTextHtml.getDurations().get(1);
+            Assert.assertEquals(DurationUnit.DAY, fifteenDays.getUnit());
+            Assert.assertEquals(15, fifteenDays.getAmount());
+
+            Duration twoHours = 
expiresConfigurationTextHtml.getDurations().get(2);
+            Assert.assertEquals(DurationUnit.HOUR, twoHours.getUnit());
+            Assert.assertEquals(2, twoHours.getAmount());
+
             // VERIFY IMAGE/GIF
-            {
-                ExpiresConfiguration expiresConfiguration = 
expiresFilter.getExpiresConfigurationByContentType().get(
-                        "image/gif");
-                Assert.assertEquals(StartingPoint.LAST_MODIFICATION_TIME,
-                        expiresConfiguration.getStartingPoint());
+            ExpiresConfiguration expiresConfigurationImageGif =
+                    
expiresFilter.getExpiresConfigurationByContentType().get("image/gif");
+            Assert.assertEquals(StartingPoint.LAST_MODIFICATION_TIME,
+                    expiresConfigurationImageGif.getStartingPoint());
 
-                Assert.assertEquals(2,
-                        expiresConfiguration.getDurations().size());
+            Assert.assertEquals(2, 
expiresConfigurationImageGif.getDurations().size());
 
-                Duration fiveHours = 
expiresConfiguration.getDurations().get(0);
-                Assert.assertEquals(DurationUnit.HOUR, fiveHours.getUnit());
-                Assert.assertEquals(5, fiveHours.getAmount());
+            Duration fiveHours = 
expiresConfigurationImageGif.getDurations().get(0);
+            Assert.assertEquals(DurationUnit.HOUR, fiveHours.getUnit());
+            Assert.assertEquals(5, fiveHours.getAmount());
 
-                Duration threeMinutes = 
expiresConfiguration.getDurations().get(
-                        1);
-                Assert.assertEquals(DurationUnit.MINUTE, 
threeMinutes.getUnit());
-                Assert.assertEquals(3, threeMinutes.getAmount());
+            Duration threeMinutes = 
expiresConfigurationImageGif.getDurations().get(1);
+            Assert.assertEquals(DurationUnit.MINUTE, threeMinutes.getUnit());
+            Assert.assertEquals(3, threeMinutes.getAmount());
 
-            }
             // VERIFY IMAGE/JPG
-            {
-                ExpiresConfiguration expiresConfiguration = 
expiresFilter.getExpiresConfigurationByContentType().get(
-                        "image/jpg");
-                Assert.assertEquals(StartingPoint.ACCESS_TIME,
-                        expiresConfiguration.getStartingPoint());
+            ExpiresConfiguration expiresConfigurationImageJpg =
+                    
expiresFilter.getExpiresConfigurationByContentType().get("image/jpg");
+            Assert.assertEquals(StartingPoint.ACCESS_TIME,
+                    expiresConfigurationImageJpg.getStartingPoint());
 
-                Assert.assertEquals(1,
-                        expiresConfiguration.getDurations().size());
+            Assert.assertEquals(1, 
expiresConfigurationImageJpg.getDurations().size());
 
-                Duration tenThousandSeconds = 
expiresConfiguration.getDurations().get(
-                        0);
-                Assert.assertEquals(DurationUnit.SECOND,
-                        tenThousandSeconds.getUnit());
-                Assert.assertEquals(10000, tenThousandSeconds.getAmount());
+            Duration tenThousandSeconds = 
expiresConfigurationImageJpg.getDurations().get(0);
+            Assert.assertEquals(DurationUnit.SECOND, 
tenThousandSeconds.getUnit());
+            Assert.assertEquals(10000, tenThousandSeconds.getAmount());
 
-            }
             // VERIFY VIDEO/MPEG
-            {
-                ExpiresConfiguration expiresConfiguration = 
expiresFilter.getExpiresConfigurationByContentType().get(
-                        "video/mpeg");
-                Assert.assertEquals(StartingPoint.LAST_MODIFICATION_TIME,
-                        expiresConfiguration.getStartingPoint());
-
-                Assert.assertEquals(1,
-                        expiresConfiguration.getDurations().size());
-
-                Duration twentyThousandSeconds = 
expiresConfiguration.getDurations().get(
-                        0);
-                Assert.assertEquals(DurationUnit.SECOND,
-                        twentyThousandSeconds.getUnit());
-                Assert.assertEquals(20000, twentyThousandSeconds.getAmount());
-            }
+            ExpiresConfiguration expiresConfiguration =
+                    
expiresFilter.getExpiresConfigurationByContentType().get("video/mpeg");
+            Assert.assertEquals(StartingPoint.LAST_MODIFICATION_TIME,
+                    expiresConfiguration.getStartingPoint());
+
+            Assert.assertEquals(1, expiresConfiguration.getDurations().size());
+
+            Duration twentyThousandSeconds = 
expiresConfiguration.getDurations().get(0);
+            Assert.assertEquals(DurationUnit.SECOND, 
twentyThousandSeconds.getUnit());
+            Assert.assertEquals(20000, twentyThousandSeconds.getAmount());
         } finally {
             tomcat.stop();
         }
     }
 
-    /**
+    /*
      * Test that a resource with empty content is also processed
      */
     @Test
diff --git a/test/org/apache/juli/TestDateFormatCache.java 
b/test/org/apache/juli/TestDateFormatCache.java
index 8238be1..9205364 100644
--- a/test/org/apache/juli/TestDateFormatCache.java
+++ b/test/org/apache/juli/TestDateFormatCache.java
@@ -43,13 +43,11 @@ public class TestDateFormatCache {
         // Get dfc.cache.cache field
         Object dfcCache;
         Field dfcCacheArray;
-        {
-            Field dfcCacheField = dfc.getClass().getDeclaredField("cache");
-            dfcCacheField.setAccessible(true);
-            dfcCache = dfcCacheField.get(dfc);
-            dfcCacheArray = dfcCache.getClass().getDeclaredField("cache");
-            dfcCacheArray.setAccessible(true);
-        }
+        Field dfcCacheField = dfc.getClass().getDeclaredField("cache");
+        dfcCacheField.setAccessible(true);
+        dfcCache = dfcCacheField.get(dfc);
+        dfcCacheArray = dfcCache.getClass().getDeclaredField("cache");
+        dfcCacheArray.setAccessible(true);
 
         // Create an array to hold the expected values
         String[] expected = new String[cacheSize];


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to