diff --git a/spring-core/src/main/java/org/springframework/core/SerializableTypeWrapper.java b/spring-core/src/main/java/org/springframework/core/SerializableTypeWrapper.java index 97537e45cc..04ef40d528 100644 --- a/spring-core/src/main/java/org/springframework/core/SerializableTypeWrapper.java +++ b/spring-core/src/main/java/org/springframework/core/SerializableTypeWrapper.java @@ -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 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); diff --git a/spring-core/src/test/java/org/springframework/core/SerializableTypeWrapperTests.java b/spring-core/src/test/java/org/springframework/core/SerializableTypeWrapperTests.java index e0610c0749..fe8ac43dc7 100644 --- a/spring-core/src/test/java/org/springframework/core/SerializableTypeWrapperTests.java +++ b/spring-core/src/test/java/org/springframework/core/SerializableTypeWrapperTests.java @@ -33,8 +33,6 @@ import org.junit.Test; import static org.assertj.core.api.Assertions.assertThat; - - /** * Tests for {@link SerializableTypeWrapper}. *