Skip to content

[RESTEASY-3621] Resource methods inherited from package-private class not registered - #4834

Merged
jamezp merged 2 commits into
resteasy:mainfrom
christosderetzis:RESTEASY-3621
May 6, 2026
Merged

jamezp merged 2 commits into
resteasy:mainfrom
christosderetzis:RESTEASY-3621

Conversation

@christosderetzis

Copy link
Copy Markdown

@christosderetzis
christosderetzis requested a review from a team as a code owner April 9, 2026 09:09

@jamezp jamezp left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the removal of setting methods to be accessible, we need to add something like this:

protected void processMethod(boolean isLocator, ResourceClassBuilder resourceClassBuilder, Class<?> root,
        Method implementation) {
    processMethod(resourceClassBuilder, root, implementation, implementation);
}

/**
 * Process the resource method to configure the builder.
 *
 * @param resourceClassBuilder the builder to configure
 * @param root                 the root resource class
 * @param implementation       the method to be invoked (may be a bridge method)
 * @param annotatedMethod         the method containing Jakarta REST annotations (may be in a superclass)
 */
private void processMethod(final ResourceClassBuilder resourceClassBuilder, final Class<?> root,
        final Method implementation, final Method annotatedMethod) {
    Method method = getAnnotatedMethod(root, annotatedMethod);
    if (method != null) {
        Set<String> httpMethods = getHttpMethods(method);

        ResourceLocatorBuilder<?> resourceLocatorBuilder;

        if (httpMethods == null) {
            resourceLocatorBuilder = resourceClassBuilder.locator(implementation, method);
        } else {
            ResourceMethodBuilder resourceMethodBuilder = resourceClassBuilder.method(implementation, method);
            resourceLocatorBuilder = resourceMethodBuilder;

            for (String httpMethod : httpMethods) {
                if (httpMethod.equalsIgnoreCase(HttpMethod.GET))
                    resourceMethodBuilder.get();
                else if (httpMethod.equalsIgnoreCase(HttpMethod.PUT))
                    resourceMethodBuilder.put();
                else if (httpMethod.equalsIgnoreCase(HttpMethod.POST))
                    resourceMethodBuilder.post();
                else if (httpMethod.equalsIgnoreCase(HttpMethod.DELETE))
                    resourceMethodBuilder.delete();
                else if (httpMethod.equalsIgnoreCase(HttpMethod.OPTIONS))
                    resourceMethodBuilder.options();
                else if (httpMethod.equalsIgnoreCase(HttpMethod.HEAD))
                    resourceMethodBuilder.head();
                else
                    resourceMethodBuilder.httpMethod(httpMethod);
            }
            Produces produces = method.getAnnotation(Produces.class);
            if (produces == null)
                produces = resourceClassBuilder.resourceClass.getClazz().getAnnotation(Produces.class);
            if (produces == null)
                produces = method.getDeclaringClass().getAnnotation(Produces.class);
            if (produces != null)
                resourceMethodBuilder.produces(produces.value());

            Consumes consumes = method.getAnnotation(Consumes.class);
            if (consumes == null)
                consumes = resourceClassBuilder.resourceClass.getClazz().getAnnotation(Consumes.class);
            if (consumes == null)
                consumes = method.getDeclaringClass().getAnnotation(Consumes.class);
            if (consumes != null)
                resourceMethodBuilder.consumes(consumes.value());
        }
        Path methodPath = method.getAnnotation(Path.class);
        if (methodPath != null)
            resourceLocatorBuilder.path(methodPath.value());
        for (int i = 0; i < resourceLocatorBuilder.locator.params.length; i++) {
            resourceLocatorBuilder.param(i).fromAnnotations();
        }
        resourceLocatorBuilder.buildMethod();
    }
}

Note this same thing will need to be done to the 6.2 variant too.

locator.fullpath = pathExpression;
if (locator.resourceClass.getClazz().isAnonymousClass()) {
if (locator.resourceClass.getClazz().isAnonymousClass()
|| !Modifier.isPublic(locator.getMethod().getDeclaringClass().getModifiers())) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

method.fullpath = pathExpression;
if (method.resourceClass.getClazz().isAnonymousClass()) {
if (method.resourceClass.getClazz().isAnonymousClass()
|| !Modifier.isPublic(method.getMethod().getDeclaringClass().getModifiers())) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jamezp

jamezp commented May 4, 2026

Copy link
Copy Markdown
Member

@g-tom do we have permissions to include your tests from Intevation@5464294?

@jamezp jamezp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you squash the commits down to a single commit please?

@g-tom

g-tom commented May 5, 2026

Copy link
Copy Markdown

@g-tom do we have permissions to include your tests from Intevation@5464294?

Of course you have. Thanks for the work on the issue!

…te class not registered

remove unnecessary resource class

[RESTEASY-3621] Resolve PR comments

[RESTEASY-3621] Skip bridge methods that have a non-synthetic counterpart in the declaring class
@christosderetzis

Copy link
Copy Markdown
Author

Can you squash the commits down to a single commit please?

@jamezp Done, i did the same for 6.2 PR

@jamezp
jamezp merged commit f8fab61 into resteasy:main May 6, 2026
19 checks passed
@jamezp

jamezp commented May 6, 2026

Copy link
Copy Markdown
Member

Thank you @g-tom and @christosderetzis

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants