Skip to content

Commit 4e9f4bc

Browse files
mp911dechristophstrobl
authored andcommitted
Polishing.
Move off deprecated StringUtils.isEmpty method. Fix type reference using the component type and not the component's component type. Add early return for null values. Original Pull Request: #2015
1 parent d5ba93c commit 4e9f4bc

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/main/java/org/springframework/data/redis/core/convert/MappingRedisConverter.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
import org.springframework.util.Assert;
6262
import org.springframework.util.ClassUtils;
6363
import org.springframework.util.CollectionUtils;
64+
import org.springframework.util.ObjectUtils;
6465
import org.springframework.util.StringUtils;
6566
import org.springframework.util.comparator.NullSafeComparator;
6667

@@ -289,22 +290,22 @@ protected Object readProperty(String path, RedisData source, RedisPersistentProp
289290
if (!source.getBucket().hasValue(currentPath) && isByteArray(typeInformation)) {
290291

291292
return readCollectionOrArray(currentPath, typeInformation.getType(),
292-
typeInformation.getRequiredComponentType().getActualType().getType(), source.getBucket());
293+
typeInformation.getRequiredComponentType().getType(), source.getBucket());
293294
}
294295
} else {
295296
return readCollectionOrArray(currentPath, typeInformation.getType(),
296-
typeInformation.getRequiredComponentType().getActualType().getType(), source.getBucket());
297+
typeInformation.getRequiredComponentType().getType(), source.getBucket());
297298
}
298299
}
299300

300301
if (persistentProperty.isEntity()
301-
&& !conversionService.canConvert(byte[].class, typeInformation.getActualType().getType())) {
302+
&& !conversionService.canConvert(byte[].class, typeInformation.getRequiredActualType().getType())) {
302303

303304
Bucket bucket = source.getBucket().extract(currentPath + ".");
304305

305306
RedisData newBucket = new RedisData(bucket);
306307
TypeInformation<?> typeToRead = typeMapper.readType(bucket.getPropertyPath(currentPath),
307-
typeInformation.getActualType());
308+
typeInformation);
308309

309310
return readInternal(currentPath, typeToRead.getType(), newBucket);
310311
}
@@ -315,8 +316,12 @@ protected Object readProperty(String path, RedisData source, RedisPersistentProp
315316
return null;
316317
}
317318

318-
if (persistentProperty.isIdProperty() && StringUtils.isEmpty(path.isEmpty())) {
319-
return sourceBytes == null ? fromBytes(sourceBytes, typeInformation.getActualType().getType()) : source.getId();
319+
if (persistentProperty.isIdProperty() && ObjectUtils.isEmpty(path.isEmpty())) {
320+
return sourceBytes != null ? fromBytes(sourceBytes, typeInformation.getType()) : source.getId();
321+
}
322+
323+
if (sourceBytes == null) {
324+
return null;
320325
}
321326

322327
Class<?> typeToUse = getTypeHint(currentPath, source.getBucket(), persistentProperty.getType());

0 commit comments

Comments
 (0)