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

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

commit f45d77d1c83b2ff0badcee9b691342f4015337a2
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Wed Jun 5 10:42:11 2019 +0100

    Simplify code using varargs
---
 java/org/apache/jasper/compiler/Localizer.java | 96 +++-----------------------
 1 file changed, 10 insertions(+), 86 deletions(-)

diff --git a/java/org/apache/jasper/compiler/Localizer.java 
b/java/org/apache/jasper/compiler/Localizer.java
index 8fed5f2..e22803a 100644
--- a/java/org/apache/jasper/compiler/Localizer.java
+++ b/java/org/apache/jasper/compiler/Localizer.java
@@ -14,7 +14,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.jasper.compiler;
 
 import java.text.MessageFormat;
@@ -35,11 +34,9 @@ public class Localizer {
 
     static {
         try {
-            bundle = ResourceBundle.getBundle(
-                    "org.apache.jasper.resources.LocalStrings");
+            bundle = 
ResourceBundle.getBundle("org.apache.jasper.resources.LocalStrings");
         } catch (Throwable t) {
             ExceptionUtils.handleThrowable(t);
-            t.printStackTrace();
         }
     }
 
@@ -57,7 +54,9 @@ public class Localizer {
     public static String getMessage(String errCode) {
         String errMsg = errCode;
         try {
-            errMsg = bundle.getString(errCode);
+            if (bundle != null) {
+                errMsg = bundle.getString(errCode);
+            }
         } catch (MissingResourceException e) {
         }
         return errMsg;
@@ -71,91 +70,16 @@ public class Localizer {
      * localized error messages, it is used as the error message.
      *
      * @param errCode Error code to localize
-     * @param arg Argument for parametric replacement
-     *
-     * @return Localized error message
-     */
-    public static String getMessage(String errCode, String arg) {
-        return getMessage(errCode, new Object[] {arg});
-    }
-
-    /*
-     * Returns the localized error message corresponding to the given error
-     * code.
-     *
-     * If the given error code is not defined in the resource bundle for
-     * localized error messages, it is used as the error message.
-     *
-     * @param errCode Error code to localize
-     * @param arg1 First argument for parametric replacement
-     * @param arg2 Second argument for parametric replacement
-     *
-     * @return Localized error message
-     */
-    public static String getMessage(String errCode, String arg1, String arg2) {
-        return getMessage(errCode, new Object[] {arg1, arg2});
-    }
-
-    /*
-     * Returns the localized error message corresponding to the given error
-     * code.
-     *
-     * If the given error code is not defined in the resource bundle for
-     * localized error messages, it is used as the error message.
-     *
-     * @param errCode Error code to localize
-     * @param arg1 First argument for parametric replacement
-     * @param arg2 Second argument for parametric replacement
-     * @param arg3 Third argument for parametric replacement
-     *
-     * @return Localized error message
-     */
-    public static String getMessage(String errCode, String arg1, String arg2,
-                                    String arg3) {
-        return getMessage(errCode, new Object[] {arg1, arg2, arg3});
-    }
-
-    /*
-     * Returns the localized error message corresponding to the given error
-     * code.
-     *
-     * If the given error code is not defined in the resource bundle for
-     * localized error messages, it is used as the error message.
-     *
-     * @param errCode Error code to localize
-     * @param arg1 First argument for parametric replacement
-     * @param arg2 Second argument for parametric replacement
-     * @param arg3 Third argument for parametric replacement
-     * @param arg4 Fourth argument for parametric replacement
-     *
-     * @return Localized error message
-     */
-    public static String getMessage(String errCode, String arg1, String arg2,
-                                    String arg3, String arg4) {
-        return getMessage(errCode, new Object[] {arg1, arg2, arg3, arg4});
-    }
-
-    /*
-     * Returns the localized error message corresponding to the given error
-     * code.
-     *
-     * If the given error code is not defined in the resource bundle for
-     * localized error messages, it is used as the error message.
-     *
-     * @param errCode Error code to localize
      * @param args Arguments for parametric replacement
      *
      * @return Localized error message
      */
-    public static String getMessage(String errCode, Object[] args) {
-        String errMsg = errCode;
-        try {
-            errMsg = bundle.getString(errCode);
-            if (args != null && args.length > 0) {
-                MessageFormat formatter = new MessageFormat(errMsg);
-                errMsg = formatter.format(args);
-            }
-        } catch (MissingResourceException e) {
+    public static String getMessage(String errCode, Object... args) {
+        String errMsg = getMessage(errCode);
+
+        if (args != null && args.length > 0) {
+            MessageFormat formatter = new MessageFormat(errMsg);
+            errMsg = formatter.format(args);
         }
 
         return errMsg;


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

Reply via email to