diff --git a/src/main/java/org/apache/maven/plugins/javadoc/AbstractFixJavadocMojo.java b/src/main/java/org/apache/maven/plugins/javadoc/AbstractFixJavadocMojo.java index 21480695..45bc87a4 100644 --- a/src/main/java/org/apache/maven/plugins/javadoc/AbstractFixJavadocMojo.java +++ b/src/main/java/org/apache/maven/plugins/javadoc/AbstractFixJavadocMojo.java @@ -2153,7 +2153,7 @@ void writeThrowsTag( final StringBuilder sb, final JavaExecutable javaExecutable { for ( JavaType exception : javaExecutable.getExceptions() ) { - if ( exception.getValue().endsWith( exceptionClassName ) ) + if ( exception.getFullyQualifiedName().endsWith( exceptionClassName ) ) { originalJavadocTag = StringUtils.replace( originalJavadocTag, exceptionClassName, exception.getFullyQualifiedName() ); diff --git a/src/test/resources/unit/fix-test/expected/src/main/java/fix/test/ClassWithJavadoc.java b/src/test/resources/unit/fix-test/expected/src/main/java/fix/test/ClassWithJavadoc.java index 8de0cbd8..c0305533 100644 --- a/src/test/resources/unit/fix-test/expected/src/main/java/fix/test/ClassWithJavadoc.java +++ b/src/test/resources/unit/fix-test/expected/src/main/java/fix/test/ClassWithJavadoc.java @@ -397,6 +397,60 @@ public void testGeneric2(Class tClass, Object o) { return; } + + /** + * test whether it will change exception description when using "fix" + * test if we use fully qualified name for the exception. + * + * @throws java.lang.Exception original description, should not be changed to "if any". + * @since 1.1 + */ + public void testException0() + throws Exception + { + throw new Exception(); + } + + /** + * test whether it will change exception description when using "fix" + * test if we use short name for the exception. + * + * @throws java.lang.Exception original description, should not be changed to "if any". + * @since 1.1 + */ + public void testException1() + throws Exception + { + throw new Exception(); + } + + /** + * test whether it will change exception description when using "fix" + * test if we use a wrong name for the exception. + * + * @throws RuaaaaaaException abcdefghijklmn. + * @throws java.lang.Exception if any. + * @since 1.1 + */ + public void testException2() + throws Exception + { + throw new Exception(); + } + + /** + * test whether it will change exception description when using "fix" + * test if we provide only one exception description. + * + * @throws java.lang.RuntimeException text. + * @throws java.lang.Exception if any. + * @since 1.1 + */ + public void testException3() + throws RuntimeException , Exception + { + throw new Exception(); + } } /** diff --git a/src/test/resources/unit/fix-test/expected/src/main/java/fix/test/ClassWithNoJavadoc.java b/src/test/resources/unit/fix-test/expected/src/main/java/fix/test/ClassWithNoJavadoc.java index 8b7196ec..ce6db451 100644 --- a/src/test/resources/unit/fix-test/expected/src/main/java/fix/test/ClassWithNoJavadoc.java +++ b/src/test/resources/unit/fix-test/expected/src/main/java/fix/test/ClassWithNoJavadoc.java @@ -218,6 +218,55 @@ public void testGeneric3(Class tClass, Object o) { return; } + + /** + *

testException0.

+ * + * @throws java.lang.Exception if any. + * @since 1.1 + */ + public void testException0() + throws Exception + { + throw new Exception(); + } + + /** + *

testException1.

+ * + * @throws java.lang.Exception if any. + * @since 1.1 + */ + public void testException1() + throws Exception + { + throw new Exception(); + } + + /** + *

testException2.

+ * + * @throws java.lang.Exception if any. + * @since 1.1 + */ + public void testException2() + throws Exception + { + throw new Exception(); + } + + /** + *

testException3.

+ * + * @throws java.lang.RuntimeException if any. + * @throws java.lang.Exception if any. + * @since 1.1 + */ + public void testException3() + throws RuntimeException , Exception + { + throw new Exception(); + } } @SuppressWarnings("SameReturnValue") diff --git a/src/test/resources/unit/fix-test/src/main/java/fix/test/ClassWithJavadoc.java b/src/test/resources/unit/fix-test/src/main/java/fix/test/ClassWithJavadoc.java index e6413f88..cb05cc93 100644 --- a/src/test/resources/unit/fix-test/src/main/java/fix/test/ClassWithJavadoc.java +++ b/src/test/resources/unit/fix-test/src/main/java/fix/test/ClassWithJavadoc.java @@ -366,6 +366,54 @@ public void testGeneric2(Class tClass, Object o) { return; } + + /** + * test whether it will change exception description when using "fix" + * test if we use fully qualified name for the exception. + * + * @throws java.lang.Exception original description, should not be changed to "if any". + */ + public void testException0() + throws Exception + { + throw new Exception(); + } + + /** + * test whether it will change exception description when using "fix" + * test if we use short name for the exception. + * + * @throws Exception original description, should not be changed to "if any". + */ + public void testException1() + throws Exception + { + throw new Exception(); + } + + /** + * test whether it will change exception description when using "fix" + * test if we use a wrong name for the exception. + * + * @throws RuaaaaaaException abcdefghijklmn. + */ + public void testException2() + throws Exception + { + throw new Exception(); + } + + /** + * test whether it will change exception description when using "fix" + * test if we provide only one exception description. + * + * @throws RuntimeException text. + */ + public void testException3() + throws RuntimeException , Exception + { + throw new Exception(); + } } /** diff --git a/src/test/resources/unit/fix-test/src/main/java/fix/test/ClassWithNoJavadoc.java b/src/test/resources/unit/fix-test/src/main/java/fix/test/ClassWithNoJavadoc.java index 3704dfb8..fa4421c6 100644 --- a/src/test/resources/unit/fix-test/src/main/java/fix/test/ClassWithNoJavadoc.java +++ b/src/test/resources/unit/fix-test/src/main/java/fix/test/ClassWithNoJavadoc.java @@ -146,6 +146,30 @@ public void testGeneric3(Class tClass, Object o) { return; } + + public void testException0() + throws Exception + { + throw new Exception(); + } + + public void testException1() + throws Exception + { + throw new Exception(); + } + + public void testException2() + throws Exception + { + throw new Exception(); + } + + public void testException3() + throws RuntimeException , Exception + { + throw new Exception(); + } } @SuppressWarnings("SameReturnValue")