Skip to content

Commit 925fa02

Browse files
committed
Polishing
1 parent 09aa59f commit 925fa02

File tree

6 files changed

+135
-127
lines changed

6 files changed

+135
-127
lines changed

spring-beans/src/main/java/org/springframework/beans/AbstractNestablePropertyAccessor.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1000,18 +1000,20 @@ public String toString() {
10001000
*/
10011001
protected abstract static class PropertyHandler {
10021002

1003+
@Nullable
10031004
private final Class<?> propertyType;
10041005

10051006
private final boolean readable;
10061007

10071008
private final boolean writable;
10081009

1009-
public PropertyHandler(Class<?> propertyType, boolean readable, boolean writable) {
1010+
public PropertyHandler(@Nullable Class<?> propertyType, boolean readable, boolean writable) {
10101011
this.propertyType = propertyType;
10111012
this.readable = readable;
10121013
this.writable = writable;
10131014
}
10141015

1016+
@Nullable
10151017
public Class<?> getPropertyType() {
10161018
return this.propertyType;
10171019
}

spring-beans/src/main/java/org/springframework/beans/DirectFieldAccessor.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -129,7 +129,6 @@ public Object getValue() throws Exception {
129129
ReflectionUtils.makeAccessible(this.field);
130130
return this.field.get(getWrappedInstance());
131131
}
132-
133132
catch (IllegalAccessException ex) {
134133
throw new InvalidPropertyException(getWrappedClass(),
135134
this.field.getName(), "Field is not accessible", ex);

spring-context/src/test/java/org/springframework/context/event/AbstractApplicationEventListenerTests.java

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -36,6 +36,10 @@ protected ResolvableType getGenericApplicationEventType(String fieldName) {
3636
}
3737
}
3838

39+
protected <T> GenericTestEvent<T> createGenericTestEvent(T payload) {
40+
return new GenericTestEvent<>(this, payload);
41+
}
42+
3943

4044
protected static class GenericTestEvent<T> extends ApplicationEvent {
4145

@@ -51,6 +55,7 @@ public T getPayload() {
5155
}
5256
}
5357

58+
5459
protected static class SmartGenericTestEvent<T> extends GenericTestEvent<T> implements ResolvableTypeProvider {
5560

5661
private final ResolvableType resolvableType;
@@ -67,52 +72,55 @@ public ResolvableType getResolvableType() {
6772
}
6873
}
6974

75+
7076
protected static class StringEvent extends GenericTestEvent<String> {
7177

7278
public StringEvent(Object source, String payload) {
7379
super(source, payload);
7480
}
7581
}
7682

83+
7784
protected static class LongEvent extends GenericTestEvent<Long> {
7885

7986
public LongEvent(Object source, Long payload) {
8087
super(source, payload);
8188
}
8289
}
8390

84-
protected <T> GenericTestEvent<T> createGenericTestEvent(T payload) {
85-
return new GenericTestEvent<>(this, payload);
86-
}
87-
8891

8992
static class GenericEventListener implements ApplicationListener<GenericTestEvent<?>> {
93+
9094
@Override
9195
public void onApplicationEvent(GenericTestEvent<?> event) {
9296
}
9397
}
9498

99+
95100
static class ObjectEventListener implements ApplicationListener<GenericTestEvent<Object>> {
101+
96102
@Override
97103
public void onApplicationEvent(GenericTestEvent<Object> event) {
98104
}
99105
}
100106

101-
static class UpperBoundEventListener
102-
implements ApplicationListener<GenericTestEvent<? extends RuntimeException>> {
107+
108+
static class UpperBoundEventListener implements ApplicationListener<GenericTestEvent<? extends RuntimeException>> {
103109

104110
@Override
105111
public void onApplicationEvent(GenericTestEvent<? extends RuntimeException> event) {
106112
}
107113
}
108114

115+
109116
static class StringEventListener implements ApplicationListener<GenericTestEvent<String>> {
110117

111118
@Override
112119
public void onApplicationEvent(GenericTestEvent<String> event) {
113120
}
114121
}
115122

123+
116124
@SuppressWarnings("rawtypes")
117125
static class RawApplicationListener implements ApplicationListener {
118126

@@ -121,10 +129,10 @@ public void onApplicationEvent(ApplicationEvent event) {
121129
}
122130
}
123131

132+
124133
static class TestEvents {
125134

126135
public GenericTestEvent<?> wildcardEvent;
127-
128136
}
129137

130138
}

spring-context/src/test/java/org/springframework/context/event/GenericApplicationListenerAdapterTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ public void genericListenerStrictTypeNotMatchTypeErasure() {
104104

105105
@Test
106106
public void genericListenerStrictTypeSubClass() {
107-
supportsEventType(false, ObjectEventListener.class, ResolvableType.forClassWithGenerics(GenericTestEvent.class, Long.class));
107+
supportsEventType(false, ObjectEventListener.class,
108+
ResolvableType.forClassWithGenerics(GenericTestEvent.class, Long.class));
108109
}
109110

110111
@Test

0 commit comments

Comments
 (0)