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

When Spring's @Validated annotation is used on a controller, the transaction name will be the proxied class name. #1574

Closed
jtduffy opened this issue Nov 6, 2023 · 1 comment · Fixed by #1575
Assignees
Labels
estimate Issue needing estimation feature request Suggestion for a new product enhancement or change

Comments

@jtduffy
Copy link
Contributor

jtduffy commented Nov 6, 2023

Investigate the following:
If a Spring controller class is annotated with @Validated, Spring will create a proxy class for the target controller. Because of this, the transaction name contains the "mangled" proxy class name and not the original name. For example: MyControlller$SpringCGLIB$$0

Possibly use something like https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/util/ClassUtils.html#getUserClass(java.lang.Class) (or similar) to retrieve the original class name.

    public static Class<?> getUserClass(Class<?> clazz) {
        if (clazz.getName().contains("$$")) {
            Class<?> superclass = clazz.getSuperclass();
            if (superclass != null && superclass != Object.class) {
                return superclass;
            }
        }

        return clazz;
    }
@jtduffy jtduffy added estimate Issue needing estimation feature request Suggestion for a new product enhancement or change labels Nov 6, 2023
@workato-integration
Copy link

@jtduffy jtduffy moved this from Triage to In progress in Java Engineering Board Nov 6, 2023
@jtduffy jtduffy self-assigned this Nov 6, 2023
@jtduffy jtduffy moved this from In progress to Needs Review in Java Engineering Board Nov 6, 2023
@github-project-automation github-project-automation bot moved this from Needs Review to Code Complete/Done in Java Engineering Board Nov 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
estimate Issue needing estimation feature request Suggestion for a new product enhancement or change
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant