question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

pass task context when dealing with Java Dynamic Proxy

See original GitHub issue

Hi , create a new Task inside Dynamic Proxy invoke method could get around the non-weaved problem , but if i put the execution logic inside the Task Body, then i will lost the previous Task’s context . `@override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {

final Method mtd = method;
final Object[] ags = args;
if (!sppCmdMap.containsKey(method.getName())) {
    return null;
}
final RpcContext rpcContext = RpcContext.getContext(KilimTask.getCurrentTask().id);
Task t = new Task() {
    public void execute() throws Exception, Pausable {

        if (!sppCmdMap.containsKey(mtd.getName())) {
            return;
        }
        RpcCmdInfo cmd = sppCmdMap.get(mtd.getName());
        if (ags[0] instanceof List) {
            List<Message> reqs = (List<Message>) ags[0];
            exit(rpcInvokeBatch(reqs, cmd, rpcContext));
        } else {
            Message req = (Message) ags[0];
            exit(rpcInvoke(req, cmd, rpcContext));
        }
    }
};
t.start();
ExitMsg m = t.joinb();
return m.result;

} `

here if i want get the previous Task’s Context , i have to use KilimTask.getCurrentTask().id but this is a Pausable method … is there any good idea to solve this ? Tks advance ! : ) BTW , Kilim is really awesome ! our team is really enjoy with it .

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:20 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
nqzerocommented, Jan 29, 2018

@JasonHuangHuster i just saw your DynamicWeaverExampleKilim.txt file - i’ll take a look and see if that helps me understand this problem

0reactions
nqzerocommented, Sep 22, 2018

the invoke demo is working with java 7, 8, 9, 10 and 11 - closing this issue, feel free to reopen or create a new issue if this doesn’t solve your issue (no additional comments since january)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Java Dynamic Proxy - How reference concrete class
The way to intercept methods using dynamic proxies are by: public class FooHandler implements InvocationHandler { private Object realObject; ...
Read more >
Dynamic Proxies in Java - Baeldung
Simply put, proxies are fronts or wrappers that pass function invocation through their own facilities (usually onto real methods) – potentially ...
Read more >
Dynamic Proxy Classes
A dynamic proxy class is a class that implements a list of interfaces specified at runtime such that a method invocation through one...
Read more >
Dynamic Proxies | Java Type Information and Reflection
A dynamic proxy can intercept a method call, examine or modify the parameters, pass the call to some other object, examine or modify...
Read more >
A Guide To Java Dynamic Proxies And It In Coding. - Xperti
Java dynamic proxies is a design pattern used to extend the pre-made methods without making any changes in them.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found