File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed
main/java/org/springframework/data/util
test/java/org/springframework/data/util Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -73,6 +73,7 @@ private MethodInvocationRecorder() {
7373 public static <T > Recorded <T > forProxyOf (Class <T > type ) {
7474
7575 Assert .notNull (type , "Type must not be null!" );
76+ Assert .isTrue (!Modifier .isFinal (type .getModifiers ()), "Type to record invocations on must not be final!" );
7677
7778 return new MethodInvocationRecorder ().create (type );
7879 }
Original file line number Diff line number Diff line change @@ -34,6 +34,13 @@ public class MethodInvocationRecorderUnitTests {
3434
3535 Recorded <Foo > recorder = MethodInvocationRecorder .forProxyOf (Foo .class );
3636
37+ @ Test // DATACMNS-1449
38+ public void rejectsFinalTypes () {
39+
40+ assertThatExceptionOfType (IllegalArgumentException .class ) //
41+ .isThrownBy (() -> MethodInvocationRecorder .forProxyOf (FinalType .class ));
42+ }
43+
3744 @ Test // DATACMNS-1449
3845 public void createsPropertyPathForSimpleMethodReference () {
3946
@@ -71,14 +78,16 @@ public void registersLookupToFinalType() {
7178 assertThat (recorder .record (Foo ::getName ).getPropertyPath ()).hasValue ("name" );
7279 }
7380
74- @ Test
81+ @ Test // DATACMNS-1449
7582 public void recordsInvocationOnInterface () {
7683
7784 Recorded <Sample > recorder = MethodInvocationRecorder .forProxyOf (Sample .class );
7885
7986 assertThat (recorder .record (Sample ::getName ).getPropertyPath ()).hasValue ("name" );
8087 }
8188
89+ static final class FinalType {}
90+
8291 @ Getter
8392 static class Foo {
8493 Bar bar ;
You can’t perform that action at this time.
0 commit comments