Fix StackOverflowException

This commit is contained in:
Luck 2016-10-13 20:36:08 +01:00
parent 26fb506560
commit fcb0fcadeb
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
2 changed files with 36 additions and 12 deletions

View File

@ -120,11 +120,15 @@ public class PersistedSubject implements Subject {
@Override
public boolean isChildOf(@NonNull Set<Context> contexts, @NonNull Subject subject) {
return subjectData.getParents(contexts).contains(subject) ||
transientSubjectData.getParents(contexts).contains(subject) ||
getContainingCollection().getDefaults().getParents(contexts).contains(subject) ||
service.getDefaults().getParents(contexts).contains(subject);
if (getContainingCollection().getIdentifier().equalsIgnoreCase("defaults")) {
return subjectData.getParents(contexts).contains(subject) ||
transientSubjectData.getParents(contexts).contains(subject);
} else {
return subjectData.getParents(contexts).contains(subject) ||
transientSubjectData.getParents(contexts).contains(subject) ||
getContainingCollection().getDefaults().getParents(contexts).contains(subject) ||
service.getDefaults().getParents(contexts).contains(subject);
}
}
@Override
@ -132,8 +136,12 @@ public class PersistedSubject implements Subject {
List<Subject> s = new ArrayList<>();
s.addAll(subjectData.getParents(contexts));
s.addAll(transientSubjectData.getParents(contexts));
s.addAll(getContainingCollection().getDefaults().getParents(contexts));
s.addAll(service.getDefaults().getParents(contexts));
if (!getContainingCollection().getIdentifier().equalsIgnoreCase("defaults")) {
s.addAll(getContainingCollection().getDefaults().getParents(contexts));
s.addAll(service.getDefaults().getParents(contexts));
}
return ImmutableList.copyOf(s);
}
@ -156,6 +164,10 @@ public class PersistedSubject implements Subject {
}
}
if (getContainingCollection().getIdentifier().equalsIgnoreCase("defaults")) {
return Optional.empty();
}
res = getContainingCollection().getDefaults().getOption(set, key);
if (res.isPresent()) {
return res;

View File

@ -97,17 +97,25 @@ public class SimpleSubject implements Subject {
@Override
public boolean isChildOf(@NonNull Set<Context> contexts, @NonNull Subject subject) {
return subjectData.getParents(contexts).contains(subject) ||
getContainingCollection().getDefaults().getParents(contexts).contains(subject) ||
service.getDefaults().getParents(contexts).contains(subject);
if (getContainingCollection().getIdentifier().equalsIgnoreCase("defaults")) {
return subjectData.getParents(contexts).contains(subject);
} else {
return subjectData.getParents(contexts).contains(subject) ||
getContainingCollection().getDefaults().getParents(contexts).contains(subject) ||
service.getDefaults().getParents(contexts).contains(subject);
}
}
@Override
public List<Subject> getParents(@NonNull Set<Context> contexts) {
List<Subject> s = new ArrayList<>();
s.addAll(subjectData.getParents(contexts));
s.addAll(getContainingCollection().getDefaults().getParents(contexts));
s.addAll(service.getDefaults().getParents(contexts));
if (!getContainingCollection().getIdentifier().equalsIgnoreCase("defaults")){
s.addAll(getContainingCollection().getDefaults().getParents(contexts));
s.addAll(service.getDefaults().getParents(contexts));
}
return ImmutableList.copyOf(s);
}
@ -125,6 +133,10 @@ public class SimpleSubject implements Subject {
}
}
if (getContainingCollection().getIdentifier().equalsIgnoreCase("defaults")) {
return Optional.empty();
}
res = getContainingCollection().getDefaults().getOption(set, key);
if (res.isPresent()) {
return res;