Skip to content

Commit 553504b

Browse files
committed
Use Java 6 API for exception construction
Use multi-catch
1 parent 0fb8b4e commit 553504b

File tree

3 files changed

+6
-22
lines changed

3 files changed

+6
-22
lines changed

commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/linear/MatrixUtils.java

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -692,14 +692,8 @@ public static void deserializeRealVector(final Object instance,
692692
instance.getClass().getDeclaredField(fieldName);
693693
f.setAccessible(true);
694694
f.set(instance, vector);
695-
} catch (NoSuchFieldException nsfe) {
696-
IOException ioe = new IOException();
697-
ioe.initCause(nsfe);
698-
throw ioe;
699-
} catch (IllegalAccessException iae) {
700-
IOException ioe = new IOException();
701-
ioe.initCause(iae);
702-
throw ioe;
695+
} catch (NoSuchFieldException | IllegalAccessException e) {
696+
throw new IOException(e);
703697
}
704698
}
705699

@@ -798,14 +792,8 @@ public static void deserializeRealMatrix(final Object instance,
798792
instance.getClass().getDeclaredField(fieldName);
799793
f.setAccessible(true);
800794
f.set(instance, matrix);
801-
} catch (NoSuchFieldException nsfe) {
802-
IOException ioe = new IOException();
803-
ioe.initCause(nsfe);
804-
throw ioe;
805-
} catch (IllegalAccessException iae) {
806-
IOException ioe = new IOException();
807-
ioe.initCause(iae);
808-
throw ioe;
795+
} catch (NoSuchFieldException | IllegalAccessException nsfe) {
796+
throw new IOException(nsfe);
809797
}
810798
}
811799

commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/ode/nonstiff/DormandPrince853StepInterpolator.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -449,9 +449,7 @@ public void writeExternal(final ObjectOutput out)
449449
// save the local attributes
450450
finalizeStep();
451451
} catch (MaxCountExceededException mcee) {
452-
final IOException ioe = new IOException(mcee.getLocalizedMessage());
453-
ioe.initCause(mcee);
454-
throw ioe;
452+
throw new IOException(mcee.getLocalizedMessage(), mcee);
455453
}
456454

457455
final int dimension = (currentState == null) ? -1 : currentState.length;

commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/ode/sampling/AbstractStepInterpolator.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -555,9 +555,7 @@ protected void writeBaseExternal(final ObjectOutput out)
555555
// finalize the step (and don't bother saving the now true flag)
556556
finalizeStep();
557557
} catch (MaxCountExceededException mcee) {
558-
final IOException ioe = new IOException(mcee.getLocalizedMessage());
559-
ioe.initCause(mcee);
560-
throw ioe;
558+
throw new IOException(mcee.getLocalizedMessage(), mcee);
561559
}
562560
}
563561

0 commit comments

Comments
 (0)