Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] - Exclude method also change parameter name #1561

Open
ZQiannnn opened this issue Jan 5, 2023 · 1 comment
Open

[Bug] - Exclude method also change parameter name #1561

ZQiannnn opened this issue Jan 5, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@ZQiannnn
Copy link

ZQiannnn commented Jan 5, 2023

Describe the bug
config yaml:

      s_exclude_lock_scope:
        type:
          name: '.*((Controller|Service.*))$'
          matcher-mode: MATCHES
        methods:
          - annotations:
              - name: 'Lock'
                matcher-mode: CONTAINS
      s_common_code_scope:
        type:
          name: '.*((Controller|Service.*))$'
          matcher-mode: MATCHES
        methods:
          - name: '^((?!lambda).)*$'
            matcher-mode: MATCHES
        exclude:
          s_exclude_lock_scope: true

method:

 @Lock(
        name = "'hwkf:instance.deployment.' + #deployment.deploymentId",
        nameIsSpel = true,
        lockType = LockType.READ
    )
    public FlowModel getFlowModelByDeployment(DefDeployment deployment) 


    public void othermethod()...

aspect:

public LockInfo getLockInfo(JoinPoint joinPoint, Lock lock) {
        Method method = this.getMethod(joinPoint);
        Object[] parameterValues = joinPoint.getArgs();
        EvaluationContext context = new StandardEvaluationContext();
        Parameter[] parameters = method.getParameters();

        Object value;
        for(int i = 0; i < parameters.length; ++i) {
            String name = parameters[i].getName();
            value = parameterValues[i];
            context.setVariable(name, value);
        }
...
}

the agent log shows javaagent not add hook for lock method,but the class is redefined
and i get an error in aspect because of variable name changed

Expected behavior
exclude scope don't change parameter name

Desktop (please complete the following information):

  • OS: Linux
  • Version 2.2.0
@ZQiannnn ZQiannnn added the bug Something isn't working label Jan 5, 2023
@ZQiannnn
Copy link
Author

ZQiannnn commented Jan 5, 2023

When i try use typepool before decorate, the problem is solved

rocks.inspectit.ocelot.core.instrumentation.transformer.AbstractClassTransformer#instrumentByteCode

 TypePool typePool = TypePool.Default.of(ClassFileLocator.ForClassLoader.of(typeWithLoader.getLoader()));

            DynamicType.Builder<?> builder = new ByteBuddy()
                    .decorate(typePool.describe(typeWithLoader.getName()).resolve(), ClassFileLocator.ForClassLoader.of(typeWithLoader.getLoader()));

I'm not sure is the rigth way

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant