dolphinscheduler icon indicating copy to clipboard operation
dolphinscheduler copied to clipboard

[BUG] taskProps.getScheduleTime() may be null, but there is no check if it is null or not

Open liwenhe1993 opened this issue 6 years ago • 0 comments

    if (paramsMap != null) {
      String dateTime = DateUtils.format(taskProps.getScheduleTime(), Constants.PARAMETER_FORMAT_TIME);
      Property p = new Property();
      p.setValue(dateTime);
      p.setProp(Constants.PARAMETER_SHECDULE_TIME);
      paramsMap.put(Constants.PARAMETER_SHECDULE_TIME, p);
      script = ParameterUtils.convertParameterPlaceholders2(script, ParamUtils.convert(paramsMap));
    }

taskProps.getScheduleTime() may be null, so we need to check if it is null or not.

I will change as follows:

    // new
    // replace variable TIME with $[YYYYmmddd...] in shell file when history run job and batch complement job
    if (paramsMap != null) {
      if (taskProps.getScheduleTime() != null) {
        String dateTime = DateUtils.format(taskProps.getScheduleTime(), Constants.PARAMETER_FORMAT_TIME);
        Property p = new Property();
        p.setValue(dateTime);
        p.setProp(Constants.PARAMETER_SHECDULE_TIME);
        paramsMap.put(Constants.PARAMETER_SHECDULE_TIME, p);
      }
      script = ParameterUtils.convertParameterPlaceholders2(script, ParamUtils.convert(paramsMap));
    }

liwenhe1993 avatar Mar 21 '20 05:03 liwenhe1993