Program: 69316
Project: 69316
Buggy source:
/** 
 * Add event handling to the hotspot
 */
private void addEventHandling(Element elm,StructureSource src,Trigger[] triggers,Cursor cursor){
  if (elm != null && triggers != null) {
    if (triggers != null && triggers.length > 0) {
      setCursorAttribute(elm,cursor,defaultCursor);
    }
    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:
    ActionValue av=tg.getAction().getValue();
  if (av instanceof URLValue) {
    URLValue urlValue=(URLValue)av;
    setURLValueAttributes(urlValue,elm,src,scriptEvent,bDblClick);
  }
 else   if (av instanceof MultiURLValues) {
    MultiURLValues muv=(MultiURLValues)av;
    List<URLValue> validURLValues=MultiURLValuesScriptGenerator.getValidURLValues(muv);
    int size=validURLValues.size();
    if (size == 0) {
      setTooltipForURLRedirect(elm,src,muv.getTooltip());
      break;
    }
    if (size == 1) {
      setURLValueAttributes(validURLValues.get(0),elm,src,scriptEvent,bDblClick);
      setTooltipForURLRedirect(elm,src,muv.getTooltip());
    }
 else {
      setMultiURLValuesAttributes(muv,elm,src,scriptEvent,bDblClick);
    }
    setTooltipForURLRedirect(elm,src,muv.getTooltip());
  }
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()));
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,Cursor cursor){
  if (elm != null && triggers != null) {
    if (triggers != null && triggers.length > 0) {
      setCursorAttribute(elm,cursor,defaultCursor);
    }
    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:
    ActionValue av=tg.getAction().getValue();
  if (av instanceof URLValue) {
    URLValue urlValue=(URLValue)av;
    setURLValueAttributes(urlValue,elm,src,scriptEvent,bDblClick);
  }
 else   if (av instanceof MultiURLValues) {
    MultiURLValues muv=(MultiURLValues)av;
    List<URLValue> validURLValues=MultiURLValuesScriptGenerator.getValidURLValues(muv);
    int size=validURLValues.size();
    if (size == 0) {
      setTooltipForURLRedirect(elm,src,muv.getTooltip());
      break;
    }
    if (size == 1) {
      setURLValueAttributes(validURLValues.get(0),elm,src,scriptEvent,bDblClick);
      setTooltipForURLRedirect(elm,src,muv.getTooltip());
    }
 else {
      setMultiURLValuesAttributes(muv,elm,src,scriptEvent,bDblClick);
    }
    setTooltipForURLRedirect(elm,src,muv.getTooltip());
  }
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");
int hashCode=script.hashCode();
if (hashCode != Integer.MIN_VALUE) {
callbackFunction.append(Math.abs(hashCode));
}
 else {
callbackFunction.append(Integer.MAX_VALUE);
}
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()));
if (!(scripts.contains(script))) {
if (hashCode != Integer.MIN_VALUE) {
svg_g2d.addScript("String_Node_Str" + Math.abs(hashCode) + "String_Node_Str"+ "String_Node_Str"+ script+ "String_Node_Str");
}
 else {
svg_g2d.addScript("String_Node_Str" + Integer.MAX_VALUE + "String_Node_Str"+ "String_Node_Str"+ script+ "String_Node_Str");
}
scripts.add(script);
}
}
break;
}
}
}
}
}