Skip to content

Can i add interceptor to the method inherited from superclasses? #5919

@tankilo

Description

@tankilo

Prerequisites

Please check the FAQ, and search existing issues for similar questions before creating a new issue.YOU MAY DELETE THIS PREREQUISITES SECTION.

  • I have checked the FAQ, and issues and found no answer.
import java.util.concurrent.CompletableFuture;
public abstract class AbstractResult extends CompletableFuture<Result> implements Result 
public class MyResult extends AbstractResult 
transformTemplate.transform("com.tankilo.MyResult", new MyResultTransform());
// MyResult.java
InstrumentMethod complete = target.getDeclaredMethod("complete", "java.lang.Object");

When i debug the code, variable complete will be null, this is because getDeclaredMethod has the same behaviour as java.lang.Class.getDeclaredMethods() , so the inherited method java.util.concurrent.CompletableFuture#complete is excluded.

MyResult is a shared variable between two threads, the result of an async opertaion.
When MyResult#complete is called, i want to enhance this method with AsyncContextSpanEventSimpleAroundInterceptor and get the final result of the async opertaion.

So can i add interceptor to the method inherited from superclasses?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions