fix: mutable object problems in InterpreterSetting

By filling InterpreterSetting object by newly created objects
This commit is contained in:
1ambda 2016-11-15 21:59:56 +09:00
parent 5460241a38
commit 7825108e77
2 changed files with 8 additions and 5 deletions

View file

@ -106,7 +106,8 @@ public class InterpreterOption {
option.perUser = other.perUser;
option.isExistingProcess = other.isExistingProcess;
option.setPermission = other.setPermission;
option.users = new ArrayList<>(other.users);
option.users = (null == other.users) ?
new ArrayList<String>() : new ArrayList<>(other.users);
return option;
}

View file

@ -285,14 +285,16 @@ public class InterpreterFactory implements InterpreterGroupFactory {
}
private InterpreterSetting createFromInterpreterSettingRef(InterpreterSetting o) {
// return immutable objects
List<InterpreterInfo> infos = new ArrayList<>(o.getInterpreterInfos());
List<Dependency> deps = new ArrayList<>(o.getDependencies());
// should return immutable objects
List<InterpreterInfo> infos = (null == o.getInterpreterInfos()) ?
new ArrayList<InterpreterInfo>() : new ArrayList<>(o.getInterpreterInfos());
List<Dependency> deps = (null == o.getDependencies()) ?
new ArrayList<Dependency>() : new ArrayList<>(o.getDependencies());
Properties props = convertInterpreterProperties((Map<String, InterpreterProperty>) o.getProperties());
InterpreterOption option = InterpreterOption.fromInterpreterOption(o.getOption());
InterpreterSetting setting = new InterpreterSetting(o.getName(), o.getName(),
o.getInterpreterInfos(), props, deps, o.getOption(), o.getPath());
infos, props, deps, option, o.getPath());
setting.setInterpreterGroupFactory(this);
return setting;
}