in xstream/src/java/com/thoughtworks/xstream/core/DefaultConverterLookup.java [56:85]
public Converter lookupConverterForType(final Class<?> type) {
final Converter cachedConverter = type != null ? typeToConverterMap.get(type.getName()) : null;
if (cachedConverter != null) {
return cachedConverter;
}
final Map<String, String> errors = new LinkedHashMap<>();
for (final Converter converter : converters) {
try {
if (converter.canConvert(type)) {
if (type != null) {
typeToConverterMap.put(type.getName(), converter);
}
return converter;
}
} catch (final RuntimeException | LinkageError e) {
errors.put(converter.getClass().getName(), e.getMessage());
}
}
final ConversionException exception = new ConversionException(errors.isEmpty()
? "No converter specified"
: "No converter available");
exception.add("type", type != null ? type.getName() : "null");
for (final Map.Entry<String, String> entry : errors.entrySet()) {
exception.add("converter", entry.getKey());
exception.add("message", entry.getValue());
}
throw exception;
}