@@ -213,9 +213,22 @@ private List<ReadyFuncAdaptor> getReadyFuncs(Reconciler reconciler) {
213
213
return readyFuncs ;
214
214
}
215
215
216
+ private static boolean invokePredicate (
217
+ String name , Object target , Method method , Object ... args ) {
218
+ try {
219
+ return (boolean ) method .invoke (target , args );
220
+ } catch (IllegalAccessException e ) {
221
+ log .error ("ignoring invalid {} method signature {} " , name , method , e );
222
+ return true ;
223
+ } catch (InvocationTargetException e ) {
224
+ log .error ("{} {} failed" , name , method , e );
225
+ return false ;
226
+ }
227
+ }
228
+
216
229
private static class AddFilterAdaptor implements Predicate {
217
- private Method method ;
218
- private Object target ;
230
+ private final Method method ;
231
+ private final Object target ;
219
232
220
233
private AddFilterAdaptor (Object target , Method method ) {
221
234
this .method = method ;
@@ -224,18 +237,13 @@ private AddFilterAdaptor(Object target, Method method) {
224
237
225
238
@ Override
226
239
public boolean test (Object addedObj ) {
227
- try {
228
- return (boolean ) method .invoke (target , addedObj );
229
- } catch (IllegalAccessException | InvocationTargetException e ) {
230
- log .error ("invalid EventAddFilter method signature" , e );
231
- return true ;
232
- }
240
+ return invokePredicate ("ADD-EventFilter" , target , method , addedObj );
233
241
}
234
242
}
235
243
236
244
private static class UpdateFilterAdaptor implements BiPredicate {
237
- private Method method ;
238
- private Object target ;
245
+ private final Method method ;
246
+ private final Object target ;
239
247
240
248
private UpdateFilterAdaptor (Object target , Method method ) {
241
249
this .method = method ;
@@ -244,18 +252,13 @@ private UpdateFilterAdaptor(Object target, Method method) {
244
252
245
253
@ Override
246
254
public boolean test (Object oldObj , Object newObj ) {
247
- try {
248
- return (boolean ) method .invoke (target , oldObj , newObj );
249
- } catch (IllegalAccessException | InvocationTargetException e ) {
250
- log .error ("invalid EventUpdateFilter method signature" , e );
251
- return true ;
252
- }
255
+ return invokePredicate ("UPDATE-EventFilter" , target , method , oldObj , newObj );
253
256
}
254
257
}
255
258
256
259
private static class DeleteFilterAdaptor implements BiPredicate {
257
- private Method method ;
258
- private Object target ;
260
+ private final Method method ;
261
+ private final Object target ;
259
262
260
263
private DeleteFilterAdaptor (Object target , Method method ) {
261
264
this .method = method ;
@@ -264,18 +267,13 @@ private DeleteFilterAdaptor(Object target, Method method) {
264
267
265
268
@ Override
266
269
public boolean test (Object deleteObj , Object cacheStatusUnknown ) {
267
- try {
268
- return (boolean ) method .invoke (target , deleteObj , cacheStatusUnknown );
269
- } catch (IllegalAccessException | InvocationTargetException e ) {
270
- log .error ("invalid EventDeleteFilter method signature" , e );
271
- return true ;
272
- }
270
+ return invokePredicate ("DELETE-EventFilter" , target , method , deleteObj , cacheStatusUnknown );
273
271
}
274
272
}
275
273
276
274
private static class ReadyFuncAdaptor implements Supplier <Boolean > {
277
- private Method method ;
278
- private Object target ;
275
+ private final Method method ;
276
+ private final Object target ;
279
277
280
278
private ReadyFuncAdaptor (Object target , Method method ) {
281
279
this .method = method ;
@@ -284,12 +282,7 @@ private ReadyFuncAdaptor(Object target, Method method) {
284
282
285
283
@ Override
286
284
public Boolean get () {
287
- try {
288
- return (boolean ) method .invoke (target );
289
- } catch (IllegalAccessException | InvocationTargetException e ) {
290
- log .error ("invalid ReadyFunc method signature" , e );
291
- return false ;
292
- }
285
+ return invokePredicate ("READY-Func" , target , method );
293
286
}
294
287
}
295
288
0 commit comments