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 ;
@@ -158,7 +159,7 @@ private Optional<String> getPropertyPath(List<PropertyNameDetectionStrategy> str
158
159
159
160
private InvocationInformation registerInvocation (Method method , Class <?> proxyType ) {
160
161
161
- Recorded <?> create = Modifier .isFinal (proxyType .getModifiers ()) ? new Unrecorded () : create (proxyType );
162
+ Recorded <?> create = Modifier .isFinal (proxyType .getModifiers ()) ? new Unrecorded (proxyType ) : create (proxyType );
162
163
InvocationInformation information = new InvocationInformation (create , method );
163
164
164
165
return this .information = information ;
@@ -167,7 +168,7 @@ private InvocationInformation registerInvocation(Method method, Class<?> proxyTy
167
168
168
169
private static final class InvocationInformation {
169
170
170
- private static final InvocationInformation NOT_INVOKED = new InvocationInformation (new Unrecorded (), null );
171
+ private static final InvocationInformation NOT_INVOKED = new InvocationInformation (new Unrecorded (null ), null );
171
172
172
173
private final Recorded <?> recorded ;
173
174
private final @ Nullable Method invokedMethod ;
@@ -251,7 +252,7 @@ public int hashCode() {
251
252
252
253
int result = ObjectUtils .nullSafeHashCode (recorded );
253
254
254
- result = 31 * result + ObjectUtils .nullSafeHashCode (invokedMethod );
255
+ result = ( 31 * result ) + ObjectUtils .nullSafeHashCode (invokedMethod );
255
256
256
257
return result ;
257
258
}
@@ -386,8 +387,8 @@ public interface ToMapConverter<T, S> extends Function<T, Map<?, S>> {}
386
387
387
388
static class Unrecorded extends Recorded <Object > {
388
389
389
- private Unrecorded () {
390
- super (null , null );
390
+ private Unrecorded (@ Nullable Class <?> type ) {
391
+ super (type == null ? null : type . isPrimitive () ? getDefaultValue ( type ) : null , null );
391
392
}
392
393
393
394
/*
@@ -398,5 +399,9 @@ private Unrecorded() {
398
399
public Optional <String > getPropertyPath (List <PropertyNameDetectionStrategy > strategies ) {
399
400
return Optional .empty ();
400
401
}
402
+
403
+ private static Object getDefaultValue (Class <?> clazz ) {
404
+ return Array .get (Array .newInstance (clazz , 1 ), 0 );
405
+ }
401
406
}
402
407
}
0 commit comments