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

"Refactoring multi-catch blocks, and the InterruptedExceptions, ExecutionException, IOException in the BaseOperation.java" #2429

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
63 changes: 43 additions & 20 deletions kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/BaseOperation.java 100644 → 100755
Expand Up @@ -170,10 +170,15 @@ private L listRequestHelper(URL url) {
L answer = handleResponse(requestBuilder, listType);
updateApiVersion(answer);
return answer;
} catch (InterruptedException | ExecutionException | IOException e) {
} catch (InterruptedException ie) {
Thread.currentThread().interrupt();
throw KubernetesClientException.launderThrowable(forOperationType("list"), ie);
} catch (ExecutionException | IOException e) {
throw KubernetesClientException.launderThrowable(forOperationType("list"), e);
}
}


}

protected URL fetchListUrl(URL url, ListOptions listOptions) throws MalformedURLException {
return new URL(HttpClientUtils.appendListOptionParams(HttpUrl.get(url.toString()).newBuilder(), listOptions).toString());
Expand Down Expand Up @@ -235,19 +240,13 @@ public T getMandatory() {
try {
URL requestUrl = getCompleteResourceUrl();
return handleGet(requestUrl);
} catch (KubernetesClientException e) {
throw KubernetesClientException.launderThrowable(forOperationType("get"), e);
//if (e.getCode() != HttpURLConnection.HTTP_NOT_FOUND) {
// throw e;
//} else {
// String resourceType = type != null ? type.getSimpleName() : "Resource";
// String msg = resourceType + " with name: [" + getName() + "] not found in namespace: [" + (Utils.isNotNullOrEmpty(getNamespace()) ? getName() : getConfig().getNamespace()) + "]";
// throw new KubernetesClientException(msg, HttpURLConnection.HTTP_NOT_FOUND, new StatusBuilder().withCode(HttpURLConnection.HTTP_NOT_FOUND).withMessage(msg).build());
// }
} catch (InterruptedException | ExecutionException | IOException e) {
} catch (InterruptedException ie) {
Thread.currentThread().interrupt();
throw KubernetesClientException.launderThrowable(forOperationType("get"), ie);
} catch (ExecutionException | IOException e) {
throw KubernetesClientException.launderThrowable(forOperationType("get"), e);
}
}
}

public RootPaths getRootPaths() {
try {
Expand All @@ -259,10 +258,13 @@ public RootPaths getRootPaths() {
throw e;
}
return null;
} catch (InterruptedException | ExecutionException | IOException e) {
} catch (InterruptedException ie) {
Thread.currentThread().interrupt();
throw KubernetesClientException.launderThrowable(ie);
} catch (ExecutionException | IOException e) {
throw KubernetesClientException.launderThrowable(e);
}
}
}

@Override
public D edit() throws KubernetesClientException {
Expand Down Expand Up @@ -344,9 +346,13 @@ public T create(T... resources) throws KubernetesClientException {
} else {
return handleCreate(getItem());
}
} catch (InterruptedException | ExecutionException | IOException e) {
} catch (InterruptedException ie) {
Thread.currentThread().interrupt();
throw KubernetesClientException.launderThrowable(forOperationType("create"), ie);
} catch (ExecutionException | IOException e) {
throw KubernetesClientException.launderThrowable(forOperationType("create"), e);
}

}

@Override
Expand All @@ -357,9 +363,13 @@ public T create(T resource) {
} else {
throw new IllegalArgumentException("Nothing to create.");
}
} catch (InterruptedException | ExecutionException | IOException e) {
} catch (InterruptedException ie) {
Thread.currentThread().interrupt();
throw KubernetesClientException.launderThrowable(forOperationType("create"), ie);
} catch (ExecutionException | IOException e) {
throw KubernetesClientException.launderThrowable(forOperationType("create"), e);
}

}

@Override
Expand Down Expand Up @@ -744,9 +754,13 @@ public Boolean delete(List<T> items) {
public T updateStatus(T item) {
try {
return handleStatusUpdate(item, getType());
} catch (InterruptedException | ExecutionException | IOException e) {
} catch (InterruptedException ie) {
Thread.currentThread().interrupt();
throw KubernetesClientException.launderThrowable(forOperationType("statusUpdate"), ie);
} catch (ExecutionException | IOException e) {
throw KubernetesClientException.launderThrowable(forOperationType("statusUpdate"), e);
}

}

public BaseOperation<T, L, D, R> withItem(T item) {
Expand Down Expand Up @@ -896,17 +910,25 @@ protected T sendPatchedObject(T oldObject, T updatedObject) {
protected Scale handleScale(Scale scaleParam) {
try {
return handleScale(getCompleteResourceUrl().toString(), scaleParam);
} catch (InterruptedException | ExecutionException | IOException e) {
} catch (InterruptedException ie) {
Thread.currentThread().interrupt();
throw KubernetesClientException.launderThrowable(forOperationType("scale"), ie);
} catch (ExecutionException | IOException e) {
throw KubernetesClientException.launderThrowable(forOperationType("scale"), e);
}

}

protected Status handleDeploymentRollback(DeploymentRollback deploymentRollback) {
try {
return handleDeploymentRollback(getCompleteResourceUrl().toString(), deploymentRollback);
} catch (InterruptedException | ExecutionException | IOException e) {
} catch (InterruptedException ie) {
Thread.currentThread().interrupt();
throw KubernetesClientException.launderThrowable(forOperationType("rollback"), ie);
} catch (ExecutionException | IOException e) {
throw KubernetesClientException.launderThrowable(forOperationType("rollback"), e);
}

}

protected T handleGet(URL resourceUrl) throws InterruptedException, ExecutionException, IOException {
Expand Down Expand Up @@ -1167,3 +1189,4 @@ public void setNamespace(String namespace) {
this.namespace = namespace;
}
}