Skip to content

Commit

Permalink
test: do not throw exceptions in utilities
Browse files Browse the repository at this point in the history
  • Loading branch information
rhwood committed Aug 7, 2019
1 parent 35418e8 commit 2a5f737
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions java/test/jmri/util/JUnitUtil.java
Expand Up @@ -607,14 +607,16 @@ static public boolean fasterWaitFor(ReleaseUntil condition) {
* {@link jmri.util.FileUtilSupport} object (used by * {@link jmri.util.FileUtilSupport} object (used by
* {@link jmri.util.FileUtil}) to the default settings/user files path for * {@link jmri.util.FileUtil}) to the default settings/user files path for
* tests of {@code git-working-copy/temp}. * tests of {@code git-working-copy/temp}.
* @throws java.lang.NoSuchFieldException if unable to reset
* @throws java.lang.IllegalAccessException if unable to reset
*/ */
public static void resetFileUtilSupport() throws NoSuchFieldException, IllegalArgumentException, IllegalAccessException { public static void resetFileUtilSupport() {
Field field = FileUtilSupport.class.getDeclaredField("defaultInstance"); try {
field.setAccessible(true); Field field = FileUtilSupport.class.getDeclaredField("defaultInstance");
field.set(null, null); field.setAccessible(true);
FileUtilSupport.getDefault().setUserFilesPath(ProfileManager.getDefault().getActiveProfile(), FileUtil.getPreferencesPath()); field.set(null, null);
FileUtilSupport.getDefault().setUserFilesPath(ProfileManager.getDefault().getActiveProfile(), FileUtil.getPreferencesPath());
} catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException ex) {
log.error("Exception resetting FileUtilSupport", ex);
}
} }


static public interface ReleaseUntil { static public interface ReleaseUntil {
Expand Down

0 comments on commit 2a5f737

Please sign in to comment.