In Java, Strings are immutable and there's no way for another thread to modify the value of your fileName
reference (since it's local to the calling method), so a defensive copy brings absolutely no benefit here.
In general, defensive copies can help to avoid such scenarios, provided there are done at the right time (when no other thread can modify the instance while the copy is running). A better idea for defense, as illustrated by this very String
example, is to make passed classes immutable.