Program: 39322
Project: 39322
Buggy source:
@Override @SuppressWarnings("String_Node_Str") protected void initializeContent(final JSONObject json) throws JSONException {
  if (json.has(JSON_SELECTED_ENTITY_ID) && !json.isNull(JSON_SELECTED_ENTITY_ID)) {
    selectedEntityId=json.getLong(JSON_SELECTED_ENTITY_ID);
  }
  if (json.has(JSON_MULTISELECT_MODE) && !json.isNull(JSON_MULTISELECT_MODE)) {
    multiselectMode=json.getBoolean(JSON_MULTISELECT_MODE);
  }
  if (json.has(JSON_SELECTED_ENTITIES) && !json.isNull(JSON_SELECTED_ENTITIES)) {
    JSONObject selectedEntitiesObj=json.getJSONObject(JSON_SELECTED_ENTITIES);
    JSONArray selectedEntitiesIds=selectedEntitiesObj.names();
    if (selectedEntitiesIds != null) {
      for (int i=0; i < selectedEntitiesIds.length(); i++) {
        String key=selectedEntitiesIds.getString(i);
        boolean isSelected=false;
        if (selectedEntitiesObj.has(key) && !selectedEntitiesObj.isNull(key)) {
          isSelected=selectedEntitiesObj.getBoolean(key);
        }
        if (isSelected) {
          selectedEntities.add(Long.parseLong(key));
        }
      }
    }
  }
  if (json.has(JSON_BELONGS_TO_ENTITY_ID) && !json.isNull(JSON_BELONGS_TO_ENTITY_ID)) {
    belongsToEntityId=json.getLong(JSON_BELONGS_TO_ENTITY_ID);
  }
  if (json.has(JSON_FIRST_ENTITY) && !json.isNull(JSON_FIRST_ENTITY)) {
    firstResult=json.getInt(JSON_FIRST_ENTITY);
  }
  if (json.has(JSON_MAX_ENTITIES) && !json.isNull(JSON_MAX_ENTITIES)) {
    maxResults=json.getInt(JSON_MAX_ENTITIES);
  }
  if (json.has(JSON_FILTERS_ENABLED) && !json.isNull(JSON_FILTERS_ENABLED)) {
    filtersEnabled=json.getBoolean(JSON_FILTERS_ENABLED);
  }
  if (json.has(JSON_ONLY_ACTIVE) && !json.isNull(JSON_ONLY_ACTIVE) && activable) {
    onlyActive=json.getBoolean(JSON_ONLY_ACTIVE);
  }
  if (json.has(JSON_ORDER) && !json.isNull(JSON_ORDER)) {
    JSONObject orderJson=json.getJSONObject(JSON_ORDER);
    if (orderJson.has(JSON_ORDER_COLUMN) && orderJson.has(JSON_ORDER_DIRECTION)) {
      orderColumn=orderJson.getString(JSON_ORDER_COLUMN);
      orderDirection=orderJson.getString(JSON_ORDER_DIRECTION);
    }
  }
  if (json.has(JSON_FILTERS) && !json.isNull(JSON_FILTERS)) {
    JSONObject filtersJson=json.getJSONObject(JSON_FILTERS);
    Iterator<String> filtersKeys=filtersJson.keys();
    while (filtersKeys.hasNext()) {
      String column=filtersKeys.next();
      filters.put(column,filtersJson.getString(column).trim());
    }
  }
  if (belongsToFieldDefinition != null && belongsToEntityId == null) {
    setEnabled(false);
  }
  requestRender();
  requestUpdateState();
}

Fixed version (ground truth):
@Override protected void initializeContent(final JSONObject json) throws JSONException {
  if (json.has(JSON_SELECTED_ENTITY_ID) && !json.isNull(JSON_SELECTED_ENTITY_ID)) {
    selectedEntityId=json.getLong(JSON_SELECTED_ENTITY_ID);
  }
  if (json.has(JSON_MULTISELECT_MODE) && !json.isNull(JSON_MULTISELECT_MODE)) {
    multiselectMode=json.getBoolean(JSON_MULTISELECT_MODE);
  }
  if (json.has(JSON_SELECTED_ENTITIES) && !json.isNull(JSON_SELECTED_ENTITIES)) {
    JSONObject selectedEntitiesObj=json.getJSONObject(JSON_SELECTED_ENTITIES);
    JSONArray selectedEntitiesIds=selectedEntitiesObj.names();
    for (int i=0; selectedEntitiesIds != null && i < selectedEntitiesIds.length(); i++) {
      String key=selectedEntitiesIds.getString(i);
      boolean isSelected=false;
      if (selectedEntitiesObj.has(key) && !selectedEntitiesObj.isNull(key)) {
        isSelected=selectedEntitiesObj.getBoolean(key);
      }
      if (isSelected) {
        selectedEntities.add(Long.parseLong(key));
      }
    }
  }
  if (json.has(JSON_BELONGS_TO_ENTITY_ID) && !json.isNull(JSON_BELONGS_TO_ENTITY_ID)) {
    belongsToEntityId=json.getLong(JSON_BELONGS_TO_ENTITY_ID);
  }
  if (json.has(JSON_FIRST_ENTITY) && !json.isNull(JSON_FIRST_ENTITY)) {
    firstResult=json.getInt(JSON_FIRST_ENTITY);
  }
  if (json.has(JSON_MAX_ENTITIES) && !json.isNull(JSON_MAX_ENTITIES)) {
    maxResults=json.getInt(JSON_MAX_ENTITIES);
  }
  if (json.has(JSON_ONLY_ACTIVE) && !json.isNull(JSON_ONLY_ACTIVE) && activable) {
    onlyActive=json.getBoolean(JSON_ONLY_ACTIVE);
  }
  if (json.has(JSON_ORDER) && !json.isNull(JSON_ORDER)) {
    JSONObject orderJson=json.getJSONObject(JSON_ORDER);
    if (orderJson.has(JSON_ORDER_COLUMN) && orderJson.has(JSON_ORDER_DIRECTION)) {
      orderColumn=orderJson.getString(JSON_ORDER_COLUMN);
      orderDirection=orderJson.getString(JSON_ORDER_DIRECTION);
    }
  }
  if (belongsToFieldDefinition != null && belongsToEntityId == null) {
    setEnabled(false);
  }
  passFiltersFromJson(json);
  requestRender();
  requestUpdateState();
}