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

238: Remove recursive classloader check in loadSpi #239

Merged
merged 1 commit into from
Dec 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*******************************************************************************
* Copyright (c) 2016-2017 Contributors to the Eclipse Foundation
* Copyright (c) 2016-2019 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
Expand Down Expand Up @@ -98,26 +98,19 @@ private static RestClientBuilderResolver loadSpi(ClassLoader cl) {
return null;
}

// start from the root CL and go back down to the TCCL
PrivilegedAction<ClassLoader> action = () -> cl.getParent();
RestClientBuilderResolver resolver = loadSpi(AccessController.doPrivileged(action));
RestClientBuilderResolver instance = null;

if (resolver == null) {
ServiceLoader<RestClientBuilderResolver> sl = ServiceLoader.load(
RestClientBuilderResolver.class, cl);
for (RestClientBuilderResolver spi : sl) {
if (resolver != null) {
throw new IllegalStateException(
"Multiple RestClientBuilderResolver implementations found: "
+ spi.getClass().getName() + " and "
+ resolver.getClass().getName());
}
else {
resolver = spi;
}
ServiceLoader<RestClientBuilderResolver> sl = ServiceLoader.load(RestClientBuilderResolver.class, cl);
for (RestClientBuilderResolver spi : sl) {
if (instance != null) {
throw new IllegalStateException("Multiple RestClientBuilderResolver implementations found: "
+ spi.getClass().getName() + " and "
+ instance.getClass().getName());
}
instance = spi;
}
return resolver;

return instance;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@
* provide additional functionality for MP Rest Clients.
*
*/
@org.osgi.annotation.versioning.Version("1.1")
Copy link
Contributor

Choose a reason for hiding this comment

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

any reason why a patch over minor?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was thinking about removing the setInstance method per issue #103 - which would force the package version to be 2.0, but then I realized that we hadn't actually come to a consensus on that. Since this change isn't changing any method signatures, it shouldn't require a minor update. I'm not an expert in semantic versioning, but I think in this case, a micro version update is correct.

I'd also like to separate the "spi" package into it's own artifact - that might require a version change too, but I'm not positive about that.

Copy link
Contributor

Choose a reason for hiding this comment

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

Took a quick look at semVer and it probably does align with a patch version

@org.osgi.annotation.versioning.Version("1.1.1")
package org.eclipse.microprofile.rest.client.spi;