commons-fileupload icon indicating copy to clipboard operation
commons-fileupload copied to clipboard

Simplify API

Open basil opened this issue 1 year ago • 0 comments

Not sure why this API has calling conventions that vary so drastically from method to method. Since this is still in M2 stage, it seems like it is still not too late to fix this. One problem with the existing code is that it violates Effective Java 3rd Edition §74, which says:

Use the Javadoc @throws tag to document each exception that a method can throw, but do not use the throws keyword on unchecked exceptions.

Another problem with the existing code is that FileItem#getString(Charset) is inconsistent with FileItem#getString()—one declares throws IOException while the other does not, yet it is not obvious how the presence of a Charset argument should cause any difference in calling convention.

Yet another problem with the existing code is that DiskFileItem#getString(java.nio.charset.Charset) claims to throw IOException but is actually implemented with DiskFileItem#get() which actually throws UncheckedIOException.

This PR fixes all of these problems by eliminating any usages of UncheckedIOException in favor of simple usages of throws IOException.

basil avatar May 10 '24 19:05 basil