Exception transparency - lone throws (no checked exceptions)

Lawrence Kesteloot lk at teamten.com
Thu Jun 17 16:17:54 PDT 2010


Stephen wrote:
> I would note that the catch side of checked exceptions is just as
> important as the throws side to those that favour checked.

Right. My team has been using Spring for three years and I frequently
see bugs like this:

    try {
        return simpleJdbcTemplate.queryForList( ... );
    } catch (EmptyResultDataAccessException e) {
        return null;
    }

The idea is to return null if the result set is empty, but
queryForList() doesn't throw that exception; it just returns an empty
list.

I may as well take this opportunity to say that three years of using
Spring has convinced me that unchecked exceptions lead to many more
bugs than checked. I'm strongly in favor of them (and static checks of
all kind) and I'm willing to pay the verbosity tax. I hope this point
of view isn't lost in the sea of claims that "everyone hates checked
exceptions".

Lawrence


More information about the lambda-dev mailing list