16
16
*/
17
17
package org .apache .dubbo .common .utils ;
18
18
19
+ import org .apache .dubbo .common .constants .CommonConstants ;
20
+ import org .apache .dubbo .common .logger .ErrorTypeAwareLogger ;
21
+ import org .apache .dubbo .common .logger .LoggerFactory ;
22
+ import org .apache .dubbo .config .ApplicationConfig ;
23
+ import org .apache .dubbo .rpc .model .FrameworkModel ;
24
+ import org .apache .dubbo .rpc .model .ModuleModel ;
25
+ import org .apache .dubbo .rpc .model .ScopeClassLoaderListener ;
26
+
19
27
import java .io .IOException ;
20
28
import java .lang .reflect .Field ;
21
29
import java .lang .reflect .GenericArrayType ;
32
40
import java .util .Set ;
33
41
import java .util .stream .Collectors ;
34
42
35
- import org .apache .dubbo .common .constants .CommonConstants ;
36
- import org .apache .dubbo .common .logger .ErrorTypeAwareLogger ;
37
- import org .apache .dubbo .common .logger .LoggerFactory ;
38
- import org .apache .dubbo .config .ApplicationConfig ;
39
- import org .apache .dubbo .rpc .model .FrameworkModel ;
40
- import org .apache .dubbo .rpc .model .ModuleModel ;
41
- import org .apache .dubbo .rpc .model .ScopeClassLoaderListener ;
42
-
43
43
import static org .apache .dubbo .common .constants .CommonConstants .CLASS_DESERIALIZE_ALLOWED_LIST ;
44
44
import static org .apache .dubbo .common .constants .CommonConstants .CLASS_DESERIALIZE_BLOCKED_LIST ;
45
45
import static org .apache .dubbo .common .constants .CommonConstants .CLASS_DESERIALIZE_BLOCK_ALL ;
@@ -185,8 +185,9 @@ public synchronized void registerInterface(Class<?> clazz) {
185
185
return ;
186
186
}
187
187
188
- Set <Class <?> > markedClass = new HashSet <>();
188
+ Set <Type > markedClass = new HashSet <>();
189
189
markedClass .add (clazz );
190
+ checkClass (markedClass , clazz );
190
191
191
192
addToAllow (clazz .getName ());
192
193
@@ -221,10 +222,17 @@ public synchronized void registerInterface(Class<?> clazz) {
221
222
}
222
223
}
223
224
224
- private void checkType (Set <Class <?> > markedClass , Type type ) {
225
+ private void checkType (Set <Type > markedClass , Type type ) {
225
226
if (type instanceof Class ) {
226
227
checkClass (markedClass , (Class <?>) type );
227
- } else if (type instanceof ParameterizedType ) {
228
+ return ;
229
+ }
230
+
231
+ if (!markedClass .add (type )) {
232
+ return ;
233
+ }
234
+
235
+ if (type instanceof ParameterizedType ) {
228
236
ParameterizedType parameterizedType = (ParameterizedType ) type ;
229
237
checkClass (markedClass , (Class <?>) parameterizedType .getRawType ());
230
238
for (Type actualTypeArgument : parameterizedType .getActualTypeArguments ()) {
@@ -249,13 +257,11 @@ private void checkType(Set<Class<?>> markedClass, Type type) {
249
257
}
250
258
}
251
259
252
- private void checkClass (Set <Class <?> > markedClass , Class <?> clazz ) {
253
- if (markedClass .contains (clazz )) {
260
+ private void checkClass (Set <Type > markedClass , Class <?> clazz ) {
261
+ if (! markedClass .add (clazz )) {
254
262
return ;
255
263
}
256
264
257
- markedClass .add (clazz );
258
-
259
265
addToAllow (clazz .getName ());
260
266
261
267
Class <?>[] interfaces = clazz .getInterfaces ();
0 commit comments