Skip to content

ServiceBootstrap unit test fix#3593

Merged
nobodyiam merged 2 commits into
apolloconfig:masterfrom
vdiskg:unit-test-fix
Mar 13, 2021
Merged

ServiceBootstrap unit test fix#3593
nobodyiam merged 2 commits into
apolloconfig:masterfrom
vdiskg:unit-test-fix

Conversation

@vdiskg
Copy link
Copy Markdown
Contributor

@vdiskg vdiskg commented Mar 10, 2021

on jdk11 the method java.util.ServiceLoader#load called the check method java.util.ServiceLoader#checkCaller
the private interface cause the error service type not accessible to xxx

    private static void checkCaller(Class<?> caller, Class<?> svc) {
        ...
        // Check access to the service type
        Module callerModule = caller.getModule();
        int mods = svc.getModifiers();
        if (!Reflection.verifyMemberAccess(caller, svc, null, mods)) {
            fail(svc, "service type not accessible to " + callerModule);
        }
        ...
    }

}

private interface Interface1 {
public interface Interface1 {
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.

How about this?

Suggested change
public interface Interface1 {
interface Interface1 {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That's right, package-private is enough for ServiceLoader

Copy link
Copy Markdown
Member

@nobodyiam nobodyiam left a comment

Choose a reason for hiding this comment

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

LGTM

@nobodyiam nobodyiam merged commit d059795 into apolloconfig:master Mar 13, 2021
@nobodyiam nobodyiam added this to the 1.9.0 milestone Mar 16, 2021
@vdiskg vdiskg deleted the unit-test-fix branch April 22, 2021 16:23
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.

2 participants