Program: 145636
Project: 145636
Buggy source:
private void setIconAndAlign(final CellButtonBase<?> btn,Element aTag) throws Exception {
  btn.setIconAlign(IconAlign.LEFT);
  if (aTag.hasAttribute("String_Node_Str")) {
    int horizontalTextPosition=Utils.getIntegerAttribute(aTag,"String_Node_Str",11);
switch (horizontalTextPosition) {
case 4:
      btn.setIconAlign(IconAlign.LEFT);
    break;
case 2:
  btn.setIconAlign(IconAlign.RIGHT);
break;
case 0:
btn.setIconAlign(IconAlign.LEFT);
break;
case 10:
btn.setIconAlign(IconAlign.RIGHT);
break;
case 11:
btn.setIconAlign(IconAlign.LEFT);
break;
default :
btn.setIconAlign(IconAlign.LEFT);
break;
}
}
if (aTag.hasAttribute("String_Node_Str")) {
int verticalTextPosition=Utils.getIntegerAttribute(aTag,"String_Node_Str",0);
switch (verticalTextPosition) {
case 0:
btn.setIconAlign(IconAlign.LEFT);
break;
case 1:
btn.setIconAlign(IconAlign.BOTTOM);
break;
case 3:
btn.setIconAlign(IconAlign.TOP);
break;
default :
btn.setIconAlign(IconAlign.LEFT);
break;
}
}
btn.setScale(ButtonScale.SMALL);
if (aTag.hasAttribute("String_Node_Str")) {
btn.setIcon(AppClient.getInstance().getImageResource(aTag.getAttribute("String_Node_Str")).addCallback(new ImageResourceCallback(){
@Override public void run(ImageResource aResource){
btn.setIcon(aResource);
Scheduler.get().scheduleDeferred(new ScheduledCommand(){
@Override public void execute(){
if (btn.getParent() instanceof ResizeContainer) {
ResizeContainer c=(ResizeContainer)btn.getParent();
Size s=XElement.as(c.getElement().getParentElement()).getSize(true);
c.setPixelSize(s.getWidth() + 1,s.getHeight());
c.setPixelSize(s.getWidth() - 1,s.getHeight());
}
 else if (btn.getParent() instanceof HasLayout) {
((HasLayout)btn.getParent()).forceLayout();
}
}
}
);
}
}
));
}
}

Fixed version (ground truth):
private void setIconAndAlign(final CellButtonBase<?> btn,Element aTag,final PublishedComponent aPublished) throws Exception {
  btn.setIconAlign(IconAlign.LEFT);
  if (aTag.hasAttribute("String_Node_Str")) {
    int horizontalTextPosition=Utils.getIntegerAttribute(aTag,"String_Node_Str",11);
switch (horizontalTextPosition) {
case 4:
      btn.setIconAlign(IconAlign.LEFT);
    break;
case 2:
  btn.setIconAlign(IconAlign.RIGHT);
break;
case 0:
btn.setIconAlign(IconAlign.LEFT);
break;
case 10:
btn.setIconAlign(IconAlign.RIGHT);
break;
case 11:
btn.setIconAlign(IconAlign.LEFT);
break;
default :
btn.setIconAlign(IconAlign.LEFT);
break;
}
}
if (aTag.hasAttribute("String_Node_Str")) {
int verticalTextPosition=Utils.getIntegerAttribute(aTag,"String_Node_Str",0);
switch (verticalTextPosition) {
case 0:
btn.setIconAlign(IconAlign.LEFT);
break;
case 1:
btn.setIconAlign(IconAlign.BOTTOM);
break;
case 3:
btn.setIconAlign(IconAlign.TOP);
break;
default :
btn.setIconAlign(IconAlign.LEFT);
break;
}
}
btn.setScale(ButtonScale.SMALL);
if (aTag.hasAttribute("String_Node_Str")) {
btn.setIcon(AppClient.getInstance().getImageResource(aTag.getAttribute("String_Node_Str")).addCallback(new ImageResourceCallback(){
@Override public void run(ImageResource aResource){
btn.setIcon(aResource);
Scheduler.get().scheduleDeferred(new ScheduledCommand(){
@Override public void execute(){
if (btn.getParent() instanceof ResizeContainer) {
ResizeContainer c=(ResizeContainer)btn.getParent();
Size s=XElement.as(c.getElement().getParentElement()).getSize(true);
c.setPixelSize(s.getWidth() + 1,s.getHeight());
c.setPixelSize(s.getWidth() - 1,s.getHeight());
}
 else if (btn.getParent() instanceof HasLayout) {
((HasLayout)btn.getParent()).forceLayout();
}
}
}
);
}
}
));
}
}