Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[ptp-dev] Empty catch in RangeSet constructor

Hi,

The org.eclipse.ptp.core.util.RangeSet constructor with string parameter contains two empty catch blocks. This was preventing me to identify an bug where the RangeSet was being instantiated with an invalid number as a machine ID.

Is there a special reason to swallow NumberFormatExceptions? If not, I wouldn't it make sense to log the error or to propagate/rethrow the exception as a RuntimeException?

Here is the code:
   public RangeSet(String str) {
       if (str != null) {
           String[] ranges = str.split(",");
           for (String range : ranges) {
               String[] vals = range.split("-");
               if (vals.length == 1) {
                   try {
                       add(Integer.parseInt(vals[0]));
                   } catch (NumberFormatException e) {
                   }
               } else {
                   try {
add(Integer.parseInt(vals[0]), Integer.parseInt(vals[1]));
                   } catch (NumberFormatException e) {
} }
           }
       }
   }

Best regards,
Daniel Felix Ferber


Back to the top