Skip to content

Commit

Permalink
Issue #4564: fixed exception on JavadocStyle's skip html comment
Browse files Browse the repository at this point in the history
  • Loading branch information
rnveach authored and romani committed Feb 21, 2019
1 parent 90c6097 commit 817febb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@ private static boolean isCommentTag(String[] text, Point pos) {
private static Point skipHtmlComment(String[] text, Point fromPoint) {
Point toPoint = fromPoint;
toPoint = findChar(text, '>', toPoint);
while (!text[toPoint.getLineNo()]
.substring(0, toPoint.getColumnNo() + 1).endsWith("-->")) {
while (toPoint.getLineNo() < text.length && !text[toPoint.getLineNo()]
.substring(0, toPoint.getColumnNo() + 1).endsWith("-->")) {
toPoint = findChar(text, '>', getNextCharPos(text, toPoint));
}
return toPoint;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -423,4 +423,12 @@ public void testHtmlTagToString() {
+ "closedTag=true, incompleteTag=false]", tag.toString());
}

@Test
public void testNeverEndingXmlCommentInsideJavadoc() throws Exception {
final DefaultConfiguration checkConfig = createModuleConfig(JavadocStyleCheck.class);
final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;

verify(checkConfig, getPath("InputJavadocStyleNeverEndingXmlComment.java"), expected);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.puppycrawl.tools.checkstyle.checks.javadoc.javadocstyle;

public class InputJavadocStyleNeverEndingXmlComment {
/** DTD: <!--. */
public int i;
}

0 comments on commit 817febb

Please sign in to comment.