Program: 189164
Project: 189164
Buggy source:
public void layout(){
  super.layout();
  add(CSSPackageResource.getHeaderContribution(getClass(),"String_Node_Str"));
  title=getPageParameters().getString("String_Node_Str");
  if (title == null || title.length() == 0) {
    title=Document.DEFAULT_PAGE;
  }
  doc=DocsApplication.getDocument(title,getProject());
  View.layoutMenuItems(this);
  WebMarkupContainer details=new WebMarkupContainer("String_Node_Str");
  add(details);
  PageParameters titledParameters=getPageParameters();
  if (!titledParameters.containsKey("String_Node_Str")) {
    titledParameters.add("String_Node_Str",title);
  }
  if (doc == null) {
    addLink(new BookmarkableMenuLink(getPageClass("String_Node_Str"),getPageParameters(),"String_Node_Str"));
    add(new WebMarkupContainer("String_Node_Str").setVisible(false));
    WebMarkupContainer notfound=new WebMarkupContainer("String_Node_Str");
    notfound.add(new Label("String_Node_Str",title));
    notfound.add(new Label("String_Node_Str",getProject().getAlias()));
    notfound.add(new BookmarkablePageLink("String_Node_Str",getPageClass("String_Node_Str"),titledParameters));
    add(notfound);
    details.setVisible(false);
    return;
  }
  addLink(new BookmarkableMenuLink(getPageClass("String_Node_Str"),titledParameters,"String_Node_Str"));
  watching=doc.getWatchers().contains(getSession().getUser());
  addLink(new MenuLink(){
    public String getLabel(){
      if (watching) {
        return "String_Node_Str";
      }
      return "String_Node_Str";
    }
    public void onClick(){
      toggleWatching();
    }
  }
);
  addLink(new BookmarkableMenuLink(getPageClass("String_Node_Str"),getPageParameters(),"String_Node_Str"));
  addLink(new BookmarkableMenuLink(getPageClass("String_Node_Str"),getPageParameters(),"String_Node_Str"));
  add(new WebMarkupContainer("String_Node_Str").setVisible(false));
  add(new Label("String_Node_Str",getContent(doc)).setEscapeModelStrings(false));
  final List<Attachment> attachmentList=new LinkedList<Attachment>();
  attachmentList.addAll(doc.getAttachments());
  Collections.sort(attachmentList,new Comparator<Attachment>(){
    public int compare(    Attachment attachment1,    Attachment attachment2){
      return attachment1.getCreated().compareTo(attachment2.getCreated());
    }
  }
);
  details.add(new ListView<Attachment>("String_Node_Str",attachmentList){
    private Attachment attachment;
    protected void populateItem(    ListItem<Attachment> listItem){
      attachment=listItem.getModelObject();
      listItem.add(new Label("String_Node_Str",attachment.getUser().getFullnameOrUsername()));
      listItem.add(new Label("String_Node_Str",new FormattedDateModel(attachment.getCreated(),((HeadsUpSession)getSession()).getTimeZone())));
      File file=attachment.getFile(getStorage());
      Mime mime=Mime.get(file.getName());
      listItem.add(new Image("String_Node_Str",new ResourceReference(Mime.class,mime.getIconName())));
      Link download=new DownloadLink("String_Node_Str",file);
      download.add(new Label("String_Node_Str",attachment.getFilename()));
      listItem.add(download);
      listItem.add(new Link("String_Node_Str"){
        @Override public void onClick(){
          attachment=(Attachment)((HibernateStorage)getStorage()).getHibernateSession().merge(attachment);
          doc=(Document)((HibernateStorage)getStorage()).getHibernateSession().merge(doc);
          attachmentList.remove(attachment);
          doc.getAttachments().remove(attachment);
          ((HibernateStorage)getStorage()).delete(attachment);
          attachment.getFile(getStorage()).delete();
        }
      }
);
      Comment comment=attachment.getComment();
      if (comment != null) {
        Label commentLabel=new Label("String_Node_Str",new MarkedUpTextModel(comment.getComment(),getProject()));
        commentLabel.setEscapeModelStrings(false);
        listItem.add(commentLabel);
      }
 else {
        listItem.add(new WebMarkupContainer("String_Node_Str").setVisible(false));
      }
    }
  }
);
  final List<Comment> commentList=new LinkedList<Comment>();
  commentList.addAll(doc.getComments());
  Collections.sort(commentList,new Comparator<Comment>(){
    public int compare(    Comment comment1,    Comment comment2){
      return comment1.getCreated().compareTo(comment2.getCreated());
    }
  }
);
  details.add(new ListView<Comment>("String_Node_Str",commentList){
    protected void populateItem(    ListItem<Comment> listItem){
      listItem.add(new CommentPanel("String_Node_Str",listItem.getModel(),getProject(),commentList,doc,(HeadsUpPage)getPage()));
    }
  }
);
}

Fixed version (ground truth):
public void layout(){
  super.layout();
  add(CSSPackageResource.getHeaderContribution(getClass(),"String_Node_Str"));
  title=getPageParameters().getString("String_Node_Str");
  if (title == null || title.length() == 0) {
    title=Document.DEFAULT_PAGE;
  }
  doc=DocsApplication.getDocument(title,getProject());
  View.layoutMenuItems(this);
  WebMarkupContainer details=new WebMarkupContainer("String_Node_Str");
  add(details);
  PageParameters titledParameters=getPageParameters();
  if (!titledParameters.containsKey("String_Node_Str")) {
    titledParameters.add("String_Node_Str",title);
  }
  if (doc == null) {
    addLink(new BookmarkableMenuLink(getPageClass("String_Node_Str"),getPageParameters(),"String_Node_Str"));
    add(new WebMarkupContainer("String_Node_Str").setVisible(false));
    WebMarkupContainer notfound=new WebMarkupContainer("String_Node_Str");
    notfound.add(new Label("String_Node_Str",title));
    notfound.add(new Label("String_Node_Str",getProject().getAlias()));
    notfound.add(new BookmarkablePageLink("String_Node_Str",getPageClass("String_Node_Str"),titledParameters));
    add(notfound);
    details.setVisible(false);
    return;
  }
  addLink(new BookmarkableMenuLink(getPageClass("String_Node_Str"),titledParameters,"String_Node_Str"));
  watching=doc.getWatchers().contains(getSession().getUser());
  addLink(new MenuLink(){
    public String getLabel(){
      if (watching) {
        return "String_Node_Str";
      }
      return "String_Node_Str";
    }
    public void onClick(){
      toggleWatching();
    }
  }
);
  addLink(new BookmarkableMenuLink(getPageClass("String_Node_Str"),getPageParameters(),"String_Node_Str"));
  addLink(new BookmarkableMenuLink(getPageClass("String_Node_Str"),getPageParameters(),"String_Node_Str"));
  add(new WebMarkupContainer("String_Node_Str").setVisible(false));
  add(new Label("String_Node_Str",getContent(doc)).setEscapeModelStrings(false));
  final List<Attachment> attachmentList=new LinkedList<Attachment>();
  attachmentList.addAll(doc.getAttachments());
  Collections.sort(attachmentList,new Comparator<Attachment>(){
    public int compare(    Attachment attachment1,    Attachment attachment2){
      return attachment1.getCreated().compareTo(attachment2.getCreated());
    }
  }
);
  details.add(new ListView<Attachment>("String_Node_Str",attachmentList){
    private Attachment attachment;
    protected void populateItem(    ListItem<Attachment> listItem){
      attachment=listItem.getModelObject();
      listItem.add(new Label("String_Node_Str",attachment.getUser().getFullnameOrUsername()));
      listItem.add(new Label("String_Node_Str",new FormattedDateModel(attachment.getCreated(),((HeadsUpSession)getSession()).getTimeZone())));
      File file=attachment.getFile(getStorage());
      Mime mime=Mime.get(file.getName());
      listItem.add(new Image("String_Node_Str",new ResourceReference(Mime.class,mime.getIconName())));
      Link download=new DownloadLink("String_Node_Str",file);
      download.add(new Label("String_Node_Str",attachment.getFilename()));
      listItem.add(download);
      listItem.add(new Link("String_Node_Str"){
        @Override public void onClick(){
          attachment=(Attachment)((HibernateStorage)getStorage()).getHibernateSession().merge(attachment);
          doc=(Document)((HibernateStorage)getStorage()).getHibernateSession().merge(doc);
          attachmentList.remove(attachment);
          doc.getAttachments().remove(attachment);
          ((HibernateStorage)getStorage()).delete(attachment);
          attachment.getFile(getStorage()).delete();
        }
      }
);
      Comment comment=attachment.getComment();
      if (comment != null) {
        Label commentLabel=new Label("String_Node_Str",new MarkedUpTextModel(comment.getComment(),getProject()));
        commentLabel.setEscapeModelStrings(false);
        listItem.add(commentLabel);
      }
 else {
        listItem.add(new WebMarkupContainer("String_Node_Str").setVisible(false));
      }
    }
  }
);
  final List<Comment> commentList=new LinkedList<Comment>();
  commentList.addAll(doc.getComments());
  Collections.sort(commentList,new Comparator<Comment>(){
    public int compare(    Comment comment1,    Comment comment2){
      return comment1.getCreated().compareTo(comment2.getCreated());
    }
  }
);
  details.add(new ListView<Comment>("String_Node_Str",commentList){
    protected void populateItem(    ListItem<Comment> listItem){
      listItem.add(new CommentPanel("String_Node_Str",listItem.getModel(),getProject(),commentList,doc));
    }
  }
);
}