Performance improvements in ReactiveWrappers and ConvertingPropertyAccessor.

We now cache whether types are reactive wrappers and bypass the ConversionService for assignable primitive values.

Closes #2546
This commit is contained in:
Mark Paluch
2022-02-11 15:21:25 +01:00
parent 9146357b51
commit 68bfa9af0e
2 changed files with 15 additions and 5 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2021 the original author or authors.
* Copyright 2014-2022 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.
@@ -21,6 +21,7 @@ import org.springframework.data.mapping.PersistentPropertyAccessor;
import org.springframework.data.mapping.PersistentPropertyPath;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
/**
* {@link PersistentPropertyAccessor} that potentially converts the value handed to
@@ -103,7 +104,7 @@ public class ConvertingPropertyAccessor<T> extends SimplePersistentPropertyPathA
return (S) (source == null //
? null //
: type.isAssignableFrom(source.getClass()) //
: ClassUtils.resolvePrimitiveIfNecessary(type).isAssignableFrom(source.getClass()) //
? source //
: conversionService.convert(source, type));
}