This is an automated email from the ASF dual-hosted git repository. garydgregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-codec.git
commit 964036594041fa0a6c8d21f3ea6cb954f2e05b6c Author: Gary Gregory <[email protected]> AuthorDate: Sat Aug 8 16:32:13 2026 -0400 Javadoc Add missing @throws in BaseNCodec and subclasses --- .../org/apache/commons/codec/binary/Base16.java | 5 ++++ .../org/apache/commons/codec/binary/Base32.java | 6 +++-- .../org/apache/commons/codec/binary/Base58.java | 1 + .../org/apache/commons/codec/binary/Base64.java | 9 +++++++ .../apache/commons/codec/binary/BaseNCodec.java | 29 ++++++++++++++++++++-- 5 files changed, 46 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/apache/commons/codec/binary/Base16.java b/src/main/java/org/apache/commons/codec/binary/Base16.java index 7a2283d8..c6ad50d4 100644 --- a/src/main/java/org/apache/commons/codec/binary/Base16.java +++ b/src/main/java/org/apache/commons/codec/binary/Base16.java @@ -229,6 +229,11 @@ public class Base16 extends BaseNCodec { super(builder); } + /** + * {@inheritDoc} + * + * @throws IllegalArgumentException Thrown when a problem is detected processing data. + */ @Override void decode(final byte[] data, int offset, final int length, final Context context) { if (context.eof || length < 0) { diff --git a/src/main/java/org/apache/commons/codec/binary/Base32.java b/src/main/java/org/apache/commons/codec/binary/Base32.java index 4c883f9f..40a489c5 100644 --- a/src/main/java/org/apache/commons/codec/binary/Base32.java +++ b/src/main/java/org/apache/commons/codec/binary/Base32.java @@ -562,14 +562,15 @@ public class Base32 extends BaseNCodec { * for other bytes, too. This method subscribes to the garbage-in, garbage-out philosophy: it will not check the provided data for validity. * </p> * <p> - * Output is written to {@link org.apache.commons.codec.binary.BaseNCodec.Context#buffer Context#buffer} as 8-bit octets, using - * {@link org.apache.commons.codec.binary.BaseNCodec.Context#pos Context#pos} as the buffer position + * Output is written to {@link BaseNCodec.Context#buffer Context#buffer} as 8-bit octets, using + * {@link BaseNCodec.Context#pos Context#pos} as the buffer position * </p> * * @param input byte[] array of ASCII data to Base32 decode. * @param inPos Position to start reading data from. * @param inAvail Amount of bytes available from input for decoding. * @param context The context to be used. + * @throws IllegalArgumentException Thrown when a problem is detected processing data. */ @Override void decode(final byte[] input, int inPos, final int inAvail, final Context context) { @@ -676,6 +677,7 @@ public class Base32 extends BaseNCodec { * @param inPos Position to start reading data from. * @param inAvail Amount of bytes available from input for encoding. * @param context The context to be used. + * @throws IllegalArgumentException Thrown when a problem is detected processing data. */ @Override void encode(final byte[] input, int inPos, final int inAvail, final Context context) { diff --git a/src/main/java/org/apache/commons/codec/binary/Base58.java b/src/main/java/org/apache/commons/codec/binary/Base58.java index 981b4c99..126a9b64 100644 --- a/src/main/java/org/apache/commons/codec/binary/Base58.java +++ b/src/main/java/org/apache/commons/codec/binary/Base58.java @@ -327,6 +327,7 @@ public class Base58 extends BaseNCodec { * @param offset The offset in the array to start from. * @param length The number of bytes to decode, or negative to signal EOF. * @param context The context for this decoding operation. + * @throws IllegalArgumentException Thrown when a problem is detected processing data. */ @Override void decode(final byte[] array, final int offset, final int length, final Context context) { diff --git a/src/main/java/org/apache/commons/codec/binary/Base64.java b/src/main/java/org/apache/commons/codec/binary/Base64.java index 031becae..3245c208 100644 --- a/src/main/java/org/apache/commons/codec/binary/Base64.java +++ b/src/main/java/org/apache/commons/codec/binary/Base64.java @@ -390,6 +390,7 @@ public class Base64 extends BaseNCodec { * * @param base64Data Byte array containing Base64 data. * @return New array containing decoded data. + * @throws IllegalArgumentException Thrown when a problem is detected processing data. */ public static byte[] decodeBase64(final byte[] base64Data) { return new Base64().decode(base64Data); @@ -405,6 +406,7 @@ public class Base64 extends BaseNCodec { * * @param base64String String containing Base64 data. * @return New array containing decoded data. + * @throws IllegalArgumentException Thrown when a problem is detected processing data. * @since 1.4 */ public static byte[] decodeBase64(final String base64String) { @@ -420,6 +422,7 @@ public class Base64 extends BaseNCodec { * * @param base64Data Byte array containing Base64 data. * @return New array containing decoded data. + * @throws IllegalArgumentException Thrown when a problem is detected processing data. * @since 1.21 */ public static byte[] decodeBase64Standard(final byte[] base64Data) { @@ -435,6 +438,7 @@ public class Base64 extends BaseNCodec { * * @param base64String String containing Base64 data. * @return New array containing decoded data. + * @throws IllegalArgumentException Thrown when a problem is detected processing data. * @since 1.21 */ public static byte[] decodeBase64Standard(final String base64String) { @@ -451,6 +455,7 @@ public class Base64 extends BaseNCodec { * * @param base64Data Byte array containing Base64 data. * @return New array containing decoded data. + * @throws IllegalArgumentException Thrown when a problem is detected processing data. * @since 1.21 */ public static byte[] decodeBase64UrlSafe(final byte[] base64Data) { @@ -467,6 +472,7 @@ public class Base64 extends BaseNCodec { * * @param base64String String containing Base64 data. * @return New array containing decoded data. + * @throws IllegalArgumentException Thrown when a problem is detected processing data. * @since 1.21 */ public static byte[] decodeBase64UrlSafe(final String base64String) { @@ -478,6 +484,7 @@ public class Base64 extends BaseNCodec { * * @param array A byte array containing base64 character data. * @return A BigInteger. + * @throws IllegalArgumentException Thrown when a problem is detected processing data. * @since 1.4 */ public static BigInteger decodeInteger(final byte[] array) { @@ -985,6 +992,7 @@ public class Base64 extends BaseNCodec { * @param inPos Position to start reading data from. * @param inAvail Amount of bytes available from input for decoding. * @param context The context to be used. + * @throws IllegalArgumentException Thrown when a problem is detected processing data. */ @Override void decode(final byte[] input, int inPos, final int inAvail, final Context context) { @@ -1064,6 +1072,7 @@ public class Base64 extends BaseNCodec { * @param inPos Position to start reading data from. * @param inAvail Amount of bytes available from input for encoding. * @param context The context to be used. + * @throws IllegalArgumentException Thrown when a problem is detected processing data. */ @Override void encode(final byte[] in, int inPos, final int inAvail, final Context context) { diff --git a/src/main/java/org/apache/commons/codec/binary/BaseNCodec.java b/src/main/java/org/apache/commons/codec/binary/BaseNCodec.java index bd27d27c..7a6e39d6 100644 --- a/src/main/java/org/apache/commons/codec/binary/BaseNCodec.java +++ b/src/main/java/org/apache/commons/codec/binary/BaseNCodec.java @@ -654,6 +654,7 @@ public abstract class BaseNCodec implements BinaryEncoder, BinaryDecoder { * * @param array A byte array containing Base-N character data. * @return A byte array containing binary data. + * @throws IllegalArgumentException Thrown when a problem is detected processing data. */ @Override public byte[] decode(final byte[] array) { @@ -668,7 +669,17 @@ public abstract class BaseNCodec implements BinaryEncoder, BinaryDecoder { return result; } - // package protected for access from I/O streams + /** + * Decodes a byte[] containing characters in the Base-N alphabet into a temporary context buffer. + * <p> + * This method is package protected for access from I/O streams. + * </p> + * + * @param array A byte array containing Base-N character data. + * @param offset initial offset of the subarray. + * @param length length of the subarray. + * @throws IllegalArgumentException Thrown when a problem is detected processing data. + */ abstract void decode(byte[] array, int i, int length, Context context); /** @@ -678,6 +689,7 @@ public abstract class BaseNCodec implements BinaryEncoder, BinaryDecoder { * @param obj Object to decode. * @return An object (of type byte[]) containing the binary data which corresponds to the byte[] or String supplied. * @throws DecoderException if the parameter supplied is not of type byte[]. + * @throws IllegalArgumentException Thrown when a problem is detected processing data. */ @Override public Object decode(final Object obj) throws DecoderException { @@ -695,6 +707,7 @@ public abstract class BaseNCodec implements BinaryEncoder, BinaryDecoder { * * @param array A String containing Base-N character data. * @return A byte array containing binary data. + * @throws IllegalArgumentException Thrown when a problem is detected processing data. */ public byte[] decode(final String array) { return decode(StringUtils.getBytesUtf8(array)); @@ -705,6 +718,7 @@ public abstract class BaseNCodec implements BinaryEncoder, BinaryDecoder { * * @param array A byte array containing binary data. * @return A byte array containing only the base N alphabetic character data. + * @throws IllegalArgumentException Thrown when a problem is detected processing data. */ @Override public byte[] encode(final byte[] array) { @@ -721,6 +735,7 @@ public abstract class BaseNCodec implements BinaryEncoder, BinaryDecoder { * @param offset initial offset of the subarray. * @param length length of the subarray. * @return A byte array containing only the base N alphabetic character data. + * @throws IllegalArgumentException Thrown when a problem is detected processing data. * @since 1.11 */ public byte[] encode(final byte[] array, final int offset, final int length) { @@ -735,7 +750,17 @@ public abstract class BaseNCodec implements BinaryEncoder, BinaryDecoder { return buf; } - // package protected for access from I/O streams + /** + * Encodes a byte[] containing characters in the Base-N alphabet into a temporary context buffer. + * <p> + * This method is package protected for access from I/O streams. + * </p> + * + * @param array A byte array containing Base-N character data. + * @param offset initial offset of the subarray. + * @param length length of the subarray. + * @throws IllegalArgumentException Thrown when a problem is detected processing data. + */ abstract void encode(byte[] array, int i, int length, Context context); /**
