|
|
|
@ -19,14 +19,15 @@ package org.springframework.core.convert.support; |
|
|
|
import java.lang.reflect.Array; |
|
|
|
import java.lang.reflect.Array; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Collections; |
|
|
|
import java.util.Collections; |
|
|
|
|
|
|
|
import java.util.Deque; |
|
|
|
import java.util.HashSet; |
|
|
|
import java.util.HashSet; |
|
|
|
import java.util.LinkedHashMap; |
|
|
|
|
|
|
|
import java.util.LinkedHashSet; |
|
|
|
|
|
|
|
import java.util.LinkedList; |
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Optional; |
|
|
|
import java.util.Optional; |
|
|
|
import java.util.Set; |
|
|
|
import java.util.Set; |
|
|
|
|
|
|
|
import java.util.concurrent.ConcurrentHashMap; |
|
|
|
|
|
|
|
import java.util.concurrent.ConcurrentLinkedDeque; |
|
|
|
|
|
|
|
import java.util.concurrent.CopyOnWriteArraySet; |
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.core.DecoratingProxy; |
|
|
|
import org.springframework.core.DecoratingProxy; |
|
|
|
import org.springframework.core.ResolvableType; |
|
|
|
import org.springframework.core.ResolvableType; |
|
|
|
@ -499,9 +500,9 @@ public class GenericConversionService implements ConfigurableConversionService { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private static class Converters { |
|
|
|
private static class Converters { |
|
|
|
|
|
|
|
|
|
|
|
private final Set<GenericConverter> globalConverters = new LinkedHashSet<>(); |
|
|
|
private final Set<GenericConverter> globalConverters = new CopyOnWriteArraySet<>(); |
|
|
|
|
|
|
|
|
|
|
|
private final Map<ConvertiblePair, ConvertersForPair> converters = new LinkedHashMap<>(36); |
|
|
|
private final Map<ConvertiblePair, ConvertersForPair> converters = new ConcurrentHashMap<>(256); |
|
|
|
|
|
|
|
|
|
|
|
public void add(GenericConverter converter) { |
|
|
|
public void add(GenericConverter converter) { |
|
|
|
Set<ConvertiblePair> convertibleTypes = converter.getConvertibleTypes(); |
|
|
|
Set<ConvertiblePair> convertibleTypes = converter.getConvertibleTypes(); |
|
|
|
@ -512,8 +513,7 @@ public class GenericConversionService implements ConfigurableConversionService { |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
for (ConvertiblePair convertiblePair : convertibleTypes) { |
|
|
|
for (ConvertiblePair convertiblePair : convertibleTypes) { |
|
|
|
ConvertersForPair convertersForPair = getMatchableConverters(convertiblePair); |
|
|
|
getMatchableConverters(convertiblePair).add(converter); |
|
|
|
convertersForPair.add(converter); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -651,7 +651,7 @@ public class GenericConversionService implements ConfigurableConversionService { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private static class ConvertersForPair { |
|
|
|
private static class ConvertersForPair { |
|
|
|
|
|
|
|
|
|
|
|
private final LinkedList<GenericConverter> converters = new LinkedList<>(); |
|
|
|
private final Deque<GenericConverter> converters = new ConcurrentLinkedDeque<>(); |
|
|
|
|
|
|
|
|
|
|
|
public void add(GenericConverter converter) { |
|
|
|
public void add(GenericConverter converter) { |
|
|
|
this.converters.addFirst(converter); |
|
|
|
this.converters.addFirst(converter); |
|
|
|
|