### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java,v retrieving revision 1.20 diff -u -r1.20 FormatterCommentsBugsTest.java --- src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java 2 Jul 2008 16:47:33 -0000 1.20 +++ src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java 8 Jul 2008 09:50:43 -0000 @@ -1781,4 +1781,50 @@ "}\n" ); } -} + +/** + * @bug 239941: [formatter] Unclosed html tags make the formatter to produce incorrect outputs + * @test Ensure that unclosed html tags do not screw up the formatter in following javadoc comments + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=239941" + */ +public void testBug239941() throws JavaModelException { + String source = + "public class X01 {\n" + + "\n" + + " /**\n" + + " *
\n" + 
+		"	 * Unclosed pre tag\n" + 
+		"	 */\n" + 
+		"	int foo;\n" + 
+		"\n" + 
+		"    /**\n" + 
+		"     * Gets the signers of this class.\n" + 
+		"     *\n" + 
+		"     * @return  the signers of this class, or null if there are no signers.  In\n" + 
+		"     * 		particular, this method returns null if this object represents\n" + 
+		"     * 		a primitive type or void.\n" + 
+		"     * @since 	JDK1.1\n" + 
+		"     */\n" + 
+		"    public native Object[] getSigners();\n" + 
+		"}\n";
+	formatSource(source,
+		"public class X01 {\n" + 
+		"\n" + 
+		"	/**\n" + 
+		"	 * 
\n" + 
+		"	 * Unclosed pre tag\n" + 
+		"	 */\n" + 
+		"	int foo;\n" + 
+		"\n" + 
+		"	/**\n" + 
+		"	 * Gets the signers of this class.\n" + 
+		"	 * \n" + 
+		"	 * @return the signers of this class, or null if there are no signers. In\n" + 
+		"	 *         particular, this method returns null if this object represents a\n" + 
+		"	 *         primitive type or void.\n" + 
+		"	 * @since JDK1.1\n" + 
+		"	 */\n" + 
+		"	public native Object[] getSigners();\n" + 
+		"}\n"
+	);
+}}
#P org.eclipse.jdt.core
Index: formatter/org/eclipse/jdt/internal/formatter/FormatterCommentParser.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/FormatterCommentParser.java,v
retrieving revision 1.19
diff -u -r1.19 FormatterCommentParser.java
--- formatter/org/eclipse/jdt/internal/formatter/FormatterCommentParser.java	2 Jul 2008 16:47:35 -0000	1.19
+++ formatter/org/eclipse/jdt/internal/formatter/FormatterCommentParser.java	8 Jul 2008 09:50:45 -0000
@@ -42,6 +42,9 @@
 	this.javadocStart = start;
 	this.javadocEnd = end;
 	this.firstTagPosition = this.javadocStart;
+	// Need to flush html tags stack in case of unclosed ones in previous javadoc comments
+	// see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=239941
+	this.htmlTagsPtr = -1;
 
 	// parse comment
 	boolean valid = commentParse();