SunJiFengPlus commented on issue #3557:
URL: 
https://github.com/apache/incubator-dolphinscheduler/issues/3557#issuecomment-683507619


   Hi, i'm having trouble, i delete try catch block, because it never throw 
exception.
   
   replace
   ```java
           Date start = null;
           Date end = null;
           try {
               start = DateUtils.getScheduleDate(startDate);
               end = DateUtils.getScheduleDate(endDate);
           } catch (Exception e) {
               logger.error(e.getMessage(), e);
               putErrorRequestParamsMsg(result);
               return result;
           }
   ```
   
   with
   ```java
           Date start = null;
           Date end = null;
           if (StringUtils.isNotEmpty(startDate) && 
StringUtils.isNotEmpty(endDate)) {
               start = DateUtils.getScheduleDate(startDate);
               end = DateUtils.getScheduleDate(endDate);
               if (Objects.isNull(start) || Objects.isNull(end)) {
                   putErrorRequestParamsMsg(result);
                   return result;
               }
           }
   ```
   
   I write the same code twice, cause 3.9% duplication, can't pass sonar 
analysis, but i don't know how to extract, because the process contains return.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to