+
Skip to content

Fix thread-safety issue in FixtureSpecificationMapper. #260

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

Merged
merged 1 commit into from
Feb 7, 2018
Merged
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
Expand Up @@ -18,7 +18,12 @@
*/
public class FixtureSpecificationMapper {

private static ServiceLoader<TestFrameworkProvider> serviceLoader = ServiceLoader.load(TestFrameworkProvider.class);
private static ThreadLocal serviceLoaderHolder = new ThreadLocal<ServiceLoader<TestFrameworkProvider>>() {
@Override
protected ServiceLoader<TestFrameworkProvider> initialValue() {
return ServiceLoader.load(TestFrameworkProvider.class);
}
};

public static Resource toSpecificationResource(Object fixture, String specificationSuffix) {
String slashedClassName = fixture.getClass().getName().replaceAll("\\.", "/");
Expand Down Expand Up @@ -49,6 +54,7 @@ public static Class<?> findFixtureClass(Resource hrefResource) throws ClassNotFo
private static Class<?> getFixtureClass(String name) throws ClassNotFoundException {
try {
Class<?> clazz = Class.forName(name);
ServiceLoader<TestFrameworkProvider> serviceLoader = (ServiceLoader<TestFrameworkProvider>) serviceLoaderHolder.get();
Iterator<TestFrameworkProvider> iterator = serviceLoader.iterator();
while (iterator.hasNext()) {
TestFrameworkProvider provider = iterator.next();
Expand Down
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载