Thursday, March 3, 2011

Missing Method Exception

Having a project in Maven central appears to help in getting quick feedback.
Two days ago I released a new version of the formatter plugin and today an issue was reported with it.

In the recent release, I switched to using plexus-io to provide wildcard includes/excludes for selecting files.
I used PlexusIoFileResourceCollection.getResources() which throws IOException.
This method uses DirectoryScanner.scan() which throws IllegalStateException if basedir is null, not exist, or not a directory
This exception is a RuntimeException, not an IOException.
So although the basedir is set on the collection and passed to the scanner, the collection does not list a throws for the IllegalStateException nor does it handle it.
Now even if I was already handling this exception, it wouldn't have been the desired behavior, which is to continue the build and ignore for projects that don't have files to format (instead of failing).
So I fixed checking the basedirs and pushed out a maintenance release today.

This is my fault for not having enough test cases, easily found using null values for the basedirs.
Or I could have just tested the maven site multimodule example from the checkstyle plugin.
Lessons learned. Evaluate the source of libraries used more thoroughly. And always more tests.

No comments:

Post a Comment