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 67de585ef74a09269848f878443e4910c7e8d83f Author: Mark Thomas <ma...@apache.org> AuthorDate: Fri May 3 19:55:39 2019 +0100 Backport i18n changes from 9.0.x to keep code aligned --- java/org/apache/tomcat/util/codec/binary/Base64.java | 16 ++++++++-------- .../apache/tomcat/util/codec/binary/BaseNCodec.java | 3 +++ .../tomcat/util/codec/binary/LocalStrings.properties | 19 +++++++++++++++++++ 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/java/org/apache/tomcat/util/codec/binary/Base64.java b/java/org/apache/tomcat/util/codec/binary/Base64.java index 27fd701..ed13cb5 100644 --- a/java/org/apache/tomcat/util/codec/binary/Base64.java +++ b/java/org/apache/tomcat/util/codec/binary/Base64.java @@ -278,7 +278,7 @@ public class Base64 extends BaseNCodec { if (lineSeparator != null) { if (containsAlphabetOrPad(lineSeparator)) { final String sep = StringUtils.newStringUtf8(lineSeparator); - throw new IllegalArgumentException("lineSeparator must not contain base64 characters: [" + sep + "]"); + throw new IllegalArgumentException(sm.getString("base64.lineSeparator", sep)); } if (lineLength > 0){ // null line-sep forces no chunking rather than throwing IAE this.encodeSize = BYTES_PER_ENCODED_BLOCK + lineSeparator.length; @@ -366,7 +366,8 @@ public class Base64 extends BaseNCodec { } break; default: - throw new IllegalStateException("Impossible modulus "+context.modulus); + throw new IllegalStateException(sm.getString( + "base64.impossibleModulus", Integer.valueOf(context.modulus))); } context.currentLinePos += context.pos - savedPos; // keep track of current line position // if currentPos == 0 we are at the start of a line, so don't add CRLF @@ -477,7 +478,8 @@ public class Base64 extends BaseNCodec { buffer[context.pos++] = (byte) ((context.ibitWorkArea) & MASK_8BITS); break; default: - throw new IllegalStateException("Impossible modulus "+context.modulus); + throw new IllegalStateException(sm.getString( + "base64.impossibleModulus", Integer.valueOf(context.modulus))); } } } @@ -652,10 +654,8 @@ public class Base64 extends BaseNCodec { final Base64 b64 = isChunked ? new Base64(urlSafe) : new Base64(0, CHUNK_SEPARATOR, urlSafe); final long len = b64.getEncodedLength(binaryData); if (len > maxResultSize) { - throw new IllegalArgumentException("Input array too big, the output array would be bigger (" + - len + - ") than the specified maximum size of " + - maxResultSize); + throw new IllegalArgumentException(sm.getString( + "base64.inputTooLarge", Long.valueOf(len), Integer.valueOf(maxResultSize))); } return b64.encode(binaryData); @@ -722,7 +722,7 @@ public class Base64 extends BaseNCodec { */ public static byte[] encodeInteger(final BigInteger bigInt) { if (bigInt == null) { - throw new NullPointerException("encodeInteger called with null parameter"); + throw new NullPointerException(sm.getString("base64.nullEncodeParameter")); } return encodeBase64(toIntegerBytes(bigInt), false); } diff --git a/java/org/apache/tomcat/util/codec/binary/BaseNCodec.java b/java/org/apache/tomcat/util/codec/binary/BaseNCodec.java index b2a9db7..4dbe84a 100644 --- a/java/org/apache/tomcat/util/codec/binary/BaseNCodec.java +++ b/java/org/apache/tomcat/util/codec/binary/BaseNCodec.java @@ -21,6 +21,7 @@ import org.apache.tomcat.util.codec.BinaryDecoder; import org.apache.tomcat.util.codec.BinaryEncoder; import org.apache.tomcat.util.codec.DecoderException; import org.apache.tomcat.util.codec.EncoderException; +import org.apache.tomcat.util.res.StringManager; /** * Abstract superclass for Base-N encoders and decoders. @@ -32,6 +33,8 @@ import org.apache.tomcat.util.codec.EncoderException; @SuppressWarnings("deprecation") public abstract class BaseNCodec implements BinaryEncoder, BinaryDecoder { + protected static final StringManager sm = StringManager.getManager(BaseNCodec.class); + /** * Holds thread context so classes can be thread-safe. * diff --git a/java/org/apache/tomcat/util/codec/binary/LocalStrings.properties b/java/org/apache/tomcat/util/codec/binary/LocalStrings.properties new file mode 100644 index 0000000..1ae86a3 --- /dev/null +++ b/java/org/apache/tomcat/util/codec/binary/LocalStrings.properties @@ -0,0 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +base64.impossibleModulus=Impossible modulus [{0}] +base64.inputTooLarge=Input array too large, the output array would be bigger [{0}] than the specified maximum size of [{1}] +base64.lineSeparator=Line separator must not contain base64 characters [{0}] +base64.nullEncodeParameter=Cannot encode integer with null parameter --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org