Skip to content

Commit

Permalink
Refactoring multi-catch blocks, and the InterruptedExceptions, Execut…
Browse files Browse the repository at this point in the history
…ionException, IOException in the BaseOperation.java
  • Loading branch information
Shivkumar13 committed Aug 24, 2020
1 parent d1dabf6 commit ed84e03
Showing 1 changed file with 73 additions and 11 deletions.
84 changes: 73 additions & 11 deletions kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/BaseOperation.java
100644 → 100755
Expand Up @@ -166,10 +166,19 @@ 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);
}
}


// catch (InterruptedException | 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 @@ -240,10 +249,18 @@ public T getMandatory() {
// 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);
}
}
}

//catch (InterruptedException | ExecutionException | IOException e) {
//throw KubernetesClientException.launderThrowable(forOperationType("get"), e);
//}


public RootPaths getRootPaths() {
try {
Expand All @@ -255,10 +272,18 @@ 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);
}
}


// catch (InterruptedException | ExecutionException | IOException e) {
//throw KubernetesClientException.launderThrowable(e);
//}
}

@Override
public D edit() throws KubernetesClientException {
Expand Down Expand Up @@ -340,9 +365,16 @@ 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);
}

// catch (InterruptedException | ExecutionException | IOException e) {
// throw KubernetesClientException.launderThrowable(forOperationType("create"), e);
// }
}

@Override
Expand All @@ -353,9 +385,16 @@ 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);
}

// catch (InterruptedException | ExecutionException | IOException e) {
// throw KubernetesClientException.launderThrowable(forOperationType("create"), e);
// }
}

@Override
Expand Down Expand Up @@ -721,9 +760,17 @@ 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);
}


// catch (InterruptedException | ExecutionException | IOException e) {
// throw KubernetesClientException.launderThrowable(forOperationType("statusUpdate"), e);
// }
}

public BaseOperation<T,L,D,R> withItem(T item) {
Expand Down Expand Up @@ -873,17 +920,31 @@ 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);
}

// catch (InterruptedException | 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);
}

// catch (InterruptedException | ExecutionException | IOException e) {
// throw KubernetesClientException.launderThrowable(forOperationType("rollback"), e);
// }
}

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

0 comments on commit ed84e03

Please sign in to comment.