From 189bea4dd5e7440f2ecf8a43211e101d285e9a6e Mon Sep 17 00:00:00 2001 From: Arghya Sadhu Date: Sat, 31 Oct 2020 16:12:35 +0530 Subject: [PATCH] remove thrown KubernetesClientException --- .../kubernetes/client/AppsAPIGroupClient.java | 4 +- .../client/AutoAdaptableKubernetesClient.java | 8 +-- .../fabric8/kubernetes/client/BaseClient.java | 8 +-- .../client/BatchAPIGroupClient.java | 4 +- .../client/ExtensionsAPIGroupClient.java | 4 +- .../client/MetricAPIGroupClient.java | 4 +- .../client/NetworkAPIGroupClient.java | 4 +- .../kubernetes/client/RbacAPIGroupClient.java | 4 +- .../client/SchedulingAPIGroupClient.java | 2 +- .../client/SettingsAPIGroupClient.java | 2 +- .../client/StorageAPIGroupClient.java | 4 +- .../client/dsl/base/OperationSupport.java | 49 ++++++------------- .../RawCustomResourceOperationsImpl.java | 37 +++++--------- .../informers/SharedInformerFactory.java | 5 +- .../client/utils/Serialization.java | 5 -- .../client/DefaultOpenShiftClient.java | 10 ++-- 16 files changed, 59 insertions(+), 95 deletions(-) diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/AppsAPIGroupClient.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/AppsAPIGroupClient.java index f57a4c7b53b..0e9f4f1b550 100644 --- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/AppsAPIGroupClient.java +++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/AppsAPIGroupClient.java @@ -40,11 +40,11 @@ public class AppsAPIGroupClient extends BaseClient implements AppsAPIGroupDSL { - public AppsAPIGroupClient() throws KubernetesClientException { + public AppsAPIGroupClient() { super(); } - public AppsAPIGroupClient(OkHttpClient httpClient, final Config config) throws KubernetesClientException { + public AppsAPIGroupClient(OkHttpClient httpClient, final Config config) { super(httpClient, config); } diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/AutoAdaptableKubernetesClient.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/AutoAdaptableKubernetesClient.java index 997e7836424..a03ca3a1e6d 100644 --- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/AutoAdaptableKubernetesClient.java +++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/AutoAdaptableKubernetesClient.java @@ -74,19 +74,19 @@ public class AutoAdaptableKubernetesClient extends DefaultKubernetesClient { private KubernetesClient delegate; - public AutoAdaptableKubernetesClient() throws KubernetesClientException { + public AutoAdaptableKubernetesClient() { delegate = adapt(new DefaultKubernetesClient()); } - public AutoAdaptableKubernetesClient(OkHttpClient httpClient, Config config) throws KubernetesClientException { + public AutoAdaptableKubernetesClient(OkHttpClient httpClient, Config config) { delegate = adapt(new DefaultKubernetesClient(httpClient, config)); } - public AutoAdaptableKubernetesClient(Config config) throws KubernetesClientException { + public AutoAdaptableKubernetesClient(Config config) { delegate = adapt(new DefaultKubernetesClient(config)); } - public AutoAdaptableKubernetesClient(String masterUrl) throws KubernetesClientException { + public AutoAdaptableKubernetesClient(String masterUrl) { delegate = adapt(new DefaultKubernetesClient(masterUrl)); } diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/BaseClient.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/BaseClient.java index ac971f08999..b93d514884e 100644 --- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/BaseClient.java +++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/BaseClient.java @@ -39,19 +39,19 @@ public abstract class BaseClient implements Client, HttpClientAware { private String namespace; private Config configuration; - public BaseClient() throws KubernetesClientException { + public BaseClient() { this(new ConfigBuilder().build()); } - public BaseClient(String masterUrl) throws KubernetesClientException { + public BaseClient(String masterUrl) { this(new ConfigBuilder().withMasterUrl(masterUrl).build()); } - public BaseClient(final Config config) throws KubernetesClientException { + public BaseClient(final Config config) { this(HttpClientUtils.createHttpClient(config), config); } - public BaseClient(final OkHttpClient httpClient, Config config) throws KubernetesClientException { + public BaseClient(final OkHttpClient httpClient, Config config) { try { this.httpClient = httpClient; this.namespace = config.getNamespace(); diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/BatchAPIGroupClient.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/BatchAPIGroupClient.java index a0395cc3eac..c709a34a8da 100644 --- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/BatchAPIGroupClient.java +++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/BatchAPIGroupClient.java @@ -31,11 +31,11 @@ public class BatchAPIGroupClient extends BaseClient implements BatchAPIGroupDSL { - public BatchAPIGroupClient() throws KubernetesClientException { + public BatchAPIGroupClient() { super(); } - public BatchAPIGroupClient(OkHttpClient httpClient, final Config config) throws KubernetesClientException { + public BatchAPIGroupClient(OkHttpClient httpClient, final Config config) { super(httpClient, config); } diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/ExtensionsAPIGroupClient.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/ExtensionsAPIGroupClient.java index 2728298dc23..3d16bfc7dca 100644 --- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/ExtensionsAPIGroupClient.java +++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/ExtensionsAPIGroupClient.java @@ -52,11 +52,11 @@ public class ExtensionsAPIGroupClient extends BaseClient implements ExtensionsAPIGroupDSL { - public ExtensionsAPIGroupClient() throws KubernetesClientException { + public ExtensionsAPIGroupClient() { super(); } - public ExtensionsAPIGroupClient(OkHttpClient httpClient, final Config config) throws KubernetesClientException { + public ExtensionsAPIGroupClient(OkHttpClient httpClient, final Config config) { super(httpClient, config); } diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/MetricAPIGroupClient.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/MetricAPIGroupClient.java index 375bb70795e..357e7dbcf65 100644 --- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/MetricAPIGroupClient.java +++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/MetricAPIGroupClient.java @@ -21,11 +21,11 @@ import okhttp3.OkHttpClient; public class MetricAPIGroupClient extends BaseClient implements MetricAPIGroupDSL { - public MetricAPIGroupClient() throws KubernetesClientException { + public MetricAPIGroupClient() { super(); } - public MetricAPIGroupClient(OkHttpClient httpClient, final Config config) throws KubernetesClientException { + public MetricAPIGroupClient(OkHttpClient httpClient, final Config config) { super(httpClient, config); } diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/NetworkAPIGroupClient.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/NetworkAPIGroupClient.java index bf5a549c286..3c9b19c97e2 100644 --- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/NetworkAPIGroupClient.java +++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/NetworkAPIGroupClient.java @@ -30,11 +30,11 @@ public class NetworkAPIGroupClient extends BaseClient implements NetworkAPIGroupDSL { - public NetworkAPIGroupClient() throws KubernetesClientException { + public NetworkAPIGroupClient() { super(); } - public NetworkAPIGroupClient(OkHttpClient httpClient, final Config config) throws KubernetesClientException { + public NetworkAPIGroupClient(OkHttpClient httpClient, final Config config) { super(httpClient, config); } diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/RbacAPIGroupClient.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/RbacAPIGroupClient.java index a0647133a78..a3260e171dd 100644 --- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/RbacAPIGroupClient.java +++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/RbacAPIGroupClient.java @@ -31,11 +31,11 @@ public class RbacAPIGroupClient extends BaseClient implements RbacAPIGroupDSL { - public RbacAPIGroupClient() throws KubernetesClientException { + public RbacAPIGroupClient() { super(); } - public RbacAPIGroupClient(OkHttpClient httpClient, final Config config) throws KubernetesClientException { + public RbacAPIGroupClient(OkHttpClient httpClient, final Config config) { super(httpClient, config); } diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/SchedulingAPIGroupClient.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/SchedulingAPIGroupClient.java index 668e3b5b755..7a7d2f77412 100644 --- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/SchedulingAPIGroupClient.java +++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/SchedulingAPIGroupClient.java @@ -25,7 +25,7 @@ import okhttp3.OkHttpClient; public class SchedulingAPIGroupClient extends BaseClient implements SchedulingAPIGroupDSL { - public SchedulingAPIGroupClient(OkHttpClient httpClient, final Config config) throws KubernetesClientException { + public SchedulingAPIGroupClient(OkHttpClient httpClient, final Config config) { super(httpClient, config); } diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/SettingsAPIGroupClient.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/SettingsAPIGroupClient.java index 43f79e3545a..f74cc183d5b 100644 --- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/SettingsAPIGroupClient.java +++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/SettingsAPIGroupClient.java @@ -25,7 +25,7 @@ import okhttp3.OkHttpClient; public class SettingsAPIGroupClient extends BaseClient implements SettingsAPIGroupDSL { - public SettingsAPIGroupClient(OkHttpClient httpClient, final Config config) throws KubernetesClientException { + public SettingsAPIGroupClient(OkHttpClient httpClient, final Config config) { super(httpClient, config); } @Override diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/StorageAPIGroupClient.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/StorageAPIGroupClient.java index 272275fffcc..c77aad48c05 100644 --- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/StorageAPIGroupClient.java +++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/StorageAPIGroupClient.java @@ -26,11 +26,11 @@ public class StorageAPIGroupClient extends BaseClient implements StorageAPIGroupDSL { - public StorageAPIGroupClient() throws KubernetesClientException { + public StorageAPIGroupClient() { super(); } - public StorageAPIGroupClient(OkHttpClient httpClient, final Config config) throws KubernetesClientException { + public StorageAPIGroupClient(OkHttpClient httpClient, final Config config) { super(httpClient, config); } diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/OperationSupport.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/OperationSupport.java index 09d6bf06415..50169cc9d6d 100644 --- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/OperationSupport.java +++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/OperationSupport.java @@ -16,7 +16,6 @@ package io.fabric8.kubernetes.client.dsl.base; import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; @@ -243,10 +242,9 @@ protected void handleDelete(URL requestUrl, long gracePeriodSeconds, DeletionPro * @return returns de-serialized version of apiserver response in form of type provided * @throws ExecutionException Execution Exception * @throws InterruptedException Interrupted Exception - * @throws KubernetesClientException KubernetesClientException * @throws IOException IOException */ - protected T handleCreate(I resource, Class outputType) throws ExecutionException, InterruptedException, KubernetesClientException, IOException { + protected T handleCreate(I resource, Class outputType) throws ExecutionException, InterruptedException, IOException { RequestBody body = RequestBody.create(JSON, JSON_MAPPER.writeValueAsString(resource)); Request.Builder requestBuilder = new Request.Builder().post(body).url(getNamespacedUrl(checkNamespace(resource))); return handleResponse(requestBuilder, outputType, Collections.emptyMap()); @@ -263,10 +261,9 @@ protected T handleCreate(I resource, Class outputType) throws Executio * @return returns de-serialized version of api server response * @throws ExecutionException Execution Exception * @throws InterruptedException Interrupted Exception - * @throws KubernetesClientException KubernetesClientException * @throws IOException IOException */ - protected T handleReplace(T updated, Class type) throws ExecutionException, InterruptedException, KubernetesClientException, IOException { + protected T handleReplace(T updated, Class type) throws ExecutionException, InterruptedException, IOException { return handleReplace(updated, type, Collections.emptyMap()); } @@ -281,10 +278,9 @@ protected T handleReplace(T updated, Class type) throws ExecutionExceptio * @return returns de-serialized version of api server response. * @throws ExecutionException Execution Exception * @throws InterruptedException Interrupted Exception - * @throws KubernetesClientException KubernetesClientException * @throws IOException IOException */ - protected T handleReplace(T updated, Class type, Map parameters) throws ExecutionException, InterruptedException, KubernetesClientException, IOException { + protected T handleReplace(T updated, Class type, Map parameters) throws ExecutionException, InterruptedException, IOException { RequestBody body = RequestBody.create(JSON, JSON_MAPPER.writeValueAsString(updated)); Request.Builder requestBuilder = new Request.Builder().put(body).url(getResourceUrl(checkNamespace(updated), checkName(updated))); return handleResponse(requestBuilder, type, parameters); @@ -307,10 +303,9 @@ protected T handleStatusUpdate(T updated, Class type) throws ExecutionExc * @return returns de-serialized version of api server response * @throws ExecutionException Execution Exception * @throws InterruptedException Interrupted Exception - * @throws KubernetesClientException KubernetesClientException * @throws IOException IOException */ - protected T handlePatch(T current, T updated, Class type) throws ExecutionException, InterruptedException, KubernetesClientException, IOException { + protected T handlePatch(T current, T updated, Class type) throws ExecutionException, InterruptedException, IOException { JsonNode diff = JsonDiff.asJson(patchMapper().valueToTree(current), patchMapper().valueToTree(updated)); RequestBody body = RequestBody.create(JSON_PATCH, JSON_MAPPER.writeValueAsString(diff)); Request.Builder requestBuilder = new Request.Builder().patch(body).url(getResourceUrl(checkNamespace(updated), checkName(updated))); @@ -328,7 +323,6 @@ protected T handlePatch(T current, T updated, Class type) throws Executio * @return returns de-serialized version of api server response * @throws ExecutionException Execution Exception * @throws InterruptedException Interrupted Exception - * @throws KubernetesClientException KubernetesClientException * @throws IOException IOException */ protected T handlePatch(T current, Map patchForUpdate, Class type) throws ExecutionException, InterruptedException, IOException { @@ -345,12 +339,9 @@ protected T handlePatch(T current, Map patchForUpdate, Class * @return updated Scale object * @throws ExecutionException in case of any execution exception * @throws InterruptedException in case thread is interrupted - * @throws KubernetesClientException in case error from Kubernetes API - * @throws MalformedURLException in case URL formed in invalid - * @throws JsonProcessingException in case Json processing fails * @throws IOException in some other I/O problem */ - protected Scale handleScale(String resourceUrl, Scale scale) throws ExecutionException, InterruptedException, KubernetesClientException, MalformedURLException, JsonProcessingException, IOException { + protected Scale handleScale(String resourceUrl, Scale scale) throws ExecutionException, InterruptedException, IOException { Request.Builder requestBuilder; if (scale != null) { RequestBody body = RequestBody.create(JSON, JSON_MAPPER.writeValueAsString(scale)); @@ -369,12 +360,9 @@ protected Scale handleScale(String resourceUrl, Scale scale) throws ExecutionExc * @return Status * @throws ExecutionException in case of any execution exception * @throws InterruptedException in case thread is interrupted - * @throws KubernetesClientException in case error from Kubernetes API - * @throws MalformedURLException in case URL formed in invalid - * @throws JsonProcessingException in case Json processing fails * @throws IOException in some other I/O problem */ - protected Status handleDeploymentRollback(String resourceUrl, DeploymentRollback deploymentRollback) throws ExecutionException, InterruptedException, KubernetesClientException, MalformedURLException, JsonProcessingException, IOException { + protected Status handleDeploymentRollback(String resourceUrl, DeploymentRollback deploymentRollback) throws ExecutionException, InterruptedException, IOException { RequestBody body = RequestBody.create(JSON, JSON_MAPPER.writeValueAsString(deploymentRollback)); Request.Builder requestBuilder = new Request.Builder().post(body).url(resourceUrl + "/rollback"); return handleResponse(requestBuilder, Status.class); @@ -390,10 +378,9 @@ protected Status handleDeploymentRollback(String resourceUrl, DeploymentRollback * @return returns a deserialized object as api server response of provided type. * @throws ExecutionException Execution Exception * @throws InterruptedException Interrupted Exception - * @throws KubernetesClientException KubernetesClientException * @throws IOException IOException */ - protected T handleGet(URL resourceUrl, Class type) throws ExecutionException, InterruptedException, KubernetesClientException, IOException { + protected T handleGet(URL resourceUrl, Class type) throws ExecutionException, InterruptedException, IOException { return handleGet(resourceUrl, type, Collections.emptyMap()); } @@ -408,10 +395,9 @@ protected T handleGet(URL resourceUrl, Class type) throws ExecutionExcept * @return Returns a deserialized object as api server response of provided type. * @throws ExecutionException Execution Exception * @throws InterruptedException Interrupted Exception - * @throws KubernetesClientException KubernetesClientException * @throws IOException IOException */ - protected T handleGet(URL resourceUrl, Class type, Map parameters) throws ExecutionException, InterruptedException, KubernetesClientException, IOException { + protected T handleGet(URL resourceUrl, Class type, Map parameters) throws ExecutionException, InterruptedException, IOException { Request.Builder requestBuilder = new Request.Builder().get().url(resourceUrl); return handleResponse(requestBuilder, type, parameters); } @@ -426,10 +412,9 @@ protected T handleGet(URL resourceUrl, Class type, Map pa * @return Returns a de-serialized object as api server response of provided type. * @throws ExecutionException Execution Exception * @throws InterruptedException Interrupted Exception - * @throws KubernetesClientException KubernetesClientException * @throws IOException IOException */ - protected T handleResponse(Request.Builder requestBuilder, Class type) throws ExecutionException, InterruptedException, KubernetesClientException, IOException { + protected T handleResponse(Request.Builder requestBuilder, Class type) throws ExecutionException, InterruptedException, IOException { return handleResponse(requestBuilder, type, Collections.emptyMap()); } @@ -444,10 +429,9 @@ protected T handleResponse(Request.Builder requestBuilder, Class type) th * @return Returns a de-serialized object as api server response of provided type. * @throws ExecutionException Execution Exception * @throws InterruptedException Interrupted Exception - * @throws KubernetesClientException KubernetesClientException * @throws IOException IOException */ - protected T handleResponse(Request.Builder requestBuilder, Class type, Map parameters) throws ExecutionException, InterruptedException, KubernetesClientException, IOException { + protected T handleResponse(Request.Builder requestBuilder, Class type, Map parameters) throws ExecutionException, InterruptedException, IOException { return handleResponse(client, requestBuilder, type, parameters); } @@ -462,10 +446,9 @@ protected T handleResponse(Request.Builder requestBuilder, Class type, Ma * @return Returns a de-serialized object as api server response of provided type. * @throws ExecutionException Execution Exception * @throws InterruptedException Interrupted Exception - * @throws KubernetesClientException KubernetesClientException * @throws IOException IOException */ - protected T handleResponse(OkHttpClient client, Request.Builder requestBuilder, Class type) throws ExecutionException, InterruptedException, KubernetesClientException, IOException { + protected T handleResponse(OkHttpClient client, Request.Builder requestBuilder, Class type) throws ExecutionException, InterruptedException, IOException { return handleResponse(client, requestBuilder, type, Collections.emptyMap()); } @@ -481,10 +464,9 @@ protected T handleResponse(OkHttpClient client, Request.Builder requestBuild * @return Returns a de-serialized object as api server response of provided type. * @throws ExecutionException Execution Exception * @throws InterruptedException Interrupted Exception - * @throws KubernetesClientException KubernetesClientException * @throws IOException IOException */ - protected T handleResponse(OkHttpClient client, Request.Builder requestBuilder, Class type, Map parameters) throws ExecutionException, InterruptedException, KubernetesClientException, IOException { + protected T handleResponse(OkHttpClient client, Request.Builder requestBuilder, Class type, Map parameters) throws ExecutionException, InterruptedException, IOException { VersionUsageUtils.log(this.resourceT, this.apiGroupVersion); Request request = requestBuilder.build(); Response response = client.newCall(request).execute(); @@ -514,7 +496,6 @@ protected T handleResponse(OkHttpClient client, Request.Builder requestBuild * * @param request The {#link Request} object. * @param response The {@link Response} object. - * @throws KubernetesClientException When the response code is not the expected. */ protected void assertResponseCode(Request request, Response response) { int statusCode = response.code(); @@ -598,15 +579,15 @@ public static KubernetesClientException requestException(Request request, Except return new KubernetesClientException(sb.toString(), e); } - protected static T unmarshal(InputStream is) throws KubernetesClientException { + protected static T unmarshal(InputStream is) { return Serialization.unmarshal(is); } - protected static T unmarshal(InputStream is, final Class type) throws KubernetesClientException { + protected static T unmarshal(InputStream is, final Class type) { return Serialization.unmarshal(is, type); } - protected static T unmarshal(InputStream is, TypeReference type) throws KubernetesClientException { + protected static T unmarshal(InputStream is, TypeReference type) { return Serialization.unmarshal(is, type); } diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/RawCustomResourceOperationsImpl.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/RawCustomResourceOperationsImpl.java index 23d3c894d92..4577527186b 100644 --- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/RawCustomResourceOperationsImpl.java +++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/RawCustomResourceOperationsImpl.java @@ -112,10 +112,9 @@ public Map create(String objectAsString) throws IOException { * * @param object object a HashMap * @return Object as HashMap - * @throws KubernetesClientException in case of error from Kubernetes API * @throws IOException in case of problems while reading HashMap */ - public Map create(Map object) throws KubernetesClientException, IOException { + public Map create(Map object) throws IOException { return validateAndSubmitRequest(null, null, objectMapper.writeValueAsString(object), HttpCallMethod.POST); } @@ -125,10 +124,9 @@ public Map create(Map object) throws KubernetesC * @param namespace namespace in which we want object to be created. * @param objectAsString Object as JSON string * @return Object as HashMap - * @throws KubernetesClientException in case of error from Kubernetes API * @throws IOException in case of problems while reading JSON object */ - public Map create(String namespace, String objectAsString) throws KubernetesClientException, IOException { + public Map create(String namespace, String objectAsString) throws IOException { return validateAndSubmitRequest(namespace, null, objectAsString, HttpCallMethod.POST); } @@ -137,10 +135,9 @@ public Map create(String namespace, String objectAsString) throw * * @param objectAsStream object as a file input stream * @return Object as HashMap - * @throws KubernetesClientException in case of error from Kubernetes API * @throws IOException in case of problems while reading file */ - public Map create(InputStream objectAsStream) throws KubernetesClientException, IOException { + public Map create(InputStream objectAsStream) throws IOException { return validateAndSubmitRequest(null, null, IOHelpers.readFully(objectAsStream), HttpCallMethod.POST); } @@ -150,10 +147,9 @@ public Map create(InputStream objectAsStream) throws KubernetesC * @param namespace namespace in which we want object to be created * @param objectAsStream object as file input stream * @return Object as HashMap - * @throws KubernetesClientException in case of error from Kubernetes API * @throws IOException in case of problems while reading file */ - public Map create(String namespace, InputStream objectAsStream) throws KubernetesClientException, IOException { + public Map create(String namespace, InputStream objectAsStream) throws IOException { return validateAndSubmitRequest(namespace, null, IOHelpers.readFully(objectAsStream), HttpCallMethod.POST); } @@ -163,10 +159,9 @@ public Map create(String namespace, InputStream objectAsStream) * @param namespace namespace in which we want object to be created. * @param object object as a HashMap * @return Object as HashMap - * @throws KubernetesClientException in case of error from Kubernetes API * @throws IOException in case of problems faced while serializing HashMap */ - public Map create(String namespace, Map object) throws KubernetesClientException, IOException { + public Map create(String namespace, Map object) throws IOException { return validateAndSubmitRequest(namespace, null, objectMapper.writeValueAsString(object), HttpCallMethod.POST); } @@ -302,7 +297,7 @@ public Map edit(String namespace, String name, String objectAsSt * @return Object as HashMap * @throws IOException in case of network/serialization failures or failures from Kubernetes API */ - public Map edit(String name, InputStream objectAsStream) throws IOException, KubernetesClientException { + public Map edit(String name, InputStream objectAsStream) throws IOException { return validateAndSubmitRequest(null, name, IOHelpers.readFully(objectAsStream), HttpCallMethod.PUT); } @@ -315,7 +310,7 @@ public Map edit(String name, InputStream objectAsStream) throws * @return Object as HashMap * @throws IOException in case of network/serialization failures or failures from Kubernetes API */ - public Map edit(String namespace, String name, InputStream objectAsStream) throws IOException, KubernetesClientException { + public Map edit(String namespace, String name, InputStream objectAsStream) throws IOException { return validateAndSubmitRequest(namespace, name, IOHelpers.readFully(objectAsStream), HttpCallMethod.PUT); } @@ -327,9 +322,8 @@ public Map edit(String namespace, String name, InputStream objec * @param objectAsMap custom resource as a HashMap * @return updated CustomResource as HashMap * @throws IOException in case any failure to parse Map - * @throws KubernetesClientException in case any failure from Kubernetes APIs */ - public Map updateStatus(String name, Map objectAsMap) throws IOException, KubernetesClientException { + public Map updateStatus(String name, Map objectAsMap) throws IOException { return validateAndSubmitRequest(fetchUrl(null, name, null) + "/status", objectMapper.writeValueAsString(objectAsMap), HttpCallMethod.PUT); } @@ -341,9 +335,8 @@ public Map updateStatus(String name, Map objectA * @param objectAsJsonString CustomResource as a JSON string * @return updated CustomResource as a HashMap * @throws IOException in case any failure to parse Map - * @throws KubernetesClientException in case any failure from Kubernetes APIs */ - public Map updateStatus(String name, String objectAsJsonString) throws IOException, KubernetesClientException { + public Map updateStatus(String name, String objectAsJsonString) throws IOException { return validateAndSubmitRequest(fetchUrl(null, name, null) + "/status", objectAsJsonString, HttpCallMethod.PUT); } @@ -356,9 +349,8 @@ public Map updateStatus(String name, String objectAsJsonString) * @param objectAsMap CustomResource as a HashMap * @return updated CustomResource as a HashMap * @throws IOException in case any failure to parse Map - * @throws KubernetesClientException in case any failure from Kubernetes APIs */ - public Map updateStatus(String namespace, String name, Map objectAsMap) throws IOException, KubernetesClientException { + public Map updateStatus(String namespace, String name, Map objectAsMap) throws IOException { return validateAndSubmitRequest(fetchUrl(namespace, name, null) + "/status", objectMapper.writeValueAsString(objectAsMap), HttpCallMethod.PUT); } @@ -370,9 +362,8 @@ public Map updateStatus(String namespace, String name, Map updateStatus(String name, InputStream objectAsStream) throws IOException, KubernetesClientException { + public Map updateStatus(String name, InputStream objectAsStream) throws IOException { return validateAndSubmitRequest(fetchUrl(null, name, null) + "/status", IOHelpers.readFully(objectAsStream), HttpCallMethod.PUT); } @@ -385,9 +376,8 @@ public Map updateStatus(String name, InputStream objectAsStream) * @param objectAsStream CustomResource object as a stream * @return updated CustomResource as a HashMap * @throws IOException in case any failure to parse Map - * @throws KubernetesClientException in case any failure from Kubernetes APIs */ - public Map updateStatus(String namespace, String name, InputStream objectAsStream) throws IOException, KubernetesClientException { + public Map updateStatus(String namespace, String name, InputStream objectAsStream) throws IOException { return validateAndSubmitRequest(fetchUrl(namespace, name, null) + "/status", IOHelpers.readFully(objectAsStream), HttpCallMethod.PUT); } @@ -400,9 +390,8 @@ public Map updateStatus(String namespace, String name, InputStre * @param objectAsJsonString CustomResource object as a JSON string * @return updated CustomResource as a HashMap * @throws IOException in case any failure to parse Map - * @throws KubernetesClientException in case any failure from Kubernetes APIs */ - public Map updateStatus(String namespace, String name, String objectAsJsonString) throws IOException, KubernetesClientException { + public Map updateStatus(String namespace, String name, String objectAsJsonString) throws IOException { return validateAndSubmitRequest(fetchUrl(namespace, name, null) + "/status", objectAsJsonString, HttpCallMethod.PUT); } diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/informers/SharedInformerFactory.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/informers/SharedInformerFactory.java index 714a5149c6e..029f5bac2b8 100644 --- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/informers/SharedInformerFactory.java +++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/informers/SharedInformerFactory.java @@ -19,7 +19,6 @@ import io.fabric8.kubernetes.api.model.KubernetesResourceList; import io.fabric8.kubernetes.api.model.ListOptions; import io.fabric8.kubernetes.client.Config; -import io.fabric8.kubernetes.client.KubernetesClientException; import io.fabric8.kubernetes.client.Watch; import io.fabric8.kubernetes.client.Watcher; import io.fabric8.kubernetes.client.dsl.base.BaseOperation; @@ -153,7 +152,7 @@ private > ListerWatch return new ListerWatcher() { @Override - public L list(ListOptions params, String namespace, OperationContext context) throws KubernetesClientException { + public L list(ListOptions params, String namespace, OperationContext context) { BaseOperation listBaseOperation = baseOperation.newInstance(context.withNamespace(namespace)); listBaseOperation.setType(apiTypeClass); listBaseOperation.setListType(apiListTypeClass); @@ -162,7 +161,7 @@ public L list(ListOptions params, String namespace, OperationContext context) th } @Override - public Watch watch(ListOptions params, String namespace, OperationContext context, Watcher resourceWatcher) throws KubernetesClientException { + public Watch watch(ListOptions params, String namespace, OperationContext context, Watcher resourceWatcher) { BaseOperation watchBaseOperation = baseOperation.newInstance(context); watchBaseOperation.setType(apiTypeClass); watchBaseOperation.setListType(apiListTypeClass); diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/Serialization.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/Serialization.java index 45c773b3eb6..a965520dbb6 100644 --- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/Serialization.java +++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/Serialization.java @@ -79,7 +79,6 @@ public static String asYaml(T object) { * @param The target type. * * @return returns de-serialized object - * @throws KubernetesClientException KubernetesClientException */ public static T unmarshal(InputStream is) { return unmarshal(is, JSON_MAPPER); @@ -91,7 +90,6 @@ public static T unmarshal(InputStream is) { * @param parameters A {@link Map} with parameters for placeholder substitution. * @param The target type. * @return returns returns de-serialized object - * @throws KubernetesClientException KubernetesClientException */ @SuppressWarnings("unchecked") public static T unmarshal(InputStream is, Map parameters) { @@ -161,7 +159,6 @@ public static T unmarshal(String str, final Class type) { * @param parameters A hashmap containing parameters * * @return returns de-serialized object - * @throws KubernetesClientException KubernetesClientException */ public static T unmarshal(String str, final Class type, Map parameters) { try (InputStream is = new ByteArrayInputStream(str.getBytes(StandardCharsets.UTF_8))) { @@ -194,7 +191,6 @@ public static T unmarshal(InputStream is, final Class type) { * @param parameters A {@link Map} with parameters for placeholder substitution. * @param Template argument denoting type * @return returns de-serialized object - * @throws KubernetesClientException KubernetesClientException */ public static T unmarshal(InputStream is, final Class type, Map parameters) { return unmarshal(is, new TypeReference() { @@ -226,7 +222,6 @@ public static T unmarshal(InputStream is, TypeReference type) { * @param Template argument denoting type * * @return returns de-serialized object - * @throws KubernetesClientException KubernetesClientException */ public static T unmarshal(InputStream is, TypeReference type, Map parameters) { try ( diff --git a/openshift-client/src/main/java/io/fabric8/openshift/client/DefaultOpenShiftClient.java b/openshift-client/src/main/java/io/fabric8/openshift/client/DefaultOpenShiftClient.java index 6f6e8d2a238..75bde3ce79e 100644 --- a/openshift-client/src/main/java/io/fabric8/openshift/client/DefaultOpenShiftClient.java +++ b/openshift-client/src/main/java/io/fabric8/openshift/client/DefaultOpenShiftClient.java @@ -184,19 +184,19 @@ public class DefaultOpenShiftClient extends BaseClient implements NamespacedOpen private URL openShiftUrl; private NamespacedKubernetesClient delegate; - public DefaultOpenShiftClient() throws KubernetesClientException { + public DefaultOpenShiftClient() { this(new OpenShiftConfigBuilder().build()); } - public DefaultOpenShiftClient(String masterUrl) throws KubernetesClientException { + public DefaultOpenShiftClient(String masterUrl) { this(new OpenShiftConfigBuilder().withMasterUrl(masterUrl).build()); } - public DefaultOpenShiftClient(final Config config) throws KubernetesClientException { + public DefaultOpenShiftClient(final Config config) { this(new OpenShiftConfig(config)); } - public DefaultOpenShiftClient(final OpenShiftConfig config) throws KubernetesClientException { + public DefaultOpenShiftClient(final OpenShiftConfig config) { super(configWithApiGroupsEnabled(clientWithOpenShiftOAuthInterceptor(config), config)); try { this.httpClient = clientWithOpenShiftOAuthInterceptor(this.httpClient, config); @@ -207,7 +207,7 @@ public DefaultOpenShiftClient(final OpenShiftConfig config) throws KubernetesCli } } - public DefaultOpenShiftClient(OkHttpClient httpClient, OpenShiftConfig config) throws KubernetesClientException { + public DefaultOpenShiftClient(OkHttpClient httpClient, OpenShiftConfig config) { super(httpClient, configWithApiGroupsEnabled(httpClient, config)); try { this.httpClient = clientWithOpenShiftOAuthInterceptor(httpClient, getConfiguration());