google / gson

A Java serialization/deserialization library to convert Java Objects into JSON and back
Apache License 2.0
23.29k stars 4.28k forks source link

Fix typeArguments array not being cloned when resolving ParameterizedType with changed owner #2706

Closed TBlueF closed 3 months ago

TBlueF commented 3 months ago

Purpose

This PR fixes an inconsistency in $Gson$Types#resolve() where the ParameterizedType#getActualTypeArguments() array is only cloned when the resolved owner-type has not changed from the original owner-type.

Description

In most cases this is a non-issue, as usually all ParameterizedType implementations clone the array themselves when invoking the getActualTypeArguments() getter. However, this is not guaranteed. Cloning the array only when the owner-type didn't change seems like an inconsistency and an oversight, so this PR is trying to fix that.

Checklist