Skip to content

Commit 9137228

Browse files
committed
Since we are using the trick of catching an ArrayIndexOutOfBoundsException instead of checking bounds, let's keep the exception when we rethrow a DecoderException.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/codec/trunk@797672 13f79535-47bb-0310-9956-ffa450edef68
1 parent 0f1e8c3 commit 9137228

2 files changed

Lines changed: 30 additions & 5 deletions

File tree

src/java/org/apache/commons/codec/DecoderException.java

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
package org.apache.commons.codec;
1919

2020
/**
21-
* Thrown when a Decoder has encountered a failure condition during a decode.
21+
* Thrown when a Decoder has encountered a failure condition during a decode.
2222
*
2323
* @author Apache Software Foundation
2424
* @version $Id$
@@ -33,13 +33,38 @@ public class DecoderException extends Exception {
3333
private static final long serialVersionUID = 1L;
3434

3535
/**
36-
* Creates a DecoderException
36+
* Creates a DecoderException.
3737
*
38-
* @param message A message with meaning to a human
38+
* @param message
39+
* The detail message which is saved for later retrieval by the {@link #getMessage()} method.
3940
*/
4041
public DecoderException(String message) {
4142
super(message);
4243
}
4344

44-
}
45+
/**
46+
* Creates a DecoderException.
47+
*
48+
* @param cause
49+
* The cause which is saved for later retrieval by the {@link #getCause()} method. A <code>null</code>
50+
* value is permitted, and indicates that the cause is nonexistent or unknown.
51+
* @since 1.4
52+
*/
53+
public DecoderException(Throwable cause) {
54+
super(cause);
55+
}
4556

57+
/**
58+
* Creates a DecoderException.
59+
*
60+
* @param message
61+
* The detail message which is saved for later retrieval by the {@link #getMessage()} method.
62+
* @param cause
63+
* The cause which is saved for later retrieval by the {@link #getCause()} method. A <code>null</code>
64+
* value is permitted, and indicates that the cause is nonexistent or unknown.
65+
* @since 1.4
66+
*/
67+
public DecoderException(String message, Throwable cause) {
68+
super(message, cause);
69+
}
70+
}

src/java/org/apache/commons/codec/net/URLCodec.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ public static final byte[] decodeUrl(byte[] bytes) throws DecoderException {
178178
int l = toCharacterDigit(bytes[++i]);
179179
buffer.write((char) ((u << 4) + l));
180180
} catch (ArrayIndexOutOfBoundsException e) {
181-
throw new DecoderException("Invalid URL encoding: ");
181+
throw new DecoderException("Invalid URL encoding: ", e);
182182
}
183183
} else {
184184
buffer.write(b);

0 commit comments

Comments
 (0)