1/*
2 * Copyright (c) 2011, 2019 Oracle and/or its affiliates. All rights reserved.
3 *
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v. 2.0, which is available at
6 * http://www.eclipse.org/legal/epl-2.0.
7 *
8 * This Source Code may also be made available under the following Secondary
…lines 9–15 unchanged (7 lines)
16
17package jakarta.ws.rs.client;
18
19import javax.net.ssl.HostnameVerifier;
20import javax.net.ssl.SSLContext;
21import java.net.URL;
22import java.security.AccessController;
23import java.security.KeyStore;
24import java.security.PrivilegedAction;
25import java.util.concurrent.ExecutorService;
26import java.util.concurrent.ScheduledExecutorService;
27import java.util.concurrent.TimeUnit;
28import java.util.concurrent.TimeoutException;
29
30import jakarta.ws.rs.ProcessingException;
…lines 31–57 unchanged (27 lines)
58 * @return new client builder instance.
59 */
60 public static ClientBuilder newBuilder() {
61 try {
62 Object delegate = FactoryFinder.find(JAXRS_DEFAULT_CLIENT_BUILDER_PROPERTY, ClientBuilder.class);
63 if (!(delegate instanceof ClientBuilder)) {
64 final CreateErrorMessageAction action = new CreateErrorMessageAction(delegate);
65 final String errorMessage;
66 if (System.getSecurityManager() == null) {
67 errorMessage = action.run();
68 } else {
69 errorMessage = AccessController.doPrivileged(action);
70 }
71 throw new LinkageError(errorMessage);
72 }
73 return (ClientBuilder) delegate;
74 } catch (Exception ex) {
75 throw new RuntimeException(ex);
76 }
77 }
…lines 78–268 unchanged (191 lines)
269 * Build a new client instance using all the configuration previously specified in this client builder.
270 *
271 * @return a new client instance.
272 */
273 public abstract Client build();
274
275 private static final class CreateErrorMessageAction implements PrivilegedAction<String> {
276 private final Object delegate;
277
278 private CreateErrorMessageAction(final Object delegate) {
279 this.delegate = delegate;
280 }
281
282 @Override
283 public String run() {
284 Class<?> pClass = ClientBuilder.class;
285 String classnameAsResource = pClass.getName().replace('.', '/') + ".class";
286 ClassLoader loader = pClass.getClassLoader();
287 if (loader == null) {
288 loader = ClassLoader.getSystemClassLoader();
289 }
290 URL targetTypeURL = loader.getResource(classnameAsResource);
291 return "ClassCastException: attempting to cast"
292 + delegate.getClass().getClassLoader().getResource(classnameAsResource)
293 + " to " + targetTypeURL;
294 }
295 }
296}
297