Skip to content
Permalink
Browse files

Remove static consist file location; use reference to roster location…

… instead.
  • Loading branch information...
pabender committed Aug 6, 2019
1 parent 6fdb8ab commit 03f4ea401e10cebcc5c8c12629e2ee9ef3b3a42e
@@ -310,23 +310,18 @@ public void writeFile(ArrayList<LocoAddress> consistList, String fileName) throw
}

/**
* Defines the preferences subdirectory in which LocoFiles are kept by
* default.
* Returns the preferences subdirectory in which Consist Files are kept
* this is relative to the roster files location.
*/
static private String fileLocation = null;

static public String getFileLocation() {
if( fileLocation == null) {
fileLocation = Roster.getDefault().getRosterFilesLocation() + "consist" + File.separator;
}
return fileLocation;
return Roster.getDefault().getRosterFilesLocation() + "consist" + File.separator;
}

/**
* @deprecated since 4.17.3 file location is determined by roster location.
*/
@Deprecated
static public void setFileLocation(String loc) {
fileLocation = loc;
if (!fileLocation.endsWith(File.separator)) {
fileLocation = fileLocation + File.separator;
}
}

/**
@@ -78,16 +78,6 @@ public void setUp() throws java.io.IOException {

@After
public void tearDown() {
// use reflection to reset the static file location.
try {
Class<?> c = ConsistFile.class;
java.lang.reflect.Field f = c.getDeclaredField("fileLocation");
f.setAccessible(true);
f.set(new String(), null);
} catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException x) {
Assert.fail("Failed to reset ConsistFile static fileLocation " + x);
}

JUnitUtil.tearDown();
}
}
@@ -256,15 +256,6 @@ public void setUp() throws java.io.IOException {

@After
public void tearDown() {
// use reflection to reset the static file location.
try {
Class<?> c = ConsistFile.class;
java.lang.reflect.Field f = c.getDeclaredField("fileLocation");
f.setAccessible(true);
f.set(new String(), null);
} catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException x) {
Assert.fail("Failed to reset ConsistFile static fileLocation " + x);
}
JUnitUtil.tearDown();
}

0 comments on commit 03f4ea4

Please sign in to comment.
You can’t perform that action at this time.