commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gary Gregory <garydgreg...@gmail.com>
Subject [codec] RuntimeException DigestUtils.getDigest(String)
Date Sat, 01 Sep 2012 15:27:51 GMT
There is a nice bit of (IMO) ugliness in
org.apache.commons.codec.digest.DigestUtils.getDigest(String):

    public static MessageDigest getDigest(String algorithm) {
        try {
            return MessageDigest.getInstance(algorithm);
        } catch (NoSuchAlgorithmException e) {
            throw new RuntimeException(e.getMessage());
        }
    }

Throwing a RuntimeException and not even linking the exception combine for
two no-nos.

I propose:

            throw new IllegalArgumentException(e);

In theory, this would break someone looking for a DigestUtils throwing a
RuntimeException.

At the very least we should do:

            // ugly
            throw new RuntimeException(e);

Thoughts?

E-Mail: garydgregory@gmail.com | ggregory@apache.org
JUnit in Action, 2nd Ed: <http://goog_1249600977>http://bit.ly/ECvg0
Spring Batch in Action: <http://s.apache.org/HOq>http://bit.ly/bqpbCK
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message