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

Remove checked exceptions from most external APIs #1969

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions src/main/java/org/kohsuke/github/AbstractBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ protected AbstractBuilder(@Nonnull Class<R> finalReturnType,
@Override
@Nonnull
@BetaApi
public R done() throws IOException {
public R done() {
R result;
if (updateInPlace && baseInstance != null) {
result = requester.fetchInto(baseInstance);
Expand Down Expand Up @@ -129,7 +129,7 @@ public R done() throws IOException {
*/
@Nonnull
@BetaApi
protected S with(@Nonnull String name, Object value) throws IOException {
protected S with(@Nonnull String name, Object value) {
requester.with(name, value);
return continueOrDone();
}
Expand All @@ -149,7 +149,7 @@ protected S with(@Nonnull String name, Object value) throws IOException {
*/
@Nonnull
@BetaApi
protected S continueOrDone() throws IOException {
protected S continueOrDone() {
// This little bit of roughness in this base class means all inheriting builders get to create Updater and
// Setter classes from almost identical code. Creator can often be implemented with significant code reuse as
// well.
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/kohsuke/github/GHApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public PagedIterable<GHAppInstallation> listInstallations(final Date since) {
* on error
* @see <a href="https://developer.github.com/v3/apps/#get-an-installation">Get an installation</a>
*/
public GHAppInstallation getInstallationById(long id) throws IOException {
public GHAppInstallation getInstallationById(long id) {
return root().createRequest()
.withUrlPath(String.format("/app/installations/%d", id))
.fetch(GHAppInstallation.class);
Expand All @@ -181,7 +181,7 @@ public GHAppInstallation getInstallationById(long id) throws IOException {
* @see <a href="https://developer.github.com/v3/apps/#get-an-organization-installation">Get an organization
* installation</a>
*/
public GHAppInstallation getInstallationByOrganization(String name) throws IOException {
public GHAppInstallation getInstallationByOrganization(String name) {
return root().createRequest()
.withUrlPath(String.format("/orgs/%s/installation", name))
.fetch(GHAppInstallation.class);
Expand All @@ -202,7 +202,7 @@ public GHAppInstallation getInstallationByOrganization(String name) throws IOExc
* @see <a href="https://developer.github.com/v3/apps/#get-a-repository-installation">Get a repository
* installation</a>
*/
public GHAppInstallation getInstallationByRepository(String ownerName, String repositoryName) throws IOException {
public GHAppInstallation getInstallationByRepository(String ownerName, String repositoryName) {
return root().createRequest()
.withUrlPath(String.format("/repos/%s/%s/installation", ownerName, repositoryName))
.fetch(GHAppInstallation.class);
Expand All @@ -220,7 +220,7 @@ public GHAppInstallation getInstallationByRepository(String ownerName, String re
* on error
* @see <a href="https://developer.github.com/v3/apps/#get-a-user-installation">Get a user installation</a>
*/
public GHAppInstallation getInstallationByUser(String name) throws IOException {
public GHAppInstallation getInstallationByUser(String name) {
return root().createRequest()
.withUrlPath(String.format("/users/%s/installation", name))
.fetch(GHAppInstallation.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public GHAppCreateTokenBuilder permissions(Map<String, GHPermissionType> permiss
* @throws IOException
* on error
*/
public GHAppInstallationToken create() throws IOException {
public GHAppInstallationToken create() {
return builder.method("POST").withUrlPath(apiUrlTail).fetch(GHAppInstallationToken.class);
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/kohsuke/github/GHAppInstallation.java
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ public GHUser getSuspendedBy() {
* on error
* @see <a href="https://developer.github.com/v3/apps/#delete-an-installation">Delete an installation</a>
*/
public void deleteInstallation() throws IOException {
public void deleteInstallation() {
root().createRequest().method("DELETE").withUrlPath(String.format("/app/installations/%d", getId())).send();
}

Expand Down Expand Up @@ -263,7 +263,7 @@ public GHAppCreateTokenBuilder createToken() {
* "https://docs.github.com/en/rest/apps/marketplace?apiVersion=2022-11-28#get-a-subscription-plan-for-an-account">Get
* a subscription plan for an account</a>
*/
public GHMarketplaceAccountPlan getMarketplaceAccount() throws IOException {
public GHMarketplaceAccountPlan getMarketplaceAccount() {
return new GHMarketplacePlanForAccountBuilder(root(), account.getId()).createRequest();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public GHRepositorySelection getRepositorySelection() {
* @throws IOException
* on error
*/
public Date getExpiresAt() throws IOException {
public Date getExpiresAt() {
return GitHubClient.parseDate(expires_at);
}
}
4 changes: 2 additions & 2 deletions src/main/java/org/kohsuke/github/GHArtifact.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public GHRepository getRepository() {
* @throws IOException
* the io exception
*/
public void delete() throws IOException {
public void delete() {
root().createRequest().method("DELETE").withUrlPath(getApiRoute()).send();
}

Expand All @@ -112,7 +112,7 @@ public void delete() throws IOException {
* @throws IOException
* The IO exception.
*/
public <T> T download(InputStreamFunction<T> streamFunction) throws IOException {
public <T> T download(InputStreamFunction<T> streamFunction) {
requireNonNull(streamFunction, "Stream function must not be null");

return root().createRequest().method("GET").withUrlPath(getApiRoute(), "zip").fetchStream(streamFunction);
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/kohsuke/github/GHAsset.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public String getContentType() {
* @throws IOException
* the io exception
*/
public void setContentType(String contentType) throws IOException {
public void setContentType(String contentType) {
edit("content_type", contentType);
this.content_type = contentType;
}
Expand Down Expand Up @@ -76,7 +76,7 @@ public String getLabel() {
* @throws IOException
* the io exception
*/
public void setLabel(String label) throws IOException {
public void setLabel(String label) {
edit("label", label);
this.label = label;
}
Expand Down Expand Up @@ -127,7 +127,7 @@ public String getBrowserDownloadUrl() {
return browser_download_url;
}

private void edit(String key, Object value) throws IOException {
private void edit(String key, Object value) {
root().createRequest().with(key, value).method("PATCH").withUrlPath(getApiRoute()).send();
}

Expand All @@ -137,7 +137,7 @@ private void edit(String key, Object value) throws IOException {
* @throws IOException
* the io exception
*/
public void delete() throws IOException {
public void delete() {
root().createRequest().method("DELETE").withUrlPath(getApiRoute()).send();
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/kohsuke/github/GHBlobBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ private String getApiTail() {
* @throws IOException
* if the blob cannot be created.
*/
public GHBlob create() throws IOException {
public GHBlob create() {
return req.method("POST").withUrlPath(getApiTail()).fetch(GHBlob.class);
}
}
10 changes: 5 additions & 5 deletions src/main/java/org/kohsuke/github/GHBranch.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class GHBranch extends GitHubInteractiveObject {
* the exception
*/
@JsonCreator
GHBranch(@JsonProperty(value = "name", required = true) String name) throws Exception {
GHBranch(@JsonProperty(value = "name", required = true) String name) {
Objects.requireNonNull(name);
this.name = name;
}
Expand Down Expand Up @@ -106,7 +106,7 @@ public URL getProtectionUrl() {
* @throws IOException
* the io exception
*/
public GHBranchProtection getProtection() throws IOException {
public GHBranchProtection getProtection() {
return root().createRequest().setRawUrlPath(protection_url).fetch(GHBranchProtection.class);
}

Expand All @@ -125,7 +125,7 @@ public String getSHA1() {
* @throws IOException
* if disabling protection fails
*/
public void disableProtection() throws IOException {
public void disableProtection() {
root().createRequest().method("DELETE").setRawUrlPath(protection_url).send();
}

Expand Down Expand Up @@ -155,7 +155,7 @@ public GHBranchProtectionBuilder enableProtection() {
* if merging fails
*/
@CheckForNull
public GHCommit merge(GHBranch headBranch, String commitMessage) throws IOException {
public GHCommit merge(GHBranch headBranch, String commitMessage) {
return merge(headBranch.getName(), commitMessage);
}

Expand All @@ -176,7 +176,7 @@ public GHCommit merge(GHBranch headBranch, String commitMessage) throws IOExcept
* if merging fails
*/
@CheckForNull
public GHCommit merge(String head, String commitMessage) throws IOException {
public GHCommit merge(String head, String commitMessage) {
GHCommit result = root().createRequest()
.withUrlPath(owner.getApiTailUrl("merges"))
.method("POST")
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/kohsuke/github/GHBranchProtection.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public GHBranchProtection() {
* @throws IOException
* the io exception
*/
public void enabledSignedCommits() throws IOException {
public void enabledSignedCommits() {
requester().method("POST").withUrlPath(url + REQUIRE_SIGNATURES_URI).fetch(RequiredSignatures.class);
}

Expand All @@ -80,7 +80,7 @@ public void enabledSignedCommits() throws IOException {
* @throws IOException
* the io exception
*/
public void disableSignedCommits() throws IOException {
public void disableSignedCommits() {
requester().method("DELETE").withUrlPath(url + REQUIRE_SIGNATURES_URI).send();
}

Expand Down Expand Up @@ -172,7 +172,7 @@ public RequiredReviews getRequiredReviews() {
* @throws IOException
* the io exception
*/
public boolean getRequiredSignatures() throws IOException {
public boolean getRequiredSignatures() {
return requester().withUrlPath(url + REQUIRE_SIGNATURES_URI).fetch(RequiredSignatures.class).enabled;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public GHBranchProtectionBuilder dismissStaleReviews(boolean v) {
* @throws IOException
* the io exception
*/
public GHBranchProtection enable() throws IOException {
public GHBranchProtection enable() {
return requester().method("PUT")
.with(fields)
.withNullable("required_status_checks", statusChecks)
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/kohsuke/github/GHCheckRun.java
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,10 @@ public String getHeadSha() {
* @throws IOException
* the io exception
*/
public List<GHPullRequest> getPullRequests() throws IOException {
public List<GHPullRequest> getPullRequests() {
for (GHPullRequest singlePull : pullRequests) {
// Only refresh if we haven't do so before
singlePull.refresh(singlePull.getTitle());
singlePull.refreshWithUnchecked(singlePull.getTitle());
}
return Collections.unmodifiableList(Arrays.asList(pullRequests));
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/kohsuke/github/GHCheckRunBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ private GHCheckRunBuilder(GHRepository repo, Requester requester) {
* @throws IOException
* for the usual reasons
*/
public @NonNull GHCheckRun create() throws IOException {
public @NonNull GHCheckRun create() {
List<Annotation> extraAnnotations;
if (output != null && output.annotations != null && output.annotations.size() > MAX_ANNOTATIONS) {
extraAnnotations = output.annotations.subList(MAX_ANNOTATIONS, output.annotations.size());
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/kohsuke/github/GHCheckSuite.java
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,11 @@ public GHApp getApp() {
* @throws IOException
* the io exception
*/
public List<GHPullRequest> getPullRequests() throws IOException {
public List<GHPullRequest> getPullRequests() {
if (pullRequests != null && pullRequests.length != 0) {
for (GHPullRequest singlePull : pullRequests) {
// Only refresh if we haven't do so before
singlePull.refresh(singlePull.getTitle());
singlePull.refreshWithUnchecked(singlePull.getTitle());
}
return Collections.unmodifiableList(Arrays.asList(pullRequests));
}
Expand Down
Loading
Loading