New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[IO-711] Use Objects.requireNotNull for fail fast method/constructors #196
[IO-711] Use Objects.requireNotNull for fail fast method/constructors #196
Conversation
@garydgregory Please review and mark the cases you don't want to change for compatibility and/or design reasons. I'll change then all occurrences accordingly. |
ba2dae9
to
644e2c6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your PR. Please see my comments.
@@ -866,6 +868,8 @@ public static void copyFile(final File srcFile, final File destFile, final CopyO | |||
* @since 2.1 | |||
*/ | |||
public static long copyFile(final File input, final OutputStream output) throws IOException { | |||
Objects.requireNonNull(input, "input"); | |||
Objects.requireNonNull(output, "output"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-1: no need to check on output
, this already done in copyLarge
.
I'll stop this type of comment since these checks over the top in this PR. IOW, let's not check for NPEs when we do not need to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@garydgregory The other cases before I understood the pattern behind "-1". In this case a FileInputStream is created, afterwards copyLarge calls copy calls copyLarge which then does the check.
I'll fix the former cases and wait with removal for cases like this on your comment.
src/main/java/org/apache/commons/io/monitor/FileAlterationObserver.java
Outdated
Show resolved
Hide resolved
Sorry but I don't want to take the time to review each change in each of 31 files. If you do not want to revise the PR to minimize changes and duplication of null checks, that's fine as well. I might get to these kinds of changes later. Thank you for your contributions so far though :-) |
d429c96
to
8912dd6
Compare
|
8912dd6
to
66b7ebc
Compare
66b7ebc
to
cb17517
Compare
@boris-unckel |
Fixes https://issues.apache.org/jira/browse/IO-711