Fixed issue with adding profile information to an unmodifiable list (#448)

This commit is contained in:
FilipDomazet 2016-09-16 21:02:22 +02:00 committed by James Agnew
parent f92c5a7232
commit e2f03a9a26
1 changed files with 9 additions and 4 deletions

View File

@ -25,6 +25,7 @@ import static org.apache.commons.lang3.StringUtils.isNotBlank;
import static org.apache.commons.lang3.StringUtils.isNotEmpty;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@ -1870,13 +1871,17 @@ class ParserState<T> {
} else if (theLocalPart.equals("profile")) {
@SuppressWarnings("unchecked")
List<IdDt> profiles = (List<IdDt>) myMap.get(ResourceMetadataKeyEnum.PROFILES);
if (profiles == null) {
profiles = new ArrayList<IdDt>();
myMap.put(ResourceMetadataKeyEnum.PROFILES, profiles);
List<IdDt> newProfiles;
if (profiles != null) {
newProfiles = new ArrayList<IdDt>(profiles.size() + 1);
newProfiles.addAll(profiles);
} else {
newProfiles = new ArrayList<IdDt>(1);
}
IdDt profile = new IdDt();
push(new PrimitiveState(getPreResourceState(), profile));
profiles.add(profile);
newProfiles.add(profile);
myMap.put(ResourceMetadataKeyEnum.PROFILES, Collections.unmodifiableList(newProfiles));
} else if (theLocalPart.equals("tag")) {
TagList tagList = (TagList) myMap.get(ResourceMetadataKeyEnum.TAG_LIST);
if (tagList == null) {