-
Notifications
You must be signed in to change notification settings - Fork 103
[MJAVADOC-825] Prefer NullPointerExceptions for null arguments #350
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,7 +40,6 @@ | |
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.Set; | ||
| import java.util.regex.PatternSyntaxException; | ||
|
|
||
| import org.apache.maven.plugin.testing.stubs.MavenProjectStub; | ||
| import org.apache.maven.plugins.javadoc.ProxyServer.AuthAsyncProxyServlet; | ||
|
|
@@ -61,21 +60,31 @@ | |
| * @author <a href="mailto:[email protected]">Vincent Siveton</a> | ||
| */ | ||
| public class JavadocUtilTest extends PlexusTestCase { | ||
| /** | ||
| * Method to test the javadoc version parsing. | ||
| * | ||
| */ | ||
| public void testParseJavadocVersion() { | ||
| String version = null; | ||
|
|
||
| public void testParseJavadocVersion_Null() { | ||
| try { | ||
| JavadocUtil.extractJavadocVersion(version); | ||
| JavadocUtil.extractJavadocVersion(null); | ||
| fail("Not catch null"); | ||
| } catch (IllegalArgumentException e) { | ||
| assertTrue(true); | ||
| } catch (NullPointerException ex) { | ||
| assertNotNull(ex.getMessage()); | ||
| } | ||
| } | ||
|
|
||
| public void testParseJavadocVersion_EmptyString() { | ||
| try { | ||
| JavadocUtil.extractJavadocVersion(""); | ||
| fail("Not catch empty version"); | ||
| } catch (IllegalArgumentException ex) { | ||
| assertNotNull(ex.getMessage()); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Test the javadoc version parsing. | ||
| */ | ||
| public void testParseJavadocVersion() { | ||
| // Sun JDK 1.4 | ||
| version = "java full version \"1.4.2_12-b03\""; | ||
| String version = "java full version \"1.4.2_12-b03\""; | ||
| assertEquals("1.4.2", JavadocUtil.extractJavadocVersion(version)); | ||
|
|
||
| // Sun JDK 1.5 | ||
|
|
@@ -126,15 +135,6 @@ public void testParseJavadocVersion() { | |
| version = "java full version \"1.4\""; | ||
| assertEquals("1.4", JavadocUtil.extractJavadocVersion(version)); | ||
|
|
||
| version = "java full version \"1.A.B_07-164\""; | ||
| try { | ||
| JavadocUtil.extractJavadocVersion(version); | ||
| // does not fail since JEP 223 support addition | ||
| // assertTrue( "Not catch wrong pattern", false ); | ||
| } catch (PatternSyntaxException e) { | ||
| assertTrue(true); | ||
| } | ||
|
|
||
| version = "SCO-UNIX-J2SE-1.5.0_09*FCS-UW714-OSR6*_20061114"; | ||
| assertEquals("1.5.0", JavadocUtil.extractJavadocVersion(version)); | ||
|
|
||
|
|
@@ -163,20 +163,29 @@ public void testParseJavadocVersion() { | |
| assertEquals("10.0.1", JavadocUtil.extractJavadocVersion(version)); | ||
| } | ||
|
|
||
| /** | ||
| * Method to test the javadoc memory parsing. | ||
| * | ||
| */ | ||
| public void testParseJavadocMemory() { | ||
| String memory = null; | ||
| public void testParseJavadocMemory_null() { | ||
| try { | ||
| JavadocUtil.parseJavadocMemory(memory); | ||
| JavadocUtil.parseJavadocMemory(null); | ||
| fail("Not catch null"); | ||
| } catch (IllegalArgumentException e) { | ||
| assertTrue(true); | ||
| } catch (NullPointerException ex) { | ||
| assertNotNull(ex.getMessage()); | ||
| } | ||
| } | ||
|
|
||
| public void testParseJavadocMemory_empty() { | ||
| try { | ||
| JavadocUtil.parseJavadocMemory(""); | ||
| fail("Not catch null"); | ||
| } catch (IllegalArgumentException ex) { | ||
| assertNotNull(ex.getMessage()); | ||
| } | ||
| } | ||
|
|
||
| memory = "128"; | ||
| /** | ||
| * Method to test the javadoc memory parsing. | ||
| */ | ||
| public void testParseJavadocMemory() { | ||
| String memory = "128"; | ||
| assertEquals(JavadocUtil.parseJavadocMemory(memory), "128m"); | ||
|
|
||
| memory = "128k"; | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Given
IAExbeing declared as thrown by, perhapsNPExcould also be added for style consistency?Or
IAExdeclaration removed?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.
Both have @throws clauses. Or did you mean something else?
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.
IllegalArgumentExceptionisRTEx(asNPExis). And is declared as being thrown by this method. Thus - let's addNullPointerExceptionto thethrowslist.Or remove
throws.Here, and in the second modified method.
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.
But that's already done in this PR. Are you looking at the left side (old code) instead of the right side (new code)?
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.
I see this:
I'd like to see this instead:
or this:
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.
Good spot. That should go the other way per guidelines. Removed both.