Program: 76758
Project: 76758
Buggy source:
/** 
 * Converts inline tags and text to text strings, expanding the inline tags along the way.  Called wherever text can contain an inline tag, such as in comments or in free-form text arguments to non-inline tags.
 * @param holderTag    specific tag where comment resides
 * @param element    specific element where comment resides
 * @param tags   array of text tags and inline tags (often alternating)present in the text of interest for this element
 * @param isFirstSentence  true if text is first sentence
 * @return a Content object
 */
public Content commentTagsToContent(DocTree holderTag,Element element,List<? extends DocTree> tags,boolean isFirstSentence){
  final Content result=new ContentBuilder(){
    @Override public void addContent(    CharSequence text){
      super.addContent(utils.normalizeNewlines(text));
    }
  }
;
  CommentHelper ch=utils.getCommentHelper(element);
  configuration.tagletManager.checkTags(utils,element,tags,true);
  commentRemoved=false;
  for (ListIterator<? extends DocTree> iterator=tags.listIterator(); iterator.hasNext(); ) {
    boolean isFirstNode=!iterator.hasPrevious();
    DocTree tag=iterator.next();
    boolean isLastNode=!iterator.hasNext();
    if (isFirstSentence) {
      if (ignoreNonInlineTag(tag))       continue;
      if ((isLastNode || commentRemoved) && tag.getKind() == TEXT && isAllWhiteSpace(ch.getText(tag)))       continue;
      if ((isFirstNode || commentRemoved) && tag.getKind() == COMMENT) {
        commentRemoved=true;
        continue;
      }
    }
    boolean allDone=new SimpleDocTreeVisitor<Boolean,Content>(){
      private boolean inAnAtag(){
        if (utils.isStartElement(tag)) {
          StartElementTree st=(StartElementTree)tag;
          Name name=st.getName();
          if (name != null) {
            com.sun.tools.doclint.HtmlTag htag=com.sun.tools.doclint.HtmlTag.get(name);
            return htag != null && htag.equals(com.sun.tools.doclint.HtmlTag.A);
          }
        }
        return false;
      }
      @Override public Boolean visitAttribute(      AttributeTree node,      Content c){
        StringBuilder sb=new StringBuilder(SPACER).append(node.getName());
        if (node.getValueKind() == ValueKind.EMPTY) {
          result.addContent(sb);
          return false;
        }
        sb.append("String_Node_Str");
        String quote;
switch (node.getValueKind()) {
case DOUBLE:
          quote="String_Node_Str";
        break;
case SINGLE:
      quote="String_Node_Str";
    break;
default :
  quote="String_Node_Str";
break;
}
sb.append(quote);
result.addContent(sb);
Content docRootContent=new ContentBuilder();
boolean isHRef=inAnAtag() && node.getName().toString().equalsIgnoreCase("String_Node_Str");
for (DocTree dt : node.getValue()) {
if (utils.isText(dt) && isHRef) {
String text=((TextTree)dt).getBody();
if (text.startsWith("String_Node_Str") && !configuration.docrootparent.isEmpty()) {
  result.addContent(configuration.docrootparent);
  docRootContent=new ContentBuilder();
  result.addContent(textCleanup(text.substring(3),isLastNode));
}
 else {
  if (!docRootContent.isEmpty()) {
    docRootContent=copyDocRootContent(docRootContent);
  }
 else {
    text=redirectRelativeLinks(element,(TextTree)dt);
  }
  result.addContent(textCleanup(text,isLastNode));
}
}
 else {
docRootContent=copyDocRootContent(docRootContent);
dt.accept(this,docRootContent);
}
}
copyDocRootContent(docRootContent);
result.addContent(quote);
return false;
}
@Override public Boolean visitComment(CommentTree node,Content c){
result.addContent(new RawHtml(node.getBody()));
return false;
}
private Content copyDocRootContent(Content content){
if (!content.isEmpty()) {
result.addContent(content);
return new ContentBuilder();
}
return content;
}
@Override public Boolean visitDocRoot(DocRootTree node,Content c){
Content docRootContent=TagletWriter.getInlineTagOutput(element,configuration.tagletManager,holderTag,node,getTagletWriterInstance(isFirstSentence));
if (c != null) {
c.addContent(docRootContent);
}
 else {
result.addContent(docRootContent);
}
return false;
}
@Override public Boolean visitEndElement(EndElementTree node,Content c){
RawHtml rawHtml=new RawHtml("String_Node_Str" + node.getName() + "String_Node_Str");
result.addContent(rawHtml);
return false;
}
@Override public Boolean visitEntity(EntityTree node,Content c){
result.addContent(new RawHtml(node.toString()));
return false;
}
@Override public Boolean visitErroneous(ErroneousTree node,Content c){
messages.warning(ch.getDocTreePath(node),"String_Node_Str",node);
result.addContent(new RawHtml(node.toString()));
return false;
}
@Override public Boolean visitInheritDoc(InheritDocTree node,Content c){
Content output=TagletWriter.getInlineTagOutput(element,configuration.tagletManager,holderTag,tag,getTagletWriterInstance(isFirstSentence));
result.addContent(output);
return (isFirstSentence && !output.isEmpty());
}
@Override public Boolean visitIndex(IndexTree node,Content p){
Content output=TagletWriter.getInlineTagOutput(element,configuration.tagletManager,holderTag,tag,getTagletWriterInstance(isFirstSentence));
if (output != null) {
result.addContent(output);
}
return false;
}
@Override public Boolean visitLink(LinkTree node,Content c){
result.addContent(seeTagToContent(element,tag));
return false;
}
@Override public Boolean visitLiteral(LiteralTree node,Content c){
String s=node.getBody().getBody();
Content content=new StringContent(utils.normalizeNewlines(s));
if (node.getKind() == CODE) content=HtmlTree.CODE(content);
result.addContent(content);
return false;
}
@Override public Boolean visitSee(SeeTree node,Content c){
result.addContent(seeTagToContent(element,tag));
return false;
}
@Override public Boolean visitStartElement(StartElementTree node,Content c){
String text="String_Node_Str" + node.getName();
RawHtml rawHtml=new RawHtml(utils.normalizeNewlines(text));
result.addContent(rawHtml);
for (DocTree dt : node.getAttributes()) {
dt.accept(this,null);
}
result.addContent(new RawHtml(node.isSelfClosing() ? "String_Node_Str" : "String_Node_Str"));
return false;
}
@Override public Boolean visitSummary(SummaryTree node,Content c){
Content output=TagletWriter.getInlineTagOutput(element,configuration.tagletManager,holderTag,tag,getTagletWriterInstance(isFirstSentence));
result.addContent(output);
return false;
}
private CharSequence textCleanup(String text,boolean isLast){
return textCleanup(text,isLast,false);
}
private CharSequence textCleanup(String text,boolean isLast,boolean trimLeader){
if (trimLeader) {
text=removeLeadingWhitespace(text);
}
if (isFirstSentence && isLast) {
text=removeTrailingWhitespace(text);
}
text=utils.replaceTabs(text);
return utils.normalizeNewlines(text);
}
@Override public Boolean visitText(TextTree node,Content c){
String text=node.getBody();
result.addContent(new RawHtml(textCleanup(text,isLastNode,commentRemoved)));
return false;
}
@Override protected Boolean defaultAction(DocTree node,Content c){
Content output=TagletWriter.getInlineTagOutput(element,configuration.tagletManager,holderTag,tag,getTagletWriterInstance(isFirstSentence));
if (output != null) {
result.addContent(output);
}
return false;
}
}
.visit(tag,null);
commentRemoved=false;
if (allDone) break;
}
return result;
}

Fixed version (ground truth):
/** 
 * Converts inline tags and text to text strings, expanding the inline tags along the way.  Called wherever text can contain an inline tag, such as in comments or in free-form text arguments to non-inline tags.
 * @param holderTag    specific tag where comment resides
 * @param element    specific element where comment resides
 * @param tags   array of text tags and inline tags (often alternating)present in the text of interest for this element
 * @param isFirstSentence  true if text is first sentence
 * @return a Content object
 */
public Content commentTagsToContent(DocTree holderTag,Element element,List<? extends DocTree> tags,boolean isFirstSentence){
  final Content result=new ContentBuilder(){
    @Override public void addContent(    CharSequence text){
      super.addContent(utils.normalizeNewlines(text));
    }
  }
;
  CommentHelper ch=utils.getCommentHelper(element);
  configuration.tagletManager.checkTags(element,tags,true);
  commentRemoved=false;
  for (ListIterator<? extends DocTree> iterator=tags.listIterator(); iterator.hasNext(); ) {
    boolean isFirstNode=!iterator.hasPrevious();
    DocTree tag=iterator.next();
    boolean isLastNode=!iterator.hasNext();
    if (isFirstSentence) {
      if (ignoreNonInlineTag(tag))       continue;
      if ((isLastNode || commentRemoved) && tag.getKind() == TEXT && isAllWhiteSpace(ch.getText(tag)))       continue;
      if ((isFirstNode || commentRemoved) && tag.getKind() == COMMENT) {
        commentRemoved=true;
        continue;
      }
    }
    boolean allDone=new SimpleDocTreeVisitor<Boolean,Content>(){
      private boolean inAnAtag(){
        if (utils.isStartElement(tag)) {
          StartElementTree st=(StartElementTree)tag;
          Name name=st.getName();
          if (name != null) {
            com.sun.tools.doclint.HtmlTag htag=com.sun.tools.doclint.HtmlTag.get(name);
            return htag != null && htag.equals(com.sun.tools.doclint.HtmlTag.A);
          }
        }
        return false;
      }
      @Override public Boolean visitAttribute(      AttributeTree node,      Content c){
        StringBuilder sb=new StringBuilder(SPACER).append(node.getName());
        if (node.getValueKind() == ValueKind.EMPTY) {
          result.addContent(sb);
          return false;
        }
        sb.append("String_Node_Str");
        String quote;
switch (node.getValueKind()) {
case DOUBLE:
          quote="String_Node_Str";
        break;
case SINGLE:
      quote="String_Node_Str";
    break;
default :
  quote="String_Node_Str";
break;
}
sb.append(quote);
result.addContent(sb);
Content docRootContent=new ContentBuilder();
boolean isHRef=inAnAtag() && node.getName().toString().equalsIgnoreCase("String_Node_Str");
for (DocTree dt : node.getValue()) {
if (utils.isText(dt) && isHRef) {
String text=((TextTree)dt).getBody();
if (text.startsWith("String_Node_Str") && !configuration.docrootparent.isEmpty()) {
  result.addContent(configuration.docrootparent);
  docRootContent=new ContentBuilder();
  result.addContent(textCleanup(text.substring(3),isLastNode));
}
 else {
  if (!docRootContent.isEmpty()) {
    docRootContent=copyDocRootContent(docRootContent);
  }
 else {
    text=redirectRelativeLinks(element,(TextTree)dt);
  }
  result.addContent(textCleanup(text,isLastNode));
}
}
 else {
docRootContent=copyDocRootContent(docRootContent);
dt.accept(this,docRootContent);
}
}
copyDocRootContent(docRootContent);
result.addContent(quote);
return false;
}
@Override public Boolean visitComment(CommentTree node,Content c){
result.addContent(new RawHtml(node.getBody()));
return false;
}
private Content copyDocRootContent(Content content){
if (!content.isEmpty()) {
result.addContent(content);
return new ContentBuilder();
}
return content;
}
@Override public Boolean visitDocRoot(DocRootTree node,Content c){
Content docRootContent=TagletWriter.getInlineTagOutput(element,configuration.tagletManager,holderTag,node,getTagletWriterInstance(isFirstSentence));
if (c != null) {
c.addContent(docRootContent);
}
 else {
result.addContent(docRootContent);
}
return false;
}
@Override public Boolean visitEndElement(EndElementTree node,Content c){
RawHtml rawHtml=new RawHtml("String_Node_Str" + node.getName() + "String_Node_Str");
result.addContent(rawHtml);
return false;
}
@Override public Boolean visitEntity(EntityTree node,Content c){
result.addContent(new RawHtml(node.toString()));
return false;
}
@Override public Boolean visitErroneous(ErroneousTree node,Content c){
messages.warning(ch.getDocTreePath(node),"String_Node_Str",node);
result.addContent(new RawHtml(node.toString()));
return false;
}
@Override public Boolean visitInheritDoc(InheritDocTree node,Content c){
Content output=TagletWriter.getInlineTagOutput(element,configuration.tagletManager,holderTag,tag,getTagletWriterInstance(isFirstSentence));
result.addContent(output);
return (isFirstSentence && !output.isEmpty());
}
@Override public Boolean visitIndex(IndexTree node,Content p){
Content output=TagletWriter.getInlineTagOutput(element,configuration.tagletManager,holderTag,tag,getTagletWriterInstance(isFirstSentence));
if (output != null) {
result.addContent(output);
}
return false;
}
@Override public Boolean visitLink(LinkTree node,Content c){
result.addContent(seeTagToContent(element,tag));
return false;
}
@Override public Boolean visitLiteral(LiteralTree node,Content c){
String s=node.getBody().getBody();
Content content=new StringContent(utils.normalizeNewlines(s));
if (node.getKind() == CODE) content=HtmlTree.CODE(content);
result.addContent(content);
return false;
}
@Override public Boolean visitSee(SeeTree node,Content c){
result.addContent(seeTagToContent(element,tag));
return false;
}
@Override public Boolean visitStartElement(StartElementTree node,Content c){
String text="String_Node_Str" + node.getName();
RawHtml rawHtml=new RawHtml(utils.normalizeNewlines(text));
result.addContent(rawHtml);
for (DocTree dt : node.getAttributes()) {
dt.accept(this,null);
}
result.addContent(new RawHtml(node.isSelfClosing() ? "String_Node_Str" : "String_Node_Str"));
return false;
}
@Override public Boolean visitSummary(SummaryTree node,Content c){
Content output=TagletWriter.getInlineTagOutput(element,configuration.tagletManager,holderTag,tag,getTagletWriterInstance(isFirstSentence));
result.addContent(output);
return false;
}
private CharSequence textCleanup(String text,boolean isLast){
return textCleanup(text,isLast,false);
}
private CharSequence textCleanup(String text,boolean isLast,boolean trimLeader){
if (trimLeader) {
text=removeLeadingWhitespace(text);
}
if (isFirstSentence && isLast) {
text=removeTrailingWhitespace(text);
}
text=utils.replaceTabs(text);
return utils.normalizeNewlines(text);
}
@Override public Boolean visitText(TextTree node,Content c){
String text=node.getBody();
result.addContent(new RawHtml(textCleanup(text,isLastNode,commentRemoved)));
return false;
}
@Override protected Boolean defaultAction(DocTree node,Content c){
Content output=TagletWriter.getInlineTagOutput(element,configuration.tagletManager,holderTag,tag,getTagletWriterInstance(isFirstSentence));
if (output != null) {
result.addContent(output);
}
return false;
}
}
.visit(tag,null);
commentRemoved=false;
if (allDone) break;
}
return result;
}