private < T > boolean processMethod ( AnnotatedMethod < T > method , Class < ? > clazz , Asynchronous classLevelAsync ) { FTEnablementConfig config = FaultToleranceCDIComponent . getEnablementConfig ( ) ; Method javaMethod = method . getJavaMember ( ) ; if ( javaMethod . isBridge ( ) ) { // Skip all validation for bridge methods // Bridge methods are created when a class overrides a method but provides more specific return or parameter types // (usually when implementing a generic interface) // In these cases, the bridge method matches the signature of the overridden method after type erasure and delegates directly to the overriding method // In some cases, the signature of the overriding method is valid for some microprofile annotation, but the signature of the bridge method is not // However, the user's code is valid, and weld seems to make sure that any interceptors get called with the real method in the InvocationContext. return false ; } if ( classLevelAsync != null ) { AsynchronousConfig asynchronous = annotationConfigFactory . createAsynchronousConfig ( javaMethod , clazz , classLevelAsync ) ; asynchronous . validate ( ) ; } boolean needsIntercepting = false ; Set < Annotation > annotations = method . getAnnotations ( ) ; for ( Annotation annotation : annotations ) { if ( config . isFaultTolerance ( annotation ) ) { if ( config . isAnnotationEnabled ( annotation , clazz , method . getJavaMember ( ) ) ) { needsIntercepting = true ; if ( annotation . annotationType ( ) == Asynchronous . class ) { AsynchronousConfig asynchronous = annotationConfigFactory . createAsynchronousConfig ( javaMethod , clazz , ( Asynchronous ) annotation ) ; asynchronous . validate ( ) ; } else if ( annotation . annotationType ( ) == Fallback . class ) { FallbackConfig fallback = new FallbackConfig ( javaMethod , clazz , ( Fallback ) annotation ) ; fallback . validate ( ) ; } else if ( annotation . annotationType ( ) == Retry . class ) { RetryConfig retry = new RetryConfig ( javaMethod , clazz , ( Retry ) annotation ) ; retry . validate ( ) ; } else if ( annotation . annotationType ( ) == Timeout . class ) { TimeoutConfig timeout = new TimeoutConfig ( javaMethod , clazz , ( Timeout ) annotation ) ; timeout . validate ( ) ; } else if ( annotation . annotationType ( ) == CircuitBreaker . class ) { CircuitBreakerConfig circuitBreaker = new CircuitBreakerConfig ( javaMethod , clazz , ( CircuitBreaker ) annotation ) ; circuitBreaker . validate ( ) ; } else if ( annotation . annotationType ( ) == Bulkhead . class ) { BulkheadConfig bulkhead = new BulkheadConfig ( javaMethod , clazz , ( Bulkhead ) annotation ) ; bulkhead . validate ( ) ; } } else { if ( isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "Annotation {0} on {1} was disabled and will be ignored" , annotation . annotationType ( ) . getSimpleName ( ) , clazz . getCanonicalName ( ) + "." + method . getJavaMember ( ) . getName ( ) ) ; } } } } return needsIntercepting ; }
Validate a method and return whether it has fault tolerance annotations which require us to add the FT interceptor