Description
In AbstractEarModule.java:240-251, the getters getBundleDir() and getLibDir() silently mutate instance state:
public String getBundleDir() {
bundleDir = cleanArchivePath(bundleDir); // modifies field
return bundleDir;
}
public String getLibDir() {
libDirectory = cleanArchivePath(libDirectory);
return libDirectory;
}
Getters modifying instance fields is surprising and makes debugging harder. While cleanArchivePath is idempotent, the side-effect could cause subtle bugs if a subclass overrides getBundleDir() while the parent field gets modified elsewhere.
Expected behavior
Use a local variable instead of assigning to the field:
public String getBundleDir() {
return cleanArchivePath(bundleDir);
}
Description
In
AbstractEarModule.java:240-251, the gettersgetBundleDir()andgetLibDir()silently mutate instance state:Getters modifying instance fields is surprising and makes debugging harder. While
cleanArchivePathis idempotent, the side-effect could cause subtle bugs if a subclass overridesgetBundleDir()while the parent field gets modified elsewhere.Expected behavior
Use a local variable instead of assigning to the field: