Use final and remove trailing whitespace.
MODIFY
checkstyle.xml
checkstyle.xml
@@ -15,11 +15,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
-
<!DOCTYPE module PUBLIC
"-//Checkstyle//DTD Checkstyle Configuration 1.2//EN"
"https://checkstyle.org/dtds/configuration_1_2.dtd">
-
<!-- commons lang customization of default Checkstyle behavior -->
<module name="Checker">
<property name="localeLanguage" value="en"/>
@@ -41,5 +39,11 @@ limitations under the License.
<module name="LeftCurly"/>
<module name="JavadocMethod">
</module>
+ <!-- No Trailing whitespace -->
+ <module name="Regexp">
+ <property name="format" value="[ \t]+$"/>
+ <property name="illegalPattern" value="true"/>
+ <property name="message" value="Trailing whitespace"/>
+ </module>
</module>
</module>

MODIFY
src/main/java/org/apache/commons/io/UncheckedIOExceptions.java
src/main/java/org/apache/commons/io/UncheckedIOExceptions.java
* @param message the detail message.
* @return a new UncheckedIOException.
*/
- public static UncheckedIOException create(Object message) {
+ public static UncheckedIOException create(final Object message) {
final String string = Objects.toString(message);
return new UncheckedIOException(string, new IOException(string));
}
@@ -52,7 +52,7 @@ public static UncheckedIOException create(Object message) {
* @param e cause the {@code IOException}.
* @return a new UncheckedIOException.
*/
- public static UncheckedIOException create(Object message, final IOException e) {
+ public static UncheckedIOException create(final Object message, final IOException e) {
return new UncheckedIOException(Objects.toString(message), e);
}

MODIFY
src/main/java/org/apache/commons/io/output/UncheckedFilterWriter.java
src/main/java/org/apache/commons/io/output/UncheckedFilterWriter.java
@@ -49,7 +49,7 @@ public static UncheckedFilterWriter on(final Writer writer) {
* @param writer a Writer object providing the underlying stream.
* @throws NullPointerException if {@code writer} is {@code null}.
*/
- protected UncheckedFilterWriter(Writer writer) {
+ protected UncheckedFilterWriter(final Writer writer) {
super(writer);
}
@@ -57,10 +57,10 @@ protected UncheckedFilterWriter(Writer writer) {
* Calls this method's super and rethrow {@link IOException} as {@link UncheckedIOException}.
*/
@Override
- public Writer append(char c) throws UncheckedIOException {
+ public Writer append(final char c) throws UncheckedIOException {
try {
return super.append(c);
- } catch (IOException e) {
+ } catch (final IOException e) {
throw uncheck(e);
}
}
@@ -69,10 +69,10 @@ public Writer append(char c) throws UncheckedIOException {
* Calls this method's super and rethrow {@link IOException} as {@link UncheckedIOException}.
*/
@Override
- public Writer append(CharSequence csq) throws UncheckedIOException {
+ public Writer append(final CharSequence csq) throws UncheckedIOException {
try {
return super.append(csq);
- } catch (IOException e) {
+ } catch (final IOException e) {
throw uncheck(e);
}
}
@@ -81,10 +81,10 @@ public Writer append(CharSequence csq) throws UncheckedIOException {
* Calls this method's super and rethrow {@link IOException} as {@link UncheckedIOException}.
*/
@Override
- public Writer append(CharSequence csq, int start, int end) throws UncheckedIOException {
+ public Writer append(final CharSequence csq, final int start, final int end) throws UncheckedIOException {
try {
return super.append(csq, start, end);
- } catch (IOException e) {
+ } catch (final IOException e) {
throw uncheck(e);
}
}
@@ -96,7 +96,7 @@ public Writer append(CharSequence csq, int start, int end) throws UncheckedIOExc
public void close() throws UncheckedIOException {
try {
super.close();
- } catch (IOException e) {
+ } catch (final IOException e) {
throw uncheck(e);
}
}
@@ -108,12 +108,12 @@ public void close() throws UncheckedIOException {
public void flush() throws UncheckedIOException {
try {
super.flush();
- } catch (IOException e) {
+ } catch (final IOException e) {
throw uncheck(e);
}
}
- private UncheckedIOException uncheck(IOException e) {
+ private UncheckedIOException uncheck(final IOException e) {
return new UncheckedIOException(e);
}
@@ -121,10 +121,10 @@ private UncheckedIOException uncheck(IOException e) {
* Calls this method's super and rethrow {@link IOException} as {@link UncheckedIOException}.
*/
@Override
- public void write(char[] cbuf) throws UncheckedIOException {
+ public void write(final char[] cbuf) throws UncheckedIOException {
try {
super.write(cbuf);
- } catch (IOException e) {
+ } catch (final IOException e) {
throw uncheck(e);
}
}
@@ -133,10 +133,10 @@ public void write(char[] cbuf) throws UncheckedIOException {
* Calls this method's super and rethrow {@link IOException} as {@link UncheckedIOException}.
*/
@Override
- public void write(char[] cbuf, int off, int len) throws UncheckedIOException {
+ public void write(final char[] cbuf, final int off, final int len) throws UncheckedIOException {
try {
super.write(cbuf, off, len);
- } catch (IOException e) {
+ } catch (final IOException e) {
throw uncheck(e);
}
}
@@ -145,10 +145,10 @@ public void write(char[] cbuf, int off, int len) throws UncheckedIOException {
* Calls this method's super and rethrow {@link IOException} as {@link UncheckedIOException}.
*/
@Override
- public void write(int c) throws UncheckedIOException {
+ public void write(final int c) throws UncheckedIOException {
try {
super.write(c);
- } catch (IOException e) {
+ } catch (final IOException e) {
throw uncheck(e);
}
}
@@ -157,10 +157,10 @@ public void write(int c) throws UncheckedIOException {
* Calls this method's super and rethrow {@link IOException} as {@link UncheckedIOException}.
*/
@Override
- public void write(String str) throws UncheckedIOException {
+ public void write(final String str) throws UncheckedIOException {
try {
super.write(str);
- } catch (IOException e) {
+ } catch (final IOException e) {
throw uncheck(e);
}
}
@@ -169,10 +169,10 @@ public void write(String str) throws UncheckedIOException {
* Calls this method's super and rethrow {@link IOException} as {@link UncheckedIOException}.
*/
@Override
- public void write(String str, int off, int len) throws UncheckedIOException {
+ public void write(final String str, final int off, final int len) throws UncheckedIOException {
try {
super.write(str, off, len);
- } catch (IOException e) {
+ } catch (final IOException e) {
throw uncheck(e);
}
}

MODIFY
src/test/java/org/apache/commons/io/UncheckedIOExceptionsTest.java
src/test/java/org/apache/commons/io/UncheckedIOExceptionsTest.java
@@ -31,7 +31,7 @@ public void testCreate() {
final Object message = "test";
try {
throw UncheckedIOExceptions.create(message);
- } catch (UncheckedIOException e) {
+ } catch (final UncheckedIOException e) {
assertEquals(message, e.getMessage());
assertEquals(message, e.getCause().getMessage());
}
@@ -45,7 +45,7 @@ public void testCreateWithException() {
final IOException ioe = new IOException(message2.toString());
try {
throw UncheckedIOExceptions.create(message1, ioe);
- } catch (UncheckedIOException e) {
+ } catch (final UncheckedIOException e) {
assertEquals(message1, e.getMessage());
assertEquals(message2, e.getCause().getMessage());
}

Use final and remove trailing whitespace.