From 550f13e8ed678447a61872b4f9ff96d918003102 Mon Sep 17 00:00:00 2001 From: Hyunjin Choi Date: Tue, 4 Feb 2020 20:59:57 +0900 Subject: [PATCH] Simplify GenericConversionService.getMatchableConverters() Closes gh-24403 --- .../core/convert/support/GenericConversionService.java | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) 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 2816117144..e8263d9526 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) {