diff --git a/spring-core/src/main/java/org/springframework/core/convert/support/GenericConversionService.java b/spring-core/src/main/java/org/springframework/core/convert/support/GenericConversionService.java index 2816117144d..e8263d9526c 100644 --- a/spring-core/src/main/java/org/springframework/core/convert/support/GenericConversionService.java +++ b/spring-core/src/main/java/org/springframework/core/convert/support/GenericConversionService.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -519,12 +519,7 @@ public class GenericConversionService implements ConfigurableConversionService { } private ConvertersForPair getMatchableConverters(ConvertiblePair convertiblePair) { - ConvertersForPair convertersForPair = this.converters.get(convertiblePair); - if (convertersForPair == null) { - convertersForPair = new ConvertersForPair(); - this.converters.put(convertiblePair, convertersForPair); - } - return convertersForPair; + return this.converters.computeIfAbsent(convertiblePair, k -> new ConvertersForPair()); } public void remove(Class sourceType, Class targetType) {