Program: 73802
Project: 73802
Buggy source:
/** 
 * Add event handling to the hotspot
 */
private void addEventHandling(Element elm,StructureSource src,Trigger[] triggers){
  if (elm != null) {
    boolean redirect=false;
    for (int x=0; x < triggers.length; x++) {
      Trigger tg=triggers[x];
      if (tg.getAction().getType().getValue() == ActionType.URL_REDIRECT) {
        redirect=true;
        break;
      }
    }
    if (redirect) {
      Element aLink=svg_g2d.createElement("String_Node_Str");
      Element group=svg_g2d.createElement("String_Node_Str");
      group.appendChild(elm);
      aLink.setAttribute("String_Node_Str","String_Node_Str");
      aLink.appendChild(group);
      elm=group;
      hotspotLayer.appendChild(aLink);
    }
 else     hotspotLayer.appendChild(elm);
    for (int x=0; x < triggers.length; x++) {
      Trigger tg=triggers[x];
      String scriptEvent=getJsScriptEvent(tg.getCondition().getValue());
      if (scriptEvent != null) {
        boolean bDblClick=false;
        if (scriptEvent.equals("String_Node_Str")) {
          scriptEvent="String_Node_Str";
          bDblClick=true;
        }
switch (tg.getAction().getType().getValue()) {
case ActionType.SHOW_TOOLTIP:
          String tooltipText=((TooltipValue)tg.getAction().getValue()).getText();
        if ((tooltipText != null) && (tooltipText.trim().length() > 0)) {
          Element title=svg_g2d.dom.createElement("String_Node_Str");
          title.appendChild(svg_g2d.dom.createTextNode(tooltipText));
          elm.appendChild(title);
          String componentId=null;
          if (src instanceof WrappedStructureSource) {
            componentId=findFirstComponentId((WrappedStructureSource)src);
          }
          if (scriptEvent.equals("String_Node_Str")) {
            elm.setAttribute("String_Node_Str","String_Node_Str");
            if (componentId != null)             elm.setAttribute("String_Node_Str","String_Node_Str" + componentId + "String_Node_Str");
 else             elm.setAttribute("String_Node_Str","String_Node_Str");
          }
 else {
            if (componentId != null) {
              elm.setAttribute(scriptEvent,wrapJS(bDblClick,"String_Node_Str" + componentId + "String_Node_Str"));
            }
 else {
              elm.setAttribute(scriptEvent,wrapJS(bDblClick,"String_Node_Str"));
            }
          }
        }
      break;
case ActionType.URL_REDIRECT:
    URLValue urlValue=((URLValue)tg.getAction().getValue());
  if (urlValue.getBaseUrl().startsWith("String_Node_Str")) {
    elm.setAttribute(scriptEvent,wrapJS(bDblClick,"String_Node_Str" + urlValue.getBaseUrl() + "String_Node_Str"));
    elm.setAttribute("String_Node_Str","String_Node_Str");
  }
 else   if (urlValue.getBaseUrl().startsWith("String_Node_Str")) {
    elm.setAttribute(scriptEvent,wrapJS(bDblClick,urlValue.getBaseUrl()));
    elm.setAttribute("String_Node_Str","String_Node_Str");
  }
 else {
    String target=urlValue.getTarget();
    if (target == null)     target="String_Node_Str";
    String jsRedirect="String_Node_Str" + target + "String_Node_Str"+ urlValue.getBaseUrl()+ "String_Node_Str";
    elm.setAttribute(scriptEvent,wrapJS(bDblClick,"String_Node_Str" + jsRedirect + "String_Node_Str"+ jsRedirect+ "String_Node_Str"));
  }
break;
case ActionType.TOGGLE_VISIBILITY:
case ActionType.TOGGLE_DATA_POINT_VISIBILITY:
case ActionType.HIGHLIGHT:
addJSCodeOnElement(src,tg,elm,scriptEvent,tg.getAction().getType().getValue(),bDblClick);
break;
case ActionType.INVOKE_SCRIPT:
if (tg.getCondition().equals(TriggerCondition.ACCESSIBILITY_LITERAL)) {
AccessibilityValue accessValue=((AccessibilityValue)tg.getAction().getValue());
if (accessValue.getText() != null) {
Element title=svg_g2d.createElement("String_Node_Str");
title.appendChild(svg_g2d.dom.createTextNode(accessValue.getText()));
elm.appendChild(title);
}
if (accessValue.getAccessibility() != null) {
Element description=svg_g2d.createElement("String_Node_Str");
description.appendChild(svg_g2d.dom.createTextNode(accessValue.getAccessibility()));
elm.appendChild(description);
}
}
 else {
String script=((ScriptValue)tg.getAction().getValue()).getScript();
String callbackFunction="String_Node_Str" + Math.abs(script.hashCode()) + "String_Node_Str"+ src.getSource().hashCode();
if (StructureType.SERIES_DATA_POINT.equals(src.getType())) {
final DataPointHints dph=(DataPointHints)src.getSource();
callbackFunction+="String_Node_Str";
callbackFunction=ScriptUtil.script(callbackFunction,dph);
}
callbackFunction+="String_Node_Str";
elm.setAttribute(scriptEvent,wrapJS(bDblClick,callbackFunction));
setCursor(elm);
if (!(scripts.contains(script))) {
svg_g2d.addScript("String_Node_Str" + Math.abs(script.hashCode()) + "String_Node_Str"+ "String_Node_Str"+ script+ "String_Node_Str");
scripts.add(script);
}
}
break;
}
}
}
}
}

Fixed version (ground truth):
/** 
 * Add event handling to the hotspot
 */
private void addEventHandling(Element elm,StructureSource src,Trigger[] triggers){
  if (elm != null) {
    boolean redirect=false;
    for (int x=0; x < triggers.length; x++) {
      Trigger tg=triggers[x];
      if (tg.getAction().getType().getValue() == ActionType.URL_REDIRECT) {
        redirect=true;
        break;
      }
    }
    if (redirect) {
      Element aLink=svg_g2d.createElement("String_Node_Str");
      Element group=svg_g2d.createElement("String_Node_Str");
      group.appendChild(elm);
      aLink.setAttribute("String_Node_Str","String_Node_Str");
      aLink.appendChild(group);
      elm=group;
      hotspotLayer.appendChild(aLink);
    }
 else     hotspotLayer.appendChild(elm);
    for (int x=0; x < triggers.length; x++) {
      Trigger tg=triggers[x];
      String scriptEvent=getJsScriptEvent(tg.getCondition().getValue());
      if (scriptEvent != null) {
        boolean bDblClick=false;
        if (scriptEvent.equals("String_Node_Str")) {
          scriptEvent="String_Node_Str";
          bDblClick=true;
        }
switch (tg.getAction().getType().getValue()) {
case ActionType.SHOW_TOOLTIP:
          String tooltipText=((TooltipValue)tg.getAction().getValue()).getText();
        if ((tooltipText != null) && (tooltipText.trim().length() > 0)) {
          Element title=svg_g2d.dom.createElement("String_Node_Str");
          title.appendChild(svg_g2d.dom.createTextNode(tooltipText));
          elm.appendChild(title);
          String componentId=null;
          if (src instanceof WrappedStructureSource) {
            componentId=findFirstComponentId((WrappedStructureSource)src);
          }
          if (scriptEvent.equals("String_Node_Str")) {
            elm.setAttribute("String_Node_Str","String_Node_Str");
            if (componentId != null)             elm.setAttribute("String_Node_Str","String_Node_Str" + componentId + "String_Node_Str");
 else             elm.setAttribute("String_Node_Str","String_Node_Str");
          }
 else {
            if (componentId != null) {
              elm.setAttribute(scriptEvent,wrapJS(bDblClick,"String_Node_Str" + componentId + "String_Node_Str"));
            }
 else {
              elm.setAttribute(scriptEvent,wrapJS(bDblClick,"String_Node_Str"));
            }
          }
        }
      break;
case ActionType.URL_REDIRECT:
    URLValue urlValue=((URLValue)tg.getAction().getValue());
  if (urlValue.getBaseUrl().startsWith("String_Node_Str")) {
    elm.setAttribute(scriptEvent,wrapJS(bDblClick,"String_Node_Str" + urlValue.getBaseUrl() + "String_Node_Str"));
    elm.setAttribute("String_Node_Str","String_Node_Str");
  }
 else   if (urlValue.getBaseUrl().startsWith("String_Node_Str")) {
    elm.setAttribute(scriptEvent,wrapJS(bDblClick,urlValue.getBaseUrl()));
    elm.setAttribute("String_Node_Str","String_Node_Str");
  }
 else {
    String target=urlValue.getTarget();
    if (target == null)     target="String_Node_Str";
    String jsRedirect="String_Node_Str" + target + "String_Node_Str"+ urlValue.getBaseUrl()+ "String_Node_Str";
    elm.setAttribute(scriptEvent,wrapJS(bDblClick,"String_Node_Str" + jsRedirect + "String_Node_Str"+ jsRedirect+ "String_Node_Str"));
  }
break;
case ActionType.TOGGLE_VISIBILITY:
case ActionType.TOGGLE_DATA_POINT_VISIBILITY:
case ActionType.HIGHLIGHT:
addJSCodeOnElement(src,tg,elm,scriptEvent,tg.getAction().getType().getValue(),bDblClick);
break;
case ActionType.INVOKE_SCRIPT:
if (tg.getCondition().equals(TriggerCondition.ACCESSIBILITY_LITERAL)) {
AccessibilityValue accessValue=((AccessibilityValue)tg.getAction().getValue());
if (accessValue.getText() != null) {
Element title=svg_g2d.createElement("String_Node_Str");
title.appendChild(svg_g2d.dom.createTextNode(accessValue.getText()));
elm.appendChild(title);
}
if (accessValue.getAccessibility() != null) {
Element description=svg_g2d.createElement("String_Node_Str");
description.appendChild(svg_g2d.dom.createTextNode(accessValue.getAccessibility()));
elm.appendChild(description);
}
}
 else {
String script=((ScriptValue)tg.getAction().getValue()).getScript();
StringBuffer callbackFunction=new StringBuffer("String_Node_Str");
callbackFunction.append(Math.abs(script.hashCode()));
callbackFunction.append("String_Node_Str");
callbackFunction.append(src.getSource().hashCode());
if (StructureType.SERIES_DATA_POINT.equals(src.getType())) {
final DataPointHints dph=(DataPointHints)src.getSource();
ScriptUtil.script(callbackFunction,dph);
}
callbackFunction.append("String_Node_Str");
elm.setAttribute(scriptEvent,wrapJS(bDblClick,callbackFunction.toString()));
setCursor(elm);
if (!(scripts.contains(script))) {
svg_g2d.addScript("String_Node_Str" + Math.abs(script.hashCode()) + "String_Node_Str"+ "String_Node_Str"+ script+ "String_Node_Str");
scripts.add(script);
}
}
break;
}
}
}
}
}