Skip to content
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

Issue 478: Throw an IllegalArgumentException when the folder already exists #479

Merged
merged 4 commits into from
Aug 13, 2012

Conversation

awulder
Copy link

@awulder awulder commented Aug 12, 2012

Changed the code so it behaves like it is described in the documentation for #478.

Changed the code so it behaves like it is described in the
documentation.
@@ -89,7 +89,9 @@ public File newFolder(String... folderNames) {
File file= getRoot();
for (String folderName : folderNames) {
file= new File(file, folderName);
file.mkdir();
if (!file.mkdir())
throw new IllegalStateException(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think IllegalArgumentException would be a better than IllegalStateException, but I wonder if we should simply throw an IOException

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason why I used IllegalStateException is to be consistent. An IllegalStateException is also thrown if for some reason a file could not be created. (line 64)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change to add the IllegalStateException was added after the 4.10 release, so we can fix it now without breaking anyone.

kcooney suggested some changes for junit-team#479
After solving junit-team#479 also fixed the indenting
@@ -61,7 +61,7 @@ public void create() throws IOException {
public File newFile(String fileName) throws IOException {
File file= new File(getRoot(), fileName);
if (!file.createNewFile())
throw new IllegalStateException(
throw new IllegalArgumentException(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like IOException would be consistent with what JDK7 would do. See http://tinyurl.com/8bkvws7 (createFile() throws a subclass of IOException if the file exists)

@kcooney
Copy link
Member

kcooney commented Aug 13, 2012

Looks good. Thanks. Let's go with IOException, since that's what the JDK appears to be settling on.

It's more consistent to throw an IOException instead of an
IllegalArgumentException
@dsaff
Copy link
Member

dsaff commented Aug 13, 2012

Thanks!

dsaff pushed a commit that referenced this pull request Aug 13, 2012
Issue 478: Throw an IllegalArgumentException when the folder already exists
@dsaff dsaff merged commit 6dbbd79 into junit-team:master Aug 13, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants