Program: 189150
Project: 189150
Buggy source:
public void layout(){
  super.layout();
  add(CSSPackageResource.getHeaderContribution(getClass(),"String_Node_Str"));
  add(CSSPackageResource.getHeaderContribution(IssueListPanel.class,"String_Node_Str"));
  try {
    issueId=getPageParameters().getLong("String_Node_Str");
  }
 catch (  NumberFormatException e) {
    notFoundError();
    return;
  }
  issue=IssuesApplication.getIssue(issueId,getProject());
  if (issue == null) {
    notFoundError();
    return;
  }
  watching=issue.getWatchers().contains(getSession().getUser());
  List<MenuLink> links=getLinks(issue);
  if (issue.getStatus() < Issue.STATUS_CLOSED) {
    links.add(1,new MenuLink(){
      public String getLabel(){
        if (watching) {
          return "String_Node_Str";
        }
        return "String_Node_Str";
      }
      public void onClick(){
        toggleWatching();
      }
    }
);
  }
  addLinks(links);
  issuePanel=new IssuePanel("String_Node_Str",issue,ViewIssue.this);
  add(issuePanel);
  final List<Attachment> attachmentList=new LinkedList<Attachment>();
  attachmentList.addAll(issue.getAttachments());
  Collections.sort(attachmentList,new Comparator<Attachment>(){
    public int compare(    Attachment attachment1,    Attachment attachment2){
      return attachment1.getCreated().compareTo(attachment2.getCreated());
    }
  }
);
  add(new ListView<Attachment>("String_Node_Str",attachmentList){
    private Attachment attachment;
    protected void populateItem(    ListItem<Attachment> listItem){
      attachment=listItem.getModelObject();
      PageParameters params=new PageParameters();
      listItem.add(new GravatarLinkPanel("String_Node_Str",attachment.getUser(),ICON_EDGE_LENGTH));
      listItem.add(new Label("String_Node_Str",attachment.getUser().getFullnameOrUsername()));
      params.add("String_Node_Str",attachment.getUser().getUsername());
      params.add("String_Node_Str","String_Node_Str");
      BookmarkablePageLink usernameLink=new BookmarkablePageLink("String_Node_Str",ViewIssue.this.getPageClass("String_Node_Str"),params);
      usernameLink.add(new Label("String_Node_Str",attachment.getUser().getFullnameOrUsername()));
      listItem.add(usernameLink);
      listItem.add(new Label("String_Node_Str",new FormattedDateModel(attachment.getCreated(),((HeadsUpSession)getSession()).getTimeZone())));
      final File file=attachment.getFile(getStorage());
      Mime mime=Mime.get(file.getName());
      listItem.add(new Image("String_Node_Str",new ResourceReference(Mime.class,mime.getIconName())));
      listItem.add(new EmbeddedFilePanel("String_Node_Str",attachment.getFile(getStorage()),getProject()));
      Link download=new DownloadLink("String_Node_Str",file);
      download.add(new Label("String_Node_Str",attachment.getFilename()));
      listItem.add(download);
      User currentUser=((HeadsUpSession)getSession()).getUser();
      listItem.add(new Link("String_Node_Str"){
        @Override public void onClick(){
          attachment=(Attachment)((HibernateStorage)getStorage()).getHibernateSession().merge(attachment);
          issue=(Issue)((HibernateStorage)getStorage()).getHibernateSession().merge(issue);
          attachmentList.remove(attachment);
          issue.getAttachments().remove(attachment);
          ((HibernateStorage)getStorage()).delete(attachment);
          attachment.getFile(getStorage()).delete();
        }
      }
.setVisible(Manager.getSecurityInstance().userHasPermission(currentUser,new IssueEditPermission(),getProject())));
      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 commentList=new LinkedList();
  commentList.addAll(issue.getComments());
  if (issue.getTimeWorked() != null && Boolean.parseBoolean(issue.getProject().getConfigurationValue(StoredProject.CONFIGURATION_TIMETRACKING_ENABLED))) {
    commentList.addAll(issue.getTimeWorked());
  }
  Collections.sort(commentList,new Comparator(){
    public int compare(    Object o1,    Object o2){
      Date date1=null, date2=null;
      if (o1 instanceof Comment) {
        date1=((Comment)o1).getCreated();
      }
 else       if (o1 instanceof DurationWorked) {
        date1=((DurationWorked)o1).getDay();
      }
      if (o2 instanceof Comment) {
        date2=((Comment)o2).getCreated();
      }
 else       if (o2 instanceof DurationWorked) {
        date2=((DurationWorked)o2).getDay();
      }
      if (date1 == null || date2 == null) {
        if (date1 == null) {
          if (date2 == null) {
            return 0;
          }
 else {
            return 1;
          }
        }
 else {
          return -1;
        }
      }
      return date1.compareTo(date2);
    }
  }
);
  add(new ListView("String_Node_Str",commentList){
    protected void populateItem(    ListItem listItem){
      CommentPanel panel=new CommentPanel("String_Node_Str",listItem.getModel(),getProject(),commentList,issue);
      listItem.add(panel);
    }
  }
);
}

Fixed version (ground truth):
public void layout(){
  super.layout();
  add(CSSPackageResource.getHeaderContribution(getClass(),"String_Node_Str"));
  add(CSSPackageResource.getHeaderContribution(IssueListPanel.class,"String_Node_Str"));
  try {
    issueId=getPageParameters().getLong("String_Node_Str");
  }
 catch (  NumberFormatException e) {
    notFoundError();
    return;
  }
  issue=IssuesApplication.getIssue(issueId,getProject());
  if (issue == null) {
    notFoundError();
    return;
  }
  watching=issue.getWatchers().contains(getSession().getUser());
  List<MenuLink> links=getLinks(issue);
  if (issue.getStatus() < Issue.STATUS_CLOSED) {
    links.add(1,new MenuLink(){
      public String getLabel(){
        if (watching) {
          return "String_Node_Str";
        }
        return "String_Node_Str";
      }
      public void onClick(){
        toggleWatching();
      }
    }
);
  }
  addLinks(links);
  issuePanel=new IssuePanel("String_Node_Str",issue,ViewIssue.this);
  add(issuePanel);
  final List<Attachment> attachmentList=new LinkedList<Attachment>();
  attachmentList.addAll(issue.getAttachments());
  Collections.sort(attachmentList,new Comparator<Attachment>(){
    public int compare(    Attachment attachment1,    Attachment attachment2){
      return attachment1.getCreated().compareTo(attachment2.getCreated());
    }
  }
);
  add(new ListView<Attachment>("String_Node_Str",attachmentList){
    private Attachment attachment;
    protected void populateItem(    ListItem<Attachment> listItem){
      attachment=listItem.getModelObject();
      PageParameters params=new PageParameters();
      listItem.add(new GravatarLinkPanel("String_Node_Str",attachment.getUser(),ICON_EDGE_LENGTH));
      params.add("String_Node_Str",attachment.getUser().getUsername());
      params.add("String_Node_Str","String_Node_Str");
      BookmarkablePageLink usernameLink=new BookmarkablePageLink("String_Node_Str",ViewIssue.this.getPageClass("String_Node_Str"),params);
      usernameLink.add(new Label("String_Node_Str",attachment.getUser().getFullnameOrUsername()));
      listItem.add(usernameLink);
      listItem.add(new Label("String_Node_Str",new FormattedDateModel(attachment.getCreated(),((HeadsUpSession)getSession()).getTimeZone())));
      final File file=attachment.getFile(getStorage());
      Mime mime=Mime.get(file.getName());
      listItem.add(new Image("String_Node_Str",new ResourceReference(Mime.class,mime.getIconName())));
      listItem.add(new EmbeddedFilePanel("String_Node_Str",attachment.getFile(getStorage()),getProject()));
      Link download=new DownloadLink("String_Node_Str",file);
      download.add(new Label("String_Node_Str",attachment.getFilename()));
      listItem.add(download);
      User currentUser=((HeadsUpSession)getSession()).getUser();
      listItem.add(new Link("String_Node_Str"){
        @Override public void onClick(){
          attachment=(Attachment)((HibernateStorage)getStorage()).getHibernateSession().merge(attachment);
          issue=(Issue)((HibernateStorage)getStorage()).getHibernateSession().merge(issue);
          attachmentList.remove(attachment);
          issue.getAttachments().remove(attachment);
          ((HibernateStorage)getStorage()).delete(attachment);
          attachment.getFile(getStorage()).delete();
        }
      }
.setVisible(Manager.getSecurityInstance().userHasPermission(currentUser,new IssueEditPermission(),getProject())));
      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 commentList=new LinkedList();
  commentList.addAll(issue.getComments());
  if (issue.getTimeWorked() != null && Boolean.parseBoolean(issue.getProject().getConfigurationValue(StoredProject.CONFIGURATION_TIMETRACKING_ENABLED))) {
    commentList.addAll(issue.getTimeWorked());
  }
  Collections.sort(commentList,new Comparator(){
    public int compare(    Object o1,    Object o2){
      Date date1=null, date2=null;
      if (o1 instanceof Comment) {
        date1=((Comment)o1).getCreated();
      }
 else       if (o1 instanceof DurationWorked) {
        date1=((DurationWorked)o1).getDay();
      }
      if (o2 instanceof Comment) {
        date2=((Comment)o2).getCreated();
      }
 else       if (o2 instanceof DurationWorked) {
        date2=((DurationWorked)o2).getDay();
      }
      if (date1 == null || date2 == null) {
        if (date1 == null) {
          if (date2 == null) {
            return 0;
          }
 else {
            return 1;
          }
        }
 else {
          return -1;
        }
      }
      return date1.compareTo(date2);
    }
  }
);
  add(new ListView("String_Node_Str",commentList){
    protected void populateItem(    ListItem listItem){
      CommentPanel panel=new CommentPanel("String_Node_Str",listItem.getModel(),getProject(),commentList,issue);
      listItem.add(panel);
    }
  }
);
}