15
15
*/
16
16
package org .springframework .data .util ;
17
17
18
+ import java .lang .reflect .Array ;
18
19
import java .lang .reflect .Method ;
19
20
import java .lang .reflect .Modifier ;
20
21
import java .util .Arrays ;
@@ -154,7 +155,7 @@ private Optional<String> getPropertyPath(List<PropertyNameDetectionStrategy> str
154
155
155
156
private InvocationInformation registerInvocation (Method method , Class <?> proxyType ) {
156
157
157
- Recorded <?> create = Modifier .isFinal (proxyType .getModifiers ()) ? new Unrecorded () : create (proxyType );
158
+ Recorded <?> create = Modifier .isFinal (proxyType .getModifiers ()) ? new Unrecorded (proxyType ) : create (proxyType );
158
159
InvocationInformation information = new InvocationInformation (create , method );
159
160
160
161
return this .information = information ;
@@ -163,7 +164,7 @@ private InvocationInformation registerInvocation(Method method, Class<?> proxyTy
163
164
164
165
private static final class InvocationInformation {
165
166
166
- private static final InvocationInformation NOT_INVOKED = new InvocationInformation (new Unrecorded (), null );
167
+ private static final InvocationInformation NOT_INVOKED = new InvocationInformation (new Unrecorded (null ), null );
167
168
168
169
private final Recorded <?> recorded ;
169
170
private final @ Nullable Method invokedMethod ;
@@ -237,7 +238,7 @@ public int hashCode() {
237
238
238
239
int result = ObjectUtils .nullSafeHashCode (recorded );
239
240
240
- result = 31 * result + ObjectUtils .nullSafeHashCode (invokedMethod );
241
+ result = ( 31 * result ) + ObjectUtils .nullSafeHashCode (invokedMethod );
241
242
242
243
return result ;
243
244
}
@@ -360,13 +361,17 @@ public interface ToMapConverter<T, S> extends Function<T, Map<?, S>> {}
360
361
361
362
static class Unrecorded extends Recorded <Object > {
362
363
363
- private Unrecorded () {
364
- super (null , null );
364
+ private Unrecorded (@ Nullable Class <?> type ) {
365
+ super (type == null ? null : type . isPrimitive () ? getDefaultValue ( type ) : null , null );
365
366
}
366
367
367
368
@ Override
368
369
public Optional <String > getPropertyPath (List <PropertyNameDetectionStrategy > strategies ) {
369
370
return Optional .empty ();
370
371
}
372
+
373
+ private static Object getDefaultValue (Class <?> clazz ) {
374
+ return Array .get (Array .newInstance (clazz , 1 ), 0 );
375
+ }
371
376
}
372
377
}
0 commit comments