Remove unnecessary loop in SerializableTypeWrapper
Since arbitrary levels of proxies do not occur, this commit replaces the `while` loop in SerializableTypeWrapper.unwrap() with a simple `if` statement. Closes gh-23415
This commit is contained in:
parent
83956f8e8b
commit
a43ba052e9
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
|
@ -51,6 +51,7 @@ import org.springframework.util.ReflectionUtils;
|
|||
*
|
||||
* @author Phillip Webb
|
||||
* @author Juergen Hoeller
|
||||
* @author Sam Brannen
|
||||
* @since 4.0
|
||||
*/
|
||||
final class SerializableTypeWrapper {
|
||||
|
@ -89,8 +90,8 @@ final class SerializableTypeWrapper {
|
|||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T extends Type> T unwrap(T type) {
|
||||
Type unwrapped = type;
|
||||
while (unwrapped instanceof SerializableTypeProxy) {
|
||||
Type unwrapped = null;
|
||||
if (type instanceof SerializableTypeProxy) {
|
||||
unwrapped = ((SerializableTypeProxy) type).getTypeProvider().getType();
|
||||
}
|
||||
return (unwrapped != null ? (T) unwrapped : type);
|
||||
|
|
|
@ -33,8 +33,6 @@ import org.junit.Test;
|
|||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Tests for {@link SerializableTypeWrapper}.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue