Program: 143616
Project: 143616
Buggy source:
public Component getTableCellRendererComponent(JTable jtable,Object value,boolean isSelected,boolean hasFocus,final int row,final int column){
  if (renderer == null || !isVisible(renderer) || !(jtable.getModel() instanceof IFoundSetInternal)) {
    return empty;
  }
  final ISwingFoundSet foundset=(ISwingFoundSet)jtable.getModel();
  final IRecordInternal state;
  try {
    state=foundset.getRecord(row);
  }
 catch (  RuntimeException re) {
    Debug.error("String_Node_Str",re);
    return empty;
  }
  RenderEventExecutor renderEventExecutor=null;
  IScriptRenderMethods renderable=null;
  if (renderer instanceof IScriptableProvider) {
    IScriptable scriptable=((IScriptableProvider)renderer).getScriptObject();
    if (scriptable instanceof ISupportOnRenderCallback) {
      renderEventExecutor=((ISupportOnRenderCallback)scriptable).getRenderEventExecutor();
      renderable=((ISupportOnRenderCallback)scriptable).getRenderable();
    }
  }
  Color bgColor=getBgColor(jtable,isSelected,row,false);
  if (bgColor != null && renderer instanceof JComponent)   ((JComponent)renderer).setOpaque(true);
  Color fgColor=getFgColor(jtable,isSelected,row);
  Font font=getFont(jtable,isSelected,row);
  if (editor != null && editor.getParent() == null) {
    Rectangle cellRect=jtable.getCellRect(row,column,false);
    editor.setLocation(cellRect.x,cellRect.y);
    editor.setSize(cellRect.width,cellRect.height);
  }
  if (isSelected) {
    Color tableSelectionColor=jtable.getSelectionForeground();
    if (bgColor != null) {
      int red=Math.abs(tableSelectionColor.getRed() - bgColor.getRed());
      int blue=Math.abs(tableSelectionColor.getBlue() - bgColor.getBlue());
      int green=Math.abs(tableSelectionColor.getGreen() - bgColor.getBlue());
      if (red < 128 && blue < 128 && green < 128) {
        red=Math.abs(tableSelectionColor.getRed() - 255);
        blue=Math.abs(tableSelectionColor.getBlue() - 255);
        green=Math.abs(tableSelectionColor.getGreen() - 255);
        tableSelectionColor=new Color(red,blue,green);
      }
    }
    renderer.setForeground(fgColor != null ? fgColor : tableSelectionColor);
    renderer.setBackground((bgColor != null ? bgColor : jtable.getSelectionBackground()));
    if (font != null)     renderer.setFont(font);
  }
 else {
    boolean isRenderWithOnRender=renderEventExecutor != null && renderEventExecutor.hasRenderCallback() && renderable instanceof RenderableWrapper;
    if (isRenderWithOnRender) {
      Color newBGColor=bgColor != null ? bgColor : componentBgColor;
      if (newBGColor != null) {
        ((RenderableWrapper)renderable).clearProperty(RenderableWrapper.PROPERTY.BGCOLOR);
        renderer.setBackground(newBGColor);
      }
      Color newFGColor=fgColor != null ? fgColor : componentFgColor;
      if (newFGColor != null) {
        ((RenderableWrapper)renderable).clearProperty(RenderableWrapper.PROPERTY.FGCOLOR);
        renderer.setForeground(newFGColor);
      }
      Font newFont=font != null ? font : componentFont;
      if (newFont != null) {
        ((RenderableWrapper)renderable).clearProperty(RenderableWrapper.PROPERTY.FONT);
        renderer.setFont(newFont);
      }
    }
 else {
      Color background=editor.getBackground();
      if (background != null && !background.equals(lastEditorBgColor)) {
        unselectedBackground=background;
      }
      Color foreground=editor.getForeground();
      if (foreground != null && !foreground.equals(lastEditorFgColor)) {
        unselectedForeground=foreground;
      }
      Font editorFont=editor.getFont();
      if (editorFont != null && !editorFont.equals(lastEditorFont)) {
        unselectedFont=editorFont;
      }
      if (editor instanceof IDisplayData && ((IDisplayData)editor).isValueValid() || !(editor instanceof IDisplayData)) {
        Color currentForeground=(fgColor != null ? fgColor : (unselectedForeground != null) ? unselectedForeground : jtable.getForeground());
        renderer.setForeground(currentForeground);
      }
      Color currentColor=(bgColor != null ? bgColor : (unselectedBackground != null) ? unselectedBackground : jtable.getBackground());
      renderer.setBackground(currentColor);
      Font currentFont=(font != null ? font : (unselectedFont != null) ? unselectedFont : jtable.getFont());
      renderer.setFont(currentFont);
    }
  }
  if (renderer instanceof JComponent) {
    applyRowBorder((JComponent)renderer,jtable,isSelected,row,column,hasFocus);
  }
  boolean printing=Utils.getAsBoolean(application.getRuntimeProperties().get("String_Node_Str"));
  if (renderEventExecutor != null && renderEventExecutor.hasRenderCallback()) {
    renderEventExecutor.setRenderState(state,row,isSelected);
  }
  if (renderer instanceof IDisplayRelatedData) {
    IDisplayRelatedData drd=(IDisplayRelatedData)renderer;
    String relationName=drd.getSelectedRelationName();
    if (state != null) {
      if (relationName != null) {
        if (!printing && !state.isRelatedFoundSetLoaded(relationName,null)) {
          IApplication app=dal.getApplication();
          ((IDisplayData)renderer).setValueObject(null);
          String key=row + "String_Node_Str" + relationName+ "String_Node_Str"+ null;
          if (!rowAndDataprovider.containsKey(key)) {
            rowAndDataprovider.put(key,key);
            Runnable r=new ASynchonizedCellLoad(app,jtable,foundset,row,jtable.convertColumnIndexToModel(column),relationName,drd.getDefaultSort(),null);
            app.getScheduledExecutor().execute(r);
          }
          return renderer.isVisible() ? renderer : empty;
        }
      }
      drd.setRecord(state,true);
    }
  }
  if (renderer instanceof IDisplayData) {
    if (state != null) {
      Object data=null;
      if (dataProviderID != null) {
        int index=-1;
        if (!printing && (index=dataProviderID.indexOf('.')) > 0) {
          if (!ScopesUtils.isVariableScope(dataProviderID)) {
            String partName=dataProviderID.substring(0,index);
            final String restName=dataProviderID.substring(index + 1);
            String relationName=partName;
            if (relationName != null && !state.isRelatedFoundSetLoaded(relationName,restName)) {
              IApplication app=dal.getApplication();
              ((IDisplayData)renderer).setValueObject(null);
              String key=row + "String_Node_Str" + relationName+ "String_Node_Str"+ restName;
              if (!rowAndDataprovider.containsKey(key)) {
                rowAndDataprovider.put(key,key);
                List<SortColumn> defaultPKSortColumns=null;
                try {
                  defaultPKSortColumns=app.getFoundSetManager().getDefaultPKSortColumns(app.getFlattenedSolution().getRelation(relationName).getForeignDataSource());
                }
 catch (                ServoyException e) {
                  Debug.error(e);
                }
                Runnable r=new ASynchonizedCellLoad(app,jtable,foundset,row,jtable.convertColumnIndexToModel(column),relationName,defaultPKSortColumns,restName);
                app.getScheduledExecutor().execute(r);
              }
              return renderer.isVisible() ? renderer : empty;
            }
            IFoundSetInternal rfs=state.getRelatedFoundSet(relationName);
            if (rfs != null) {
              int selected=rfs.getSelectedIndex();
              if (selected == -1 && rfs.getSize() > 0) {
                selected=0;
              }
              final IRecordInternal relState=rfs.getRecord(selected);
              if (testCalc(restName,relState,row,jtable.convertColumnIndexToModel(column),foundset))               return renderer;
            }
          }
        }
        if (!((IDisplayData)renderer).needEntireState() && !printing && testCalc(dataProviderID,state,row,jtable.convertColumnIndexToModel(column),foundset)) {
          return renderer;
        }
        try {
          data=dal.getValueObject(state,dataProviderID);
        }
 catch (        IllegalArgumentException iae) {
          Debug.error(iae);
          data="String_Node_Str";
        }
      }
      ((IDisplayData)renderer).setTagResolver(new ITagResolver(){
        public String getStringValue(        String name){
          return TagResolver.formatObject(dal.getValueObject(state,name),dal.getApplication().getSettings());
        }
      }
);
      if (data instanceof DbIdentValue) {
        data=((DbIdentValue)data).getPkValue();
      }
      ((IDisplayData)renderer).setValueObject(data);
    }
  }
  if (renderer instanceof IServoyAwareBean && state != null) {
    ((IServoyAwareBean)renderer).setSelectedRecord(new ServoyBeanState(state,dal.getFormScope()));
  }
  if (!(renderer instanceof IDisplayData) && !(renderer instanceof IDisplayRelatedData) && renderEventExecutor != null && renderEventExecutor.hasRenderCallback()) {
    renderEventExecutor.fireOnRender(false);
  }
  return renderer.isVisible() ? renderer : empty;
}

Fixed version (ground truth):
public Component getTableCellRendererComponent(JTable jtable,Object value,boolean isSelected,boolean hasFocus,final int row,final int column){
  if (renderer == null || !isVisible(renderer) || !(jtable.getModel() instanceof IFoundSetInternal)) {
    return empty;
  }
  final ISwingFoundSet foundset=(ISwingFoundSet)jtable.getModel();
  final IRecordInternal state;
  try {
    state=foundset.getRecord(row);
  }
 catch (  RuntimeException re) {
    Debug.error("String_Node_Str",re);
    return empty;
  }
  RenderEventExecutor renderEventExecutor=null;
  IScriptRenderMethods renderable=null;
  if (renderer instanceof IScriptableProvider) {
    IScriptable scriptable=((IScriptableProvider)renderer).getScriptObject();
    if (scriptable instanceof ISupportOnRenderCallback) {
      renderEventExecutor=((ISupportOnRenderCallback)scriptable).getRenderEventExecutor();
      renderable=((ISupportOnRenderCallback)scriptable).getRenderable();
    }
  }
  Color bgColor=getBgColor(jtable,isSelected,row,false);
  if (bgColor != null && renderer instanceof JComponent)   ((JComponent)renderer).setOpaque(true);
  Color fgColor=getFgColor(jtable,isSelected,row);
  Font font=getFont(jtable,isSelected,row);
  if (editor != null && editor.getParent() == null) {
    Rectangle cellRect=jtable.getCellRect(row,column,false);
    editor.setLocation(cellRect.x,cellRect.y);
    editor.setSize(cellRect.width,cellRect.height);
  }
  if (isSelected) {
    Color tableSelectionColor=jtable.getSelectionForeground();
    if (bgColor != null) {
      int red=Math.abs(tableSelectionColor.getRed() - bgColor.getRed());
      int blue=Math.abs(tableSelectionColor.getBlue() - bgColor.getBlue());
      int green=Math.abs(tableSelectionColor.getGreen() - bgColor.getBlue());
      if (red < 128 && blue < 128 && green < 128) {
        red=Math.abs(tableSelectionColor.getRed() - 255);
        blue=Math.abs(tableSelectionColor.getBlue() - 255);
        green=Math.abs(tableSelectionColor.getGreen() - 255);
        tableSelectionColor=new Color(red,blue,green);
      }
    }
    renderer.setForeground(fgColor != null ? fgColor : tableSelectionColor);
    renderer.setBackground((bgColor != null ? bgColor : jtable.getSelectionBackground()));
    if (font != null)     renderer.setFont(font);
  }
 else {
    boolean isRenderWithOnRender=renderEventExecutor != null && renderEventExecutor.hasRenderCallback() && renderable instanceof RenderableWrapper;
    if (isRenderWithOnRender) {
      Color newBGColor=bgColor != null ? bgColor : componentBgColor;
      if (newBGColor != null) {
        ((RenderableWrapper)renderable).clearProperty(RenderableWrapper.PROPERTY_BGCOLOR);
        renderer.setBackground(newBGColor);
      }
      Color newFGColor=fgColor != null ? fgColor : componentFgColor;
      if (newFGColor != null) {
        ((RenderableWrapper)renderable).clearProperty(RenderableWrapper.PROPERTY_FGCOLOR);
        renderer.setForeground(newFGColor);
      }
      Font newFont=font != null ? font : componentFont;
      if (newFont != null) {
        ((RenderableWrapper)renderable).clearProperty(RenderableWrapper.PROPERTY_FONT);
        renderer.setFont(newFont);
      }
    }
 else {
      Color background=editor.getBackground();
      if (background != null && !background.equals(lastEditorBgColor)) {
        unselectedBackground=background;
      }
      Color foreground=editor.getForeground();
      if (foreground != null && !foreground.equals(lastEditorFgColor)) {
        unselectedForeground=foreground;
      }
      Font editorFont=editor.getFont();
      if (editorFont != null && !editorFont.equals(lastEditorFont)) {
        unselectedFont=editorFont;
      }
      if (editor instanceof IDisplayData && ((IDisplayData)editor).isValueValid() || !(editor instanceof IDisplayData)) {
        Color currentForeground=(fgColor != null ? fgColor : (unselectedForeground != null) ? unselectedForeground : jtable.getForeground());
        renderer.setForeground(currentForeground);
      }
      Color currentColor=(bgColor != null ? bgColor : (unselectedBackground != null) ? unselectedBackground : jtable.getBackground());
      renderer.setBackground(currentColor);
      Font currentFont=(font != null ? font : (unselectedFont != null) ? unselectedFont : jtable.getFont());
      renderer.setFont(currentFont);
    }
  }
  if (renderer instanceof JComponent) {
    applyRowBorder((JComponent)renderer,jtable,isSelected,row,column,hasFocus);
  }
  boolean printing=Utils.getAsBoolean(application.getRuntimeProperties().get("String_Node_Str"));
  if (renderEventExecutor != null && renderEventExecutor.hasRenderCallback()) {
    renderEventExecutor.setRenderState(state,row,isSelected);
  }
  if (renderer instanceof IDisplayRelatedData) {
    IDisplayRelatedData drd=(IDisplayRelatedData)renderer;
    String relationName=drd.getSelectedRelationName();
    if (state != null) {
      if (relationName != null) {
        if (!printing && !state.isRelatedFoundSetLoaded(relationName,null)) {
          IApplication app=dal.getApplication();
          ((IDisplayData)renderer).setValueObject(null);
          String key=row + "String_Node_Str" + relationName+ "String_Node_Str"+ null;
          if (!rowAndDataprovider.containsKey(key)) {
            rowAndDataprovider.put(key,key);
            Runnable r=new ASynchonizedCellLoad(app,jtable,foundset,row,jtable.convertColumnIndexToModel(column),relationName,drd.getDefaultSort(),null);
            app.getScheduledExecutor().execute(r);
          }
          return renderer.isVisible() ? renderer : empty;
        }
      }
      drd.setRecord(state,true);
    }
  }
  if (renderer instanceof IDisplayData) {
    if (state != null) {
      Object data=null;
      if (dataProviderID != null) {
        int index=-1;
        if (!printing && (index=dataProviderID.indexOf('.')) > 0) {
          if (!ScopesUtils.isVariableScope(dataProviderID)) {
            String partName=dataProviderID.substring(0,index);
            final String restName=dataProviderID.substring(index + 1);
            String relationName=partName;
            if (relationName != null && !state.isRelatedFoundSetLoaded(relationName,restName)) {
              IApplication app=dal.getApplication();
              ((IDisplayData)renderer).setValueObject(null);
              String key=row + "String_Node_Str" + relationName+ "String_Node_Str"+ restName;
              if (!rowAndDataprovider.containsKey(key)) {
                rowAndDataprovider.put(key,key);
                List<SortColumn> defaultPKSortColumns=null;
                try {
                  defaultPKSortColumns=app.getFoundSetManager().getDefaultPKSortColumns(app.getFlattenedSolution().getRelation(relationName).getForeignDataSource());
                }
 catch (                ServoyException e) {
                  Debug.error(e);
                }
                Runnable r=new ASynchonizedCellLoad(app,jtable,foundset,row,jtable.convertColumnIndexToModel(column),relationName,defaultPKSortColumns,restName);
                app.getScheduledExecutor().execute(r);
              }
              return renderer.isVisible() ? renderer : empty;
            }
            IFoundSetInternal rfs=state.getRelatedFoundSet(relationName);
            if (rfs != null) {
              int selected=rfs.getSelectedIndex();
              if (selected == -1 && rfs.getSize() > 0) {
                selected=0;
              }
              final IRecordInternal relState=rfs.getRecord(selected);
              if (testCalc(restName,relState,row,jtable.convertColumnIndexToModel(column),foundset))               return renderer;
            }
          }
        }
        if (!((IDisplayData)renderer).needEntireState() && !printing && testCalc(dataProviderID,state,row,jtable.convertColumnIndexToModel(column),foundset)) {
          return renderer;
        }
        try {
          data=dal.getValueObject(state,dataProviderID);
        }
 catch (        IllegalArgumentException iae) {
          Debug.error(iae);
          data="String_Node_Str";
        }
      }
      ((IDisplayData)renderer).setTagResolver(new ITagResolver(){
        public String getStringValue(        String name){
          return TagResolver.formatObject(dal.getValueObject(state,name),dal.getApplication().getSettings());
        }
      }
);
      if (data instanceof DbIdentValue) {
        data=((DbIdentValue)data).getPkValue();
      }
      ((IDisplayData)renderer).setValueObject(data);
    }
  }
  if (renderer instanceof IServoyAwareBean && state != null) {
    ((IServoyAwareBean)renderer).setSelectedRecord(new ServoyBeanState(state,dal.getFormScope()));
  }
  if (!(renderer instanceof IDisplayData) && !(renderer instanceof IDisplayRelatedData) && renderEventExecutor != null && renderEventExecutor.hasRenderCallback()) {
    renderEventExecutor.fireOnRender(false);
  }
  return renderer.isVisible() ? renderer : empty;
}