Skip to content

Commit

Permalink
Fix for issue RWS#94 - reverse sort autowired set to ensure Spring pr…
Browse files Browse the repository at this point in the history
…iority is respected when setting data converters
  • Loading branch information
willprice76 committed Apr 10, 2018
1 parent 3e598d3 commit 3043cfa
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
import org.springframework.core.convert.TypeDescriptor;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

Expand Down Expand Up @@ -50,7 +53,10 @@ private static String resolveLink(String itemId, WebRequestContext webRequestCon

@Autowired
public void setConverters(Set<SemanticModelConverter<?>> semanticModelConverters) {
semanticModelConverters.forEach(sourceConverter ->
List<SemanticModelConverter<?>> list = new ArrayList<>(semanticModelConverters);
//reverse sorting the autowired set ensures that higher priority components are added last and thus override lower prio/default components
Collections.reverse(list);
list.forEach(sourceConverter ->
sourceConverter.getTypes().forEach(aClass ->
converters.put(aClass, sourceConverter)));
}
Expand Down

0 comments on commit 3043cfa

Please sign in to comment.