Is making a defensive copy of the fileName argument necessary in this example?
public static Context getInstanceFromFile(final String fileName)
throws IOException, FileNotFoundException, ContextException {
if (fileName == null) {
throw new NullPointerException("The fileName argument is null.");
}
return instance.loadParametersFromFile(String.valueOf(fileName));
}
In theory, another thread can modify the fileName before the loadParametersFromFile
method is called. Is the same not true before String.valueOf(fileName)
is called?
How can I ensure the value passed in fileName is still the same when loadParametersFromFile is called?