From 733311fa1c3a96aa9de498bcf3e1de0fcb76a5dc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 20 Jun 2024 03:12:06 +0000 Subject: [PATCH 1/3] Chore(deps): Bump spotbugs.version from 4.7.3 to 4.8.6 Bumps `spotbugs.version` from 4.7.3 to 4.8.6. Updates `com.github.spotbugs:spotbugs` from 4.7.3 to 4.8.6 - [Release notes](https://github.com/spotbugs/spotbugs/releases) - [Changelog](https://github.com/spotbugs/spotbugs/blob/master/CHANGELOG.md) - [Commits](https://github.com/spotbugs/spotbugs/compare/4.7.3...4.8.6) Updates `com.github.spotbugs:spotbugs-annotations` from 4.7.3 to 4.8.6 - [Release notes](https://github.com/spotbugs/spotbugs/releases) - [Changelog](https://github.com/spotbugs/spotbugs/blob/master/CHANGELOG.md) - [Commits](https://github.com/spotbugs/spotbugs/compare/4.7.3...4.8.6) --- updated-dependencies: - dependency-name: com.github.spotbugs:spotbugs dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: com.github.spotbugs:spotbugs-annotations dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0c7bf49c76..65629d1914 100644 --- a/pom.xml +++ b/pom.xml @@ -34,7 +34,7 @@ UTF-8 4.8.1.0 - 4.7.3 + 4.8.6 true 2.2 4.9.2 From 702abb43efdcbeab58d3c07574e541d38acd347a Mon Sep 17 00:00:00 2001 From: Liam Newman Date: Thu, 20 Jun 2024 01:04:10 -0700 Subject: [PATCH 2/3] Clean up --- pom.xml | 2 +- src/main/java/org/kohsuke/github/AbstractBuilder.java | 3 +++ src/main/java/org/kohsuke/github/GHArtifactsPage.java | 4 ++++ src/main/java/org/kohsuke/github/GHCheckRunsPage.java | 4 ++++ .../java/org/kohsuke/github/GHCommitSearchBuilder.java | 4 ++++ .../java/org/kohsuke/github/GHIssueSearchBuilder.java | 5 +++++ src/main/java/org/kohsuke/github/GHMembership.java | 2 ++ .../org/kohsuke/github/GHRepositorySearchBuilder.java | 5 +++++ src/main/java/org/kohsuke/github/GHTree.java | 4 ++++ src/main/java/org/kohsuke/github/GHWorkflowJobsPage.java | 4 ++++ src/main/java/org/kohsuke/github/GHWorkflowRunsPage.java | 4 ++++ src/main/java/org/kohsuke/github/GHWorkflowsPage.java | 4 ++++ src/main/java/org/kohsuke/github/GitHub.java | 1 + src/main/java/org/kohsuke/github/GitHubPageIterator.java | 8 ++++---- src/main/java/org/kohsuke/github/GitHubRequest.java | 1 + src/main/java/org/kohsuke/github/RateLimitChecker.java | 3 ++- src/main/java/org/kohsuke/github/SearchResult.java | 4 ---- .../kohsuke/github/extras/HttpClientGitHubConnector.java | 1 - .../java/org/kohsuke/github/extras/OkHttpConnector.java | 2 ++ .../github/extras/authorization/JWTTokenProvider.java | 2 ++ .../github/extras/authorization/JwtBuilderUtil.java | 4 ++-- 21 files changed, 58 insertions(+), 13 deletions(-) diff --git a/pom.xml b/pom.xml index 65629d1914..805a3c690c 100644 --- a/pom.xml +++ b/pom.xml @@ -33,7 +33,7 @@ UTF-8 - 4.8.1.0 + 4.8.5.0 4.8.6 true 2.2 diff --git a/src/main/java/org/kohsuke/github/AbstractBuilder.java b/src/main/java/org/kohsuke/github/AbstractBuilder.java index 3f368322ed..189d3f7a57 100644 --- a/src/main/java/org/kohsuke/github/AbstractBuilder.java +++ b/src/main/java/org/kohsuke/github/AbstractBuilder.java @@ -1,5 +1,7 @@ package org.kohsuke.github; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; + import java.io.IOException; import javax.annotation.CheckForNull; @@ -75,6 +77,7 @@ abstract class AbstractBuilder extends GitHubInteractiveObject { * @param baseInstance * optional instance on which to base this builder. */ + @SuppressFBWarnings(value = { "CT_CONSTRUCTOR_THROW" }, justification = "argument validation, internal class") protected AbstractBuilder(@Nonnull Class finalReturnType, @Nonnull Class intermediateReturnType, @Nonnull GitHub root, diff --git a/src/main/java/org/kohsuke/github/GHArtifactsPage.java b/src/main/java/org/kohsuke/github/GHArtifactsPage.java index 3737343912..4ef5878699 100644 --- a/src/main/java/org/kohsuke/github/GHArtifactsPage.java +++ b/src/main/java/org/kohsuke/github/GHArtifactsPage.java @@ -1,9 +1,13 @@ package org.kohsuke.github; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; + // TODO: Auto-generated Javadoc /** * Represents the one page of artifacts result when listing artifacts. */ +@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD" }, + justification = "JSON API") class GHArtifactsPage { private int total_count; private GHArtifact[] artifacts; diff --git a/src/main/java/org/kohsuke/github/GHCheckRunsPage.java b/src/main/java/org/kohsuke/github/GHCheckRunsPage.java index f9262f2561..2caf0a711f 100644 --- a/src/main/java/org/kohsuke/github/GHCheckRunsPage.java +++ b/src/main/java/org/kohsuke/github/GHCheckRunsPage.java @@ -1,9 +1,13 @@ package org.kohsuke.github; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; + // TODO: Auto-generated Javadoc /** * Represents the one page of check-runs result when listing check-runs. */ +@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD" }, + justification = "JSON API") class GHCheckRunsPage { private int total_count; private GHCheckRun[] check_runs; diff --git a/src/main/java/org/kohsuke/github/GHCommitSearchBuilder.java b/src/main/java/org/kohsuke/github/GHCommitSearchBuilder.java index 7d166bc9b4..8ce7ce7ef9 100644 --- a/src/main/java/org/kohsuke/github/GHCommitSearchBuilder.java +++ b/src/main/java/org/kohsuke/github/GHCommitSearchBuilder.java @@ -1,5 +1,6 @@ package org.kohsuke.github; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import org.apache.commons.lang3.StringUtils; import org.kohsuke.github.internal.Previews; @@ -249,6 +250,9 @@ public enum Sort { COMMITTER_DATE } + @SuppressFBWarnings( + value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD" }, + justification = "JSON API") private static class CommitSearchResult extends SearchResult { private GHCommit[] items; diff --git a/src/main/java/org/kohsuke/github/GHIssueSearchBuilder.java b/src/main/java/org/kohsuke/github/GHIssueSearchBuilder.java index 92deb26ccf..95a266847d 100644 --- a/src/main/java/org/kohsuke/github/GHIssueSearchBuilder.java +++ b/src/main/java/org/kohsuke/github/GHIssueSearchBuilder.java @@ -1,5 +1,7 @@ package org.kohsuke.github; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; + // TODO: Auto-generated Javadoc /** * Search issues. @@ -117,6 +119,9 @@ public enum Sort { UPDATED } + @SuppressFBWarnings( + value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD" }, + justification = "JSON API") private static class IssueSearchResult extends SearchResult { private GHIssue[] items; diff --git a/src/main/java/org/kohsuke/github/GHMembership.java b/src/main/java/org/kohsuke/github/GHMembership.java index e8e012c995..a4cca63f50 100644 --- a/src/main/java/org/kohsuke/github/GHMembership.java +++ b/src/main/java/org/kohsuke/github/GHMembership.java @@ -13,6 +13,8 @@ * @author Kohsuke Kawaguchi * @see GHMyself#listOrgMemberships() GHMyself#listOrgMemberships() */ +@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD" }, + justification = "JSON API") public class GHMembership extends GitHubInteractiveObject { /** The url. */ diff --git a/src/main/java/org/kohsuke/github/GHRepositorySearchBuilder.java b/src/main/java/org/kohsuke/github/GHRepositorySearchBuilder.java index 7a21cf941a..ed770fd995 100644 --- a/src/main/java/org/kohsuke/github/GHRepositorySearchBuilder.java +++ b/src/main/java/org/kohsuke/github/GHRepositorySearchBuilder.java @@ -1,5 +1,7 @@ package org.kohsuke.github; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; + // TODO: Auto-generated Javadoc /** * Search repositories. @@ -328,6 +330,9 @@ public String toString() { } } + @SuppressFBWarnings( + value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD" }, + justification = "JSON API") private static class RepositorySearchResult extends SearchResult { private GHRepository[] items; diff --git a/src/main/java/org/kohsuke/github/GHTree.java b/src/main/java/org/kohsuke/github/GHTree.java index 6a2be8a55e..11f35cee49 100644 --- a/src/main/java/org/kohsuke/github/GHTree.java +++ b/src/main/java/org/kohsuke/github/GHTree.java @@ -1,5 +1,7 @@ package org.kohsuke.github; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; + import java.net.URL; import java.util.Arrays; import java.util.Collections; @@ -14,6 +16,8 @@ * @see GHRepository#getTree(String) GHRepository#getTree(String) * @see GHTreeEntry#asTree() GHTreeEntry#asTree() */ +@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD" }, + justification = "JSON API") public class GHTree { /** The repo. */ diff --git a/src/main/java/org/kohsuke/github/GHWorkflowJobsPage.java b/src/main/java/org/kohsuke/github/GHWorkflowJobsPage.java index f19e30a2fb..91d7013f70 100644 --- a/src/main/java/org/kohsuke/github/GHWorkflowJobsPage.java +++ b/src/main/java/org/kohsuke/github/GHWorkflowJobsPage.java @@ -1,9 +1,13 @@ package org.kohsuke.github; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; + // TODO: Auto-generated Javadoc /** * Represents the one page of jobs result when listing jobs from a workflow run. */ +@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD" }, + justification = "JSON API") class GHWorkflowJobsPage { private int total_count; private GHWorkflowJob[] jobs; diff --git a/src/main/java/org/kohsuke/github/GHWorkflowRunsPage.java b/src/main/java/org/kohsuke/github/GHWorkflowRunsPage.java index ed45f1addc..8df067dead 100644 --- a/src/main/java/org/kohsuke/github/GHWorkflowRunsPage.java +++ b/src/main/java/org/kohsuke/github/GHWorkflowRunsPage.java @@ -1,9 +1,13 @@ package org.kohsuke.github; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; + // TODO: Auto-generated Javadoc /** * Represents the one page of workflow runs result when listing workflow runs. */ +@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD" }, + justification = "JSON API") class GHWorkflowRunsPage { private int totalCount; private GHWorkflowRun[] workflowRuns; diff --git a/src/main/java/org/kohsuke/github/GHWorkflowsPage.java b/src/main/java/org/kohsuke/github/GHWorkflowsPage.java index 8bdff6e710..7786d11fab 100644 --- a/src/main/java/org/kohsuke/github/GHWorkflowsPage.java +++ b/src/main/java/org/kohsuke/github/GHWorkflowsPage.java @@ -1,9 +1,13 @@ package org.kohsuke.github; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; + // TODO: Auto-generated Javadoc /** * Represents the one page of workflow result when listing workflows. */ +@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD" }, + justification = "JSON API") class GHWorkflowsPage { private int total_count; private GHWorkflow[] workflows; diff --git a/src/main/java/org/kohsuke/github/GitHub.java b/src/main/java/org/kohsuke/github/GitHub.java index 8bcd93b85f..d25033af18 100644 --- a/src/main/java/org/kohsuke/github/GitHub.java +++ b/src/main/java/org/kohsuke/github/GitHub.java @@ -117,6 +117,7 @@ public class GitHub { * @throws IOException * Signals that an I/O exception has occurred. */ + @SuppressFBWarnings(value = { "CT_CONSTRUCTOR_THROW" }, justification = "internal constructor") GitHub(String apiUrl, GitHubConnector connector, GitHubRateLimitHandler rateLimitHandler, diff --git a/src/main/java/org/kohsuke/github/GitHubPageIterator.java b/src/main/java/org/kohsuke/github/GitHubPageIterator.java index 36da9cd24b..4f622d05b4 100644 --- a/src/main/java/org/kohsuke/github/GitHubPageIterator.java +++ b/src/main/java/org/kohsuke/github/GitHubPageIterator.java @@ -52,10 +52,6 @@ class GitHubPageIterator implements Iterator { private GitHubResponse finalResponse = null; private GitHubPageIterator(GitHubClient client, Class type, GitHubRequest request) { - if (!"GET".equals(request.method())) { - throw new IllegalStateException("Request method \"GET\" is required for page iterator."); - } - this.client = client; this.type = type; this.nextRequest = request; @@ -83,6 +79,10 @@ static GitHubPageIterator create(GitHubClient client, Class type, GitH request = builder.build(); } + if (!"GET".equals(request.method())) { + throw new IllegalArgumentException("Request method \"GET\" is required for page iterator."); + } + return new GitHubPageIterator<>(client, type, request); } diff --git a/src/main/java/org/kohsuke/github/GitHubRequest.java b/src/main/java/org/kohsuke/github/GitHubRequest.java index 903501bb27..1e9d5851a2 100644 --- a/src/main/java/org/kohsuke/github/GitHubRequest.java +++ b/src/main/java/org/kohsuke/github/GitHubRequest.java @@ -55,6 +55,7 @@ public class GitHubRequest implements GitHubConnectorRequest { private final URL url; + @SuppressFBWarnings(value = { "CT_CONSTRUCTOR_THROW" }, justification = "Basic argument validation") private GitHubRequest(@Nonnull List args, @Nonnull Map> headers, @Nonnull Map injectedMappingValues, diff --git a/src/main/java/org/kohsuke/github/RateLimitChecker.java b/src/main/java/org/kohsuke/github/RateLimitChecker.java index 76bc479ec0..fbfdabd93c 100644 --- a/src/main/java/org/kohsuke/github/RateLimitChecker.java +++ b/src/main/java/org/kohsuke/github/RateLimitChecker.java @@ -103,7 +103,8 @@ public static class LiteralValue extends RateLimitChecker { */ public LiteralValue(int sleepAtOrBelow) { if (sleepAtOrBelow < 0) { - throw new IllegalArgumentException("sleepAtOrBelow must >= 0"); + // ignore negative numbers + sleepAtOrBelow = 0; } this.sleepAtOrBelow = sleepAtOrBelow; } diff --git a/src/main/java/org/kohsuke/github/SearchResult.java b/src/main/java/org/kohsuke/github/SearchResult.java index 62cded1886..ca2f621df7 100644 --- a/src/main/java/org/kohsuke/github/SearchResult.java +++ b/src/main/java/org/kohsuke/github/SearchResult.java @@ -1,7 +1,5 @@ package org.kohsuke.github; -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; - // TODO: Auto-generated Javadoc /** * Represents the result of a search. @@ -13,11 +11,9 @@ abstract class SearchResult { /** The total count. */ - @SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "Field comes from JSON deserialization") int total_count; /** The incomplete results. */ - @SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "Field comes from JSON deserialization") boolean incomplete_results; /** diff --git a/src/main/java/org/kohsuke/github/extras/HttpClientGitHubConnector.java b/src/main/java/org/kohsuke/github/extras/HttpClientGitHubConnector.java index baa4365c8a..29bcf27c65 100644 --- a/src/main/java/org/kohsuke/github/extras/HttpClientGitHubConnector.java +++ b/src/main/java/org/kohsuke/github/extras/HttpClientGitHubConnector.java @@ -17,7 +17,6 @@ public class HttpClientGitHubConnector implements GitHubConnector { * Instantiates a new Impatient http connector. */ public HttpClientGitHubConnector() { - throw new UnsupportedOperationException("java.net.http.HttpClient is only supported in Java 11+."); } @Override diff --git a/src/main/java/org/kohsuke/github/extras/OkHttpConnector.java b/src/main/java/org/kohsuke/github/extras/OkHttpConnector.java index 4b9b5bb36f..27a1731d65 100644 --- a/src/main/java/org/kohsuke/github/extras/OkHttpConnector.java +++ b/src/main/java/org/kohsuke/github/extras/OkHttpConnector.java @@ -4,6 +4,7 @@ import com.squareup.okhttp.ConnectionSpec; import com.squareup.okhttp.OkHttpClient; import com.squareup.okhttp.OkUrlFactory; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import org.kohsuke.github.HttpConnector; import org.kohsuke.github.extras.okhttp3.OkHttpGitHubConnector; @@ -31,6 +32,7 @@ * @see OkHttpGitHubConnector */ @Deprecated +@SuppressFBWarnings(value = { "CT_CONSTRUCTOR_THROW" }, justification = "Deprecated") public class OkHttpConnector implements HttpConnector { private static final String HEADER_NAME = "Cache-Control"; private final OkUrlFactory urlFactory; diff --git a/src/main/java/org/kohsuke/github/extras/authorization/JWTTokenProvider.java b/src/main/java/org/kohsuke/github/extras/authorization/JWTTokenProvider.java index cc3f3c4df5..eae8a8abca 100644 --- a/src/main/java/org/kohsuke/github/extras/authorization/JWTTokenProvider.java +++ b/src/main/java/org/kohsuke/github/extras/authorization/JWTTokenProvider.java @@ -1,5 +1,6 @@ package org.kohsuke.github.extras.authorization; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import org.kohsuke.github.authorization.AuthorizationProvider; import java.io.File; @@ -23,6 +24,7 @@ * authenticate as an application. This token provider does not provide any kind of caching, and will always request a * new token to the API. */ +@SuppressFBWarnings(value = { "CT_CONSTRUCTOR_THROW" }, justification = "TODO") public class JWTTokenProvider implements AuthorizationProvider { private final PrivateKey privateKey; diff --git a/src/main/java/org/kohsuke/github/extras/authorization/JwtBuilderUtil.java b/src/main/java/org/kohsuke/github/extras/authorization/JwtBuilderUtil.java index 754b2f315c..81aa4b1272 100644 --- a/src/main/java/org/kohsuke/github/extras/authorization/JwtBuilderUtil.java +++ b/src/main/java/org/kohsuke/github/extras/authorization/JwtBuilderUtil.java @@ -102,7 +102,7 @@ interface IJwtBuilder { * Without this class, JwtBuilderUtil.buildJwt() immediately throws NoClassDefFoundError when called. With this * class the error is thrown when DefaultBuilder.build() is called allowing us to catch and handle it. */ - private static class DefaultBuilderImpl implements IJwtBuilder { + private static final class DefaultBuilderImpl implements IJwtBuilder { /** * This method builds a JWT using 0.12.x or later versions of jjwt library * @@ -135,7 +135,7 @@ public String buildJwt(Instant issuedAt, Instant expiration, String applicationI /** * A class to encapsulate building a JWT using reflection. */ - private static class ReflectionBuilderImpl implements IJwtBuilder { + private static final class ReflectionBuilderImpl implements IJwtBuilder { private Method setIssuedAtMethod; private Method setExpirationMethod; From 499f0475cd7b88c24b4ef94c12ea8721c460df22 Mon Sep 17 00:00:00 2001 From: Liam Newman Date: Thu, 20 Jun 2024 01:08:15 -0700 Subject: [PATCH 3/3] Retain one constructor exception --- .../org/kohsuke/github/extras/HttpClientGitHubConnector.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/org/kohsuke/github/extras/HttpClientGitHubConnector.java b/src/main/java/org/kohsuke/github/extras/HttpClientGitHubConnector.java index 29bcf27c65..21c943fa58 100644 --- a/src/main/java/org/kohsuke/github/extras/HttpClientGitHubConnector.java +++ b/src/main/java/org/kohsuke/github/extras/HttpClientGitHubConnector.java @@ -1,5 +1,6 @@ package org.kohsuke.github.extras; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import org.kohsuke.github.connector.GitHubConnector; import org.kohsuke.github.connector.GitHubConnectorRequest; import org.kohsuke.github.connector.GitHubConnectorResponse; @@ -11,12 +12,14 @@ * * @author Liam Newman */ +@SuppressFBWarnings(value = { "CT_CONSTRUCTOR_THROW" }, justification = "Basic validation") public class HttpClientGitHubConnector implements GitHubConnector { /** * Instantiates a new Impatient http connector. */ public HttpClientGitHubConnector() { + throw new UnsupportedOperationException("java.net.http.HttpClient is only supported in Java 11+."); } @Override