From da9d777a289d2ec4b6742afec6e0e64b8fe27fd0 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
<41898282+github-actions[bot]@users.noreply.github.com>
Date: Thu, 20 Mar 2025 20:05:48 -0700
Subject: [PATCH 01/36] Prepare release (bitwiseman): github-api-2.0-rc.1
(#2069)
* Prepare release (bitwiseman): github-api-2.0-rc.1
* Prepare for next development iteration
---------
Co-authored-by: bitwiseman <1958953+bitwiseman@users.noreply.github.com>
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index 6297cde6da..d2156847dd 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
4.0.0org.kohsukegithub-api
- 2.0-rc.1-SNAPSHOT
+ 2.0-rc.2-SNAPSHOTGitHub API for JavaGitHub API for Javahttps://hub4j.github.io/github-api/
From 2274f27271b1a470bae996421d580647961c781e Mon Sep 17 00:00:00 2001
From: Liam Newman
Date: Fri, 21 Mar 2025 11:39:59 -0700
Subject: [PATCH 02/36] Move back to old nexus server
---
pom.xml | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/pom.xml b/pom.xml
index d2156847dd..9e42411708 100644
--- a/pom.xml
+++ b/pom.xml
@@ -48,12 +48,12 @@
sonatype-nexus-stagingNexus Release Repository
- https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/
+ ${nexus.serverUrl}/service/local/staging/deploy/maven2/sonatype-nexus-snapshotsSonatype Nexus Snapshots
- https://s01.oss.sonatype.org/content/repositories/snapshots/
+ ${nexus.serverUrl}/content/repositories/snapshots/github-pages
@@ -71,6 +71,8 @@
0.12.6
+
+ https://oss.sonatype.org4.12.03.10.2UTF-8
@@ -443,7 +445,7 @@
truesonatype-nexus-staging
- https://oss.sonatype.org/
+ ${nexus.serverUrl}/true
From 91a8ff334f33240ce4d09f023c30bccf0801a500 Mon Sep 17 00:00:00 2001
From: Liam Newman
Date: Tue, 25 Mar 2025 00:30:54 -0700
Subject: [PATCH 03/36] Update PULL_REQUEST_TEMPLATE.md
Fix build command
---
.github/PULL_REQUEST_TEMPLATE.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
index 0815906c23..2ffe6c4da9 100644
--- a/.github/PULL_REQUEST_TEMPLATE.md
+++ b/.github/PULL_REQUEST_TEMPLATE.md
@@ -8,7 +8,7 @@
- [ ] Add JavaDocs and other comments explaining the behavior.
- [ ] When adding or updating methods that fetch entities, add `@link` JavaDoc entries to the relevant documentation on https://docs.github.com/en/rest .
- [ ] Add tests that cover any added or changed code. This generally requires capturing snapshot test data. See [CONTRIBUTING.md](CONTRIBUTING.md) for details.
-- [ ] Run `mvn -D enable-ci clean install site` locally. If this command doesn't succeed, your change will not pass CI.
+- [ ] Run `mvn -D enable-ci clean install site "-Dsurefire.argLine=--add-opens java.base/java.net=ALL-UNNAMED"` locally. If this command doesn't succeed, your change will not pass CI.
- [ ] Push your changes to a branch other than `main`. You will create your PR from that branch.
# When creating a PR:
From 12255103c3e80b0baf7fdb9e45418560fb750b15 Mon Sep 17 00:00:00 2001
From: Johnathan Gilday
Date: Tue, 25 Mar 2025 10:35:38 -0400
Subject: [PATCH 04/36] Add side and start_side Parameters to Create Review
Comment (#2072)
* Add side and start_side Parameters to Create Review Comment
Follows existing pattern from line and start_line
* Update src/main/java/org/kohsuke/github/GHPullRequestReviewCommentBuilder.java
* Update src/main/java/org/kohsuke/github/GHPullRequestReviewCommentBuilder.java
---------
Co-authored-by: Liam Newman
---
.../GHPullRequestReviewCommentBuilder.java | 37 +++++++++++++++++++
.../org/kohsuke/github/GHPullRequestTest.java | 9 ++++-
.../mappings/7-r_h_g_pulls_484_comments.json | 4 +-
.../mappings/8-r_h_g_pulls_484_comments.json | 4 +-
4 files changed, 49 insertions(+), 5 deletions(-)
diff --git a/src/main/java/org/kohsuke/github/GHPullRequestReviewCommentBuilder.java b/src/main/java/org/kohsuke/github/GHPullRequestReviewCommentBuilder.java
index a3b267c9f9..98709f6e8f 100644
--- a/src/main/java/org/kohsuke/github/GHPullRequestReviewCommentBuilder.java
+++ b/src/main/java/org/kohsuke/github/GHPullRequestReviewCommentBuilder.java
@@ -110,6 +110,43 @@ public GHPullRequestReviewCommentBuilder lines(int startLine, int endLine) {
return this;
}
+ /**
+ * The side of the diff in the pull request that the comment applies to.
+ *
+ * {@link #side(GHPullRequestReviewComment.Side)} and
+ * {@link #sides(GHPullRequestReviewComment.Side, GHPullRequestReviewComment.Side)} will overwrite each other's
+ * values.
+ *
+ * @param side
+ * side of the diff to which the comment applies
+ * @return the gh pull request review comment builder
+ */
+ public GHPullRequestReviewCommentBuilder side(GHPullRequestReviewComment.Side side) {
+ builder.with("side", side);
+ builder.remove("start_side");
+ return this;
+ }
+
+ /**
+ * The sides of the diff in the pull request that the comment applies to.
+ *
+ * You must use a JWT to access this endpoint.
+ *
+ * @param since
+ * - Allows users to get installations that have been updated since a given date.
+ * @return a list of App installations since a given time.
+ * @see List installations
+ */
+ public PagedIterable listInstallations(final Instant since) {
Requester requester = root().createRequest().withUrlPath("/app/installations");
if (since != null) {
- requester.with("since", GitHubClient.printDate(since));
+ requester.with("since", GitHubClient.printInstant(since));
}
return requester.toIterable(GHAppInstallation[].class, null);
}
diff --git a/src/main/java/org/kohsuke/github/GHAppInstallation.java b/src/main/java/org/kohsuke/github/GHAppInstallation.java
index c2611e468c..7764458d5a 100644
--- a/src/main/java/org/kohsuke/github/GHAppInstallation.java
+++ b/src/main/java/org/kohsuke/github/GHAppInstallation.java
@@ -1,11 +1,13 @@
package org.kohsuke.github;
import com.fasterxml.jackson.annotation.JsonProperty;
+import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.kohsuke.github.internal.EnumUtils;
import java.io.IOException;
import java.net.URL;
+import java.time.Instant;
import java.util.Collections;
import java.util.Date;
import java.util.List;
@@ -189,8 +191,9 @@ public GHRepositorySelection getRepositorySelection() {
*
* @return the suspended at
*/
- public Date getSuspendedAt() {
- return GitHubClient.parseDate(suspendedAt);
+ @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
+ public Instant getSuspendedAt() {
+ return GitHubClient.parseInstant(suspendedAt);
}
/**
diff --git a/src/main/java/org/kohsuke/github/GHAppInstallationToken.java b/src/main/java/org/kohsuke/github/GHAppInstallationToken.java
index 817156a4bc..339d80cdd2 100644
--- a/src/main/java/org/kohsuke/github/GHAppInstallationToken.java
+++ b/src/main/java/org/kohsuke/github/GHAppInstallationToken.java
@@ -1,5 +1,8 @@
package org.kohsuke.github;
+import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
+
+import java.time.Instant;
import java.util.*;
// TODO: Auto-generated Javadoc
@@ -66,7 +69,8 @@ public GHRepositorySelection getRepositorySelection() {
*
* @return date when this token expires
*/
- public Date getExpiresAt() {
- return GitHubClient.parseDate(expires_at);
+ @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
+ public Instant getExpiresAt() {
+ return GitHubClient.parseInstant(expires_at);
}
}
diff --git a/src/main/java/org/kohsuke/github/GHArtifact.java b/src/main/java/org/kohsuke/github/GHArtifact.java
index cc37a5bf4d..c9af104ed0 100644
--- a/src/main/java/org/kohsuke/github/GHArtifact.java
+++ b/src/main/java/org/kohsuke/github/GHArtifact.java
@@ -1,12 +1,14 @@
package org.kohsuke.github;
import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.apache.commons.lang3.StringUtils;
import org.kohsuke.github.function.InputStreamFunction;
import java.io.IOException;
import java.net.URL;
+import java.time.Instant;
import java.util.Date;
import java.util.Objects;
@@ -77,8 +79,9 @@ public boolean isExpired() {
*
* @return the date of expiration
*/
- public Date getExpiresAt() {
- return GitHubClient.parseDate(expiresAt);
+ @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
+ public Instant getExpiresAt() {
+ return GitHubClient.parseInstant(expiresAt);
}
/**
diff --git a/src/main/java/org/kohsuke/github/GHCheckRun.java b/src/main/java/org/kohsuke/github/GHCheckRun.java
index cb12173ae4..8befbba46b 100644
--- a/src/main/java/org/kohsuke/github/GHCheckRun.java
+++ b/src/main/java/org/kohsuke/github/GHCheckRun.java
@@ -1,12 +1,14 @@
package org.kohsuke.github;
import com.fasterxml.jackson.annotation.JsonProperty;
+import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.kohsuke.github.internal.EnumUtils;
import java.io.IOException;
import java.net.URL;
+import java.time.Instant;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
@@ -269,8 +271,9 @@ public URL getDetailsUrl() {
*
* @return Timestamp of the start time
*/
- public Date getStartedAt() {
- return GitHubClient.parseDate(startedAt);
+ @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
+ public Instant getStartedAt() {
+ return GitHubClient.parseInstant(startedAt);
}
/**
@@ -278,8 +281,9 @@ public Date getStartedAt() {
*
* @return Timestamp of the completed time
*/
- public Date getCompletedAt() {
- return GitHubClient.parseDate(completedAt);
+ @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
+ public Instant getCompletedAt() {
+ return GitHubClient.parseInstant(completedAt);
}
/**
diff --git a/src/main/java/org/kohsuke/github/GHCheckRunBuilder.java b/src/main/java/org/kohsuke/github/GHCheckRunBuilder.java
index eefe6d0235..2165b3e264 100644
--- a/src/main/java/org/kohsuke/github/GHCheckRunBuilder.java
+++ b/src/main/java/org/kohsuke/github/GHCheckRunBuilder.java
@@ -30,6 +30,7 @@
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.IOException;
+import java.time.Instant;
import java.util.Collections;
import java.util.Date;
import java.util.LinkedList;
@@ -171,10 +172,23 @@ private GHCheckRunBuilder(GHRepository repo, Requester requester) {
* @param startedAt
* the started at
* @return the GH check run builder
+ * @deprecated Use {@link #withStartedAt(Instant)}
*/
+ @Deprecated
public @NonNull GHCheckRunBuilder withStartedAt(@CheckForNull Date startedAt) {
+ return withStartedAt(GitHubClient.toInstantOrNull(startedAt));
+ }
+
+ /**
+ * With started at.
+ *
+ * @param startedAt
+ * the started at
+ * @return the GH check run builder
+ */
+ public @NonNull GHCheckRunBuilder withStartedAt(@CheckForNull Instant startedAt) {
if (startedAt != null) {
- requester.with("started_at", GitHubClient.printDate(startedAt));
+ requester.with("started_at", GitHubClient.printInstant(startedAt));
}
return this;
}
@@ -185,10 +199,23 @@ private GHCheckRunBuilder(GHRepository repo, Requester requester) {
* @param completedAt
* the completed at
* @return the GH check run builder
+ * @deprecated Use {@link #withCompletedAt(Instant)}
*/
+ @Deprecated
public @NonNull GHCheckRunBuilder withCompletedAt(@CheckForNull Date completedAt) {
+ return withCompletedAt(GitHubClient.toInstantOrNull(completedAt));
+ }
+
+ /**
+ * With completed at.
+ *
+ * @param completedAt
+ * the completed at
+ * @return the GH check run builder
+ */
+ public @NonNull GHCheckRunBuilder withCompletedAt(@CheckForNull Instant completedAt) {
if (completedAt != null) {
- requester.with("completed_at", GitHubClient.printDate(completedAt));
+ requester.with("completed_at", GitHubClient.printInstant(completedAt));
}
return this;
}
diff --git a/src/main/java/org/kohsuke/github/GHCheckSuite.java b/src/main/java/org/kohsuke/github/GHCheckSuite.java
index 8c9dea61f7..f6595fa031 100644
--- a/src/main/java/org/kohsuke/github/GHCheckSuite.java
+++ b/src/main/java/org/kohsuke/github/GHCheckSuite.java
@@ -1,10 +1,12 @@
package org.kohsuke.github;
import com.fasterxml.jackson.annotation.JsonProperty;
+import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.IOException;
import java.net.URL;
+import java.time.Instant;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
@@ -210,7 +212,7 @@ public List getPullRequests() throws IOException {
/**
* The Class HeadCommit.
*/
- public static class HeadCommit {
+ public static class HeadCommit extends GitHubBridgeAdapterObject {
/**
* Create default HeadCommit instance
@@ -257,8 +259,9 @@ public String getMessage() {
*
* @return timestamp of the commit
*/
- public Date getTimestamp() {
- return GitHubClient.parseDate(timestamp);
+ @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
+ public Instant getTimestamp() {
+ return GitHubClient.parseInstant(timestamp);
}
/**
diff --git a/src/main/java/org/kohsuke/github/GHCommit.java b/src/main/java/org/kohsuke/github/GHCommit.java
index 83ea3be00b..e3d6582f78 100644
--- a/src/main/java/org/kohsuke/github/GHCommit.java
+++ b/src/main/java/org/kohsuke/github/GHCommit.java
@@ -1,9 +1,11 @@
package org.kohsuke.github;
+import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.IOException;
import java.net.URL;
+import java.time.Instant;
import java.util.AbstractList;
import java.util.ArrayList;
import java.util.Collections;
@@ -471,7 +473,8 @@ public GHUser getAuthor() throws IOException {
* @throws IOException
* if the information was not already fetched and an attempt at fetching the information failed.
*/
- public Date getAuthoredDate() throws IOException {
+ @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
+ public Instant getAuthoredDate() throws IOException {
return getCommitShortInfo().getAuthoredDate();
}
@@ -494,7 +497,8 @@ public GHUser getCommitter() throws IOException {
* @throws IOException
* if the information was not already fetched and an attempt at fetching the information failed.
*/
- public Date getCommitDate() throws IOException {
+ @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
+ public Instant getCommitDate() throws IOException {
return getCommitShortInfo().getCommitDate();
}
diff --git a/src/main/java/org/kohsuke/github/GHCommitBuilder.java b/src/main/java/org/kohsuke/github/GHCommitBuilder.java
index 11c382312b..7dfb40e148 100644
--- a/src/main/java/org/kohsuke/github/GHCommitBuilder.java
+++ b/src/main/java/org/kohsuke/github/GHCommitBuilder.java
@@ -1,12 +1,10 @@
package org.kohsuke.github;
import java.io.IOException;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
+import java.time.Instant;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
-import java.util.TimeZone;
// TODO: Auto-generated Javadoc
/**
@@ -23,13 +21,10 @@ private static final class UserInfo {
private final String email;
private final String date;
- private UserInfo(String name, String email, Date date) {
+ private UserInfo(String name, String email, Instant date) {
this.name = name;
this.email = email;
- TimeZone tz = TimeZone.getTimeZone("UTC");
- DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
- df.setTimeZone(tz);
- this.date = df.format((date != null) ? date : new Date());
+ this.date = GitHubClient.printInstant(date);
}
}
@@ -90,8 +85,25 @@ public GHCommitBuilder parent(String parent) {
* @param date
* the date
* @return the gh commit builder
+ * @deprecated use {@link #author(String, String, Instant)} instead
*/
+ @Deprecated
public GHCommitBuilder author(String name, String email, Date date) {
+ return author(name, email, GitHubClient.toInstantOrNull(date));
+ }
+
+ /**
+ * Configures the author of this commit.
+ *
+ * @param name
+ * the name
+ * @param email
+ * the email
+ * @param date
+ * the date
+ * @return the gh commit builder
+ */
+ public GHCommitBuilder author(String name, String email, Instant date) {
req.with("author", new UserInfo(name, email, date));
return this;
}
@@ -119,8 +131,25 @@ public GHCommitBuilder withSignature(String signature) {
* @param date
* the date
* @return the gh commit builder
+ * @deprecated use {@link #committer(String, String, Instant)} instead
*/
+ @Deprecated
public GHCommitBuilder committer(String name, String email, Date date) {
+ return committer(name, email, GitHubClient.toInstantOrNull(date));
+ }
+
+ /**
+ * Configures the committer of this commit.
+ *
+ * @param name
+ * the name
+ * @param email
+ * the email
+ * @param date
+ * the date
+ * @return the gh commit builder
+ */
+ public GHCommitBuilder committer(String name, String email, Instant date) {
req.with("committer", new UserInfo(name, email, date));
return this;
}
diff --git a/src/main/java/org/kohsuke/github/GHCommitQueryBuilder.java b/src/main/java/org/kohsuke/github/GHCommitQueryBuilder.java
index e9b8f0cca8..dd4738421d 100644
--- a/src/main/java/org/kohsuke/github/GHCommitQueryBuilder.java
+++ b/src/main/java/org/kohsuke/github/GHCommitQueryBuilder.java
@@ -1,5 +1,6 @@
package org.kohsuke.github;
+import java.time.Instant;
import java.util.Date;
// TODO: Auto-generated Javadoc
@@ -88,9 +89,22 @@ public GHCommitQueryBuilder pageSize(int pageSize) {
* @param dt
* the dt
* @return the gh commit query builder
+ * @deprecated use {@link #since(Instant)}
*/
+ @Deprecated
public GHCommitQueryBuilder since(Date dt) {
- req.with("since", GitHubClient.printDate(dt));
+ return since(GitHubClient.toInstantOrNull(dt));
+ }
+
+ /**
+ * Only commits after this date will be returned.
+ *
+ * @param dt
+ * the dt
+ * @return the gh commit query builder
+ */
+ public GHCommitQueryBuilder since(Instant dt) {
+ req.with("since", GitHubClient.printInstant(dt));
return this;
}
@@ -102,7 +116,7 @@ public GHCommitQueryBuilder since(Date dt) {
* @return the gh commit query builder
*/
public GHCommitQueryBuilder since(long timestamp) {
- return since(new Date(timestamp));
+ return since(Instant.ofEpochMilli(timestamp));
}
/**
@@ -111,9 +125,22 @@ public GHCommitQueryBuilder since(long timestamp) {
* @param dt
* the dt
* @return the gh commit query builder
+ * @deprecated use {@link #until(Instant)}
*/
+ @Deprecated
public GHCommitQueryBuilder until(Date dt) {
- req.with("until", GitHubClient.printDate(dt));
+ return until(GitHubClient.toInstantOrNull(dt));
+ }
+
+ /**
+ * Only commits before this date will be returned.
+ *
+ * @param dt
+ * the dt
+ * @return the gh commit query builder
+ */
+ public GHCommitQueryBuilder until(Instant dt) {
+ req.with("until", GitHubClient.printInstant(dt));
return this;
}
@@ -125,7 +152,7 @@ public GHCommitQueryBuilder until(Date dt) {
* @return the gh commit query builder
*/
public GHCommitQueryBuilder until(long timestamp) {
- return until(new Date(timestamp));
+ return until(Instant.ofEpochMilli(timestamp));
}
/**
diff --git a/src/main/java/org/kohsuke/github/GHDeployKey.java b/src/main/java/org/kohsuke/github/GHDeployKey.java
index 50a7743688..7cd64c8e02 100644
--- a/src/main/java/org/kohsuke/github/GHDeployKey.java
+++ b/src/main/java/org/kohsuke/github/GHDeployKey.java
@@ -1,8 +1,10 @@
package org.kohsuke.github;
+import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
import org.apache.commons.lang3.builder.ToStringBuilder;
import java.io.IOException;
+import java.time.Instant;
import java.util.Date;
// TODO: Auto-generated Javadoc
@@ -89,8 +91,9 @@ public boolean isVerified() {
*
* @return the created_at
*/
- public Date getCreatedAt() {
- return GitHubClient.parseDate(created_at);
+ @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
+ public Instant getCreatedAt() {
+ return GitHubClient.parseInstant(created_at);
}
/**
@@ -98,8 +101,9 @@ public Date getCreatedAt() {
*
* @return the last_used
*/
- public Date getLastUsedAt() {
- return GitHubClient.parseDate(last_used);
+ @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
+ public Instant getLastUsedAt() {
+ return GitHubClient.parseInstant(last_used);
}
/**
diff --git a/src/main/java/org/kohsuke/github/GHEventInfo.java b/src/main/java/org/kohsuke/github/GHEventInfo.java
index 050b141f31..8238f04a06 100644
--- a/src/main/java/org/kohsuke/github/GHEventInfo.java
+++ b/src/main/java/org/kohsuke/github/GHEventInfo.java
@@ -1,9 +1,11 @@
package org.kohsuke.github;
import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.IOException;
+import java.time.Instant;
import java.util.*;
// TODO: Auto-generated Javadoc
@@ -128,8 +130,9 @@ public long getId() {
*
* @return the created at
*/
- public Date getCreatedAt() {
- return GitHubClient.parseDate(created_at);
+ @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
+ public Instant getCreatedAt() {
+ return GitHubClient.parseInstant(created_at);
}
/**
diff --git a/src/main/java/org/kohsuke/github/GHEventPayload.java b/src/main/java/org/kohsuke/github/GHEventPayload.java
index 845b95bcaa..592a04e28f 100644
--- a/src/main/java/org/kohsuke/github/GHEventPayload.java
+++ b/src/main/java/org/kohsuke/github/GHEventPayload.java
@@ -2,10 +2,12 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSetter;
+import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.IOException;
import java.io.Reader;
+import java.time.Instant;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
@@ -1363,9 +1365,11 @@ public List getModified() {
*
* @return the timestamp
*/
- public Date getTimestamp() {
- return GitHubClient.parseDate(timestamp);
+ @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
+ public Instant getTimestamp() {
+ return GitHubClient.parseInstant(timestamp);
}
+
}
}
@@ -1809,8 +1813,9 @@ public Star() {
*
* @return the date when the star is added
*/
- public Date getStarredAt() {
- return GitHubClient.parseDate(starredAt);
+ @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
+ public Instant getStarredAt() {
+ return GitHubClient.parseInstant(starredAt);
}
}
diff --git a/src/main/java/org/kohsuke/github/GHExternalGroup.java b/src/main/java/org/kohsuke/github/GHExternalGroup.java
index 50518412e1..c40608d0f5 100644
--- a/src/main/java/org/kohsuke/github/GHExternalGroup.java
+++ b/src/main/java/org/kohsuke/github/GHExternalGroup.java
@@ -1,8 +1,10 @@
package org.kohsuke.github;
+import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.IOException;
+import java.time.Instant;
import java.util.Collections;
import java.util.Date;
import java.util.List;
@@ -223,8 +225,9 @@ public String getName() {
*
* @return the date
*/
- public Date getUpdatedAt() {
- return GitHubClient.parseDate(updatedAt);
+ @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
+ public Instant getUpdatedAt() {
+ return GitHubClient.parseInstant(updatedAt);
}
/**
diff --git a/src/main/java/org/kohsuke/github/GHIssue.java b/src/main/java/org/kohsuke/github/GHIssue.java
index 4e654c7474..668a74b4d0 100644
--- a/src/main/java/org/kohsuke/github/GHIssue.java
+++ b/src/main/java/org/kohsuke/github/GHIssue.java
@@ -24,12 +24,14 @@
package org.kohsuke.github;
+import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.apache.commons.lang3.StringUtils;
import org.kohsuke.github.internal.EnumUtils;
import java.io.IOException;
import java.net.URL;
+import java.time.Instant;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -234,8 +236,9 @@ public Collection getLabels() {
*
* @return the closed at
*/
- public Date getClosedAt() {
- return GitHubClient.parseDate(closed_at);
+ @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
+ public Instant getClosedAt() {
+ return GitHubClient.parseInstant(closed_at);
}
/**
diff --git a/src/main/java/org/kohsuke/github/GHIssueCommentQueryBuilder.java b/src/main/java/org/kohsuke/github/GHIssueCommentQueryBuilder.java
index d39df0d475..9cc43b35b3 100644
--- a/src/main/java/org/kohsuke/github/GHIssueCommentQueryBuilder.java
+++ b/src/main/java/org/kohsuke/github/GHIssueCommentQueryBuilder.java
@@ -1,5 +1,6 @@
package org.kohsuke.github;
+import java.time.Instant;
import java.util.Date;
// TODO: Auto-generated Javadoc
@@ -40,9 +41,22 @@ public class GHIssueCommentQueryBuilder {
* @param date
* the date
* @return the query builder
+ * @deprecated Use {@link #since(Instant)}
*/
+ @Deprecated
public GHIssueCommentQueryBuilder since(Date date) {
- req.with("since", GitHubClient.printDate(date));
+ return since(GitHubClient.toInstantOrNull(date));
+ }
+
+ /**
+ * Only comments created/updated after this date will be returned.
+ *
+ * @param date
+ * the date
+ * @return the query builder
+ */
+ public GHIssueCommentQueryBuilder since(Instant date) {
+ req.with("since", GitHubClient.printInstant(date));
return this;
}
@@ -54,7 +68,7 @@ public GHIssueCommentQueryBuilder since(Date date) {
* @return the query builder
*/
public GHIssueCommentQueryBuilder since(long timestamp) {
- return since(new Date(timestamp));
+ return since(Instant.ofEpochMilli(timestamp));
}
/**
diff --git a/src/main/java/org/kohsuke/github/GHIssueEvent.java b/src/main/java/org/kohsuke/github/GHIssueEvent.java
index 726a590989..11193e2634 100644
--- a/src/main/java/org/kohsuke/github/GHIssueEvent.java
+++ b/src/main/java/org/kohsuke/github/GHIssueEvent.java
@@ -1,7 +1,9 @@
package org.kohsuke.github;
+import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+import java.time.Instant;
import java.util.Date;
// TODO: Auto-generated Javadoc
@@ -105,8 +107,9 @@ public String getCommitUrl() {
*
* @return the created at
*/
- public Date getCreatedAt() {
- return GitHubClient.parseDate(created_at);
+ @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
+ public Instant getCreatedAt() {
+ return GitHubClient.parseInstant(created_at);
}
/**
diff --git a/src/main/java/org/kohsuke/github/GHIssueQueryBuilder.java b/src/main/java/org/kohsuke/github/GHIssueQueryBuilder.java
index cf43cb6391..72e9bba12e 100644
--- a/src/main/java/org/kohsuke/github/GHIssueQueryBuilder.java
+++ b/src/main/java/org/kohsuke/github/GHIssueQueryBuilder.java
@@ -1,5 +1,6 @@
package org.kohsuke.github;
+import java.time.Instant;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@@ -78,9 +79,22 @@ public GHIssueQueryBuilder direction(GHDirection direction) {
* @param date
* the date
* @return the gh issue query builder
+ * @deprecated Use {@link #since(Instant)}
*/
+ @Deprecated
public GHIssueQueryBuilder since(Date date) {
- req.with("since", GitHubClient.printDate(date));
+ return since(GitHubClient.toInstantOrNull(date));
+ }
+
+ /**
+ * Only issues after this date will be returned.
+ *
+ * @param date
+ * the date
+ * @return the gh issue query builder
+ */
+ public GHIssueQueryBuilder since(Instant date) {
+ req.with("since", GitHubClient.printInstant(date));
return this;
}
diff --git a/src/main/java/org/kohsuke/github/GHMarketplacePendingChange.java b/src/main/java/org/kohsuke/github/GHMarketplacePendingChange.java
index d91e6e5417..1dcb83a43e 100644
--- a/src/main/java/org/kohsuke/github/GHMarketplacePendingChange.java
+++ b/src/main/java/org/kohsuke/github/GHMarketplacePendingChange.java
@@ -1,7 +1,9 @@
package org.kohsuke.github;
+import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+import java.time.Instant;
import java.util.Date;
// TODO: Auto-generated Javadoc
@@ -59,8 +61,9 @@ public GHMarketplacePlan getPlan() {
*
* @return the effective date
*/
- public Date getEffectiveDate() {
- return GitHubClient.parseDate(effectiveDate);
+ @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
+ public Instant getEffectiveDate() {
+ return GitHubClient.parseInstant(effectiveDate);
}
}
diff --git a/src/main/java/org/kohsuke/github/GHMarketplacePurchase.java b/src/main/java/org/kohsuke/github/GHMarketplacePurchase.java
index a0c149e159..25a06c0ef0 100644
--- a/src/main/java/org/kohsuke/github/GHMarketplacePurchase.java
+++ b/src/main/java/org/kohsuke/github/GHMarketplacePurchase.java
@@ -1,7 +1,9 @@
package org.kohsuke.github;
+import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+import java.time.Instant;
import java.util.Date;
// TODO: Auto-generated Javadoc
@@ -42,8 +44,9 @@ public String getBillingCycle() {
*
* @return the next billing date
*/
- public Date getNextBillingDate() {
- return GitHubClient.parseDate(nextBillingDate);
+ @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
+ public Instant getNextBillingDate() {
+ return GitHubClient.parseInstant(nextBillingDate);
}
/**
@@ -60,8 +63,9 @@ public boolean isOnFreeTrial() {
*
* @return the free trial ends on
*/
- public Date getFreeTrialEndsOn() {
- return GitHubClient.parseDate(freeTrialEndsOn);
+ @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
+ public Instant getFreeTrialEndsOn() {
+ return GitHubClient.parseInstant(freeTrialEndsOn);
}
/**
@@ -78,8 +82,9 @@ public Long getUnitCount() {
*
* @return the updated at
*/
- public Date getUpdatedAt() {
- return GitHubClient.parseDate(updatedAt);
+ @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
+ public Instant getUpdatedAt() {
+ return GitHubClient.parseInstant(updatedAt);
}
/**
diff --git a/src/main/java/org/kohsuke/github/GHMarketplaceUserPurchase.java b/src/main/java/org/kohsuke/github/GHMarketplaceUserPurchase.java
index fb2b210512..cd981ef0ec 100644
--- a/src/main/java/org/kohsuke/github/GHMarketplaceUserPurchase.java
+++ b/src/main/java/org/kohsuke/github/GHMarketplaceUserPurchase.java
@@ -1,7 +1,9 @@
package org.kohsuke.github;
+import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+import java.time.Instant;
import java.util.Date;
// TODO: Auto-generated Javadoc
@@ -44,8 +46,9 @@ public String getBillingCycle() {
*
* @return the next billing date
*/
- public Date getNextBillingDate() {
- return GitHubClient.parseDate(nextBillingDate);
+ @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
+ public Instant getNextBillingDate() {
+ return GitHubClient.parseInstant(nextBillingDate);
}
/**
@@ -62,8 +65,9 @@ public boolean isOnFreeTrial() {
*
* @return the free trial ends on
*/
- public Date getFreeTrialEndsOn() {
- return GitHubClient.parseDate(freeTrialEndsOn);
+ @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
+ public Instant getFreeTrialEndsOn() {
+ return GitHubClient.parseInstant(freeTrialEndsOn);
}
/**
@@ -80,8 +84,9 @@ public Long getUnitCount() {
*
* @return the updated at
*/
- public Date getUpdatedAt() {
- return GitHubClient.parseDate(updatedAt);
+ @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
+ public Instant getUpdatedAt() {
+ return GitHubClient.parseInstant(updatedAt);
}
/**
diff --git a/src/main/java/org/kohsuke/github/GHMilestone.java b/src/main/java/org/kohsuke/github/GHMilestone.java
index 3df476bb74..c0dbc6792b 100644
--- a/src/main/java/org/kohsuke/github/GHMilestone.java
+++ b/src/main/java/org/kohsuke/github/GHMilestone.java
@@ -1,9 +1,11 @@
package org.kohsuke.github;
+import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.IOException;
import java.net.URL;
+import java.time.Instant;
import java.util.Date;
import java.util.Locale;
@@ -56,10 +58,9 @@ public GHUser getCreator() {
*
* @return the due on
*/
- public Date getDueOn() {
- if (due_on == null)
- return null;
- return GitHubClient.parseDate(due_on);
+ @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
+ public Instant getDueOn() {
+ return GitHubClient.parseInstant(due_on);
}
/**
@@ -67,8 +68,9 @@ public Date getDueOn() {
*
* @return the closed at
*/
- public Date getClosedAt() {
- return GitHubClient.parseDate(closed_at);
+ @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
+ public Instant getClosedAt() {
+ return GitHubClient.parseInstant(closed_at);
}
/**
@@ -199,9 +201,23 @@ public void setDescription(String description) throws IOException {
* the due on
* @throws IOException
* the io exception
+ * @deprecated Use {@link #setDueOn(Instant)}
*/
+ @Deprecated
public void setDueOn(Date dueOn) throws IOException {
- edit("due_on", GitHubClient.printDate(dueOn));
+ setDueOn(GitHubClient.toInstantOrNull(dueOn));
+ }
+
+ /**
+ * Sets due on.
+ *
+ * @param dueOn
+ * the due on
+ * @throws IOException
+ * the io exception
+ */
+ public void setDueOn(Instant dueOn) throws IOException {
+ edit("due_on", GitHubClient.printInstant(dueOn));
}
/**
diff --git a/src/main/java/org/kohsuke/github/GHNotificationStream.java b/src/main/java/org/kohsuke/github/GHNotificationStream.java
index f769907125..cc5b2e7e86 100644
--- a/src/main/java/org/kohsuke/github/GHNotificationStream.java
+++ b/src/main/java/org/kohsuke/github/GHNotificationStream.java
@@ -1,6 +1,7 @@
package org.kohsuke.github;
import java.io.IOException;
+import java.time.Instant;
import java.util.Date;
import java.util.Iterator;
import java.util.NoSuchElementException;
@@ -84,9 +85,22 @@ public GHNotificationStream since(long timestamp) {
* @param dt
* the dt
* @return the gh notification stream
+ * @deprecated {@link #since(Instant)}
*/
+ @Deprecated
public GHNotificationStream since(Date dt) {
- since = GitHubClient.printDate(dt);
+ return since(GitHubClient.toInstantOrNull(dt));
+ }
+
+ /**
+ * Since gh notification stream.
+ *
+ * @param dt
+ * the dt
+ * @return the gh notification stream
+ */
+ public GHNotificationStream since(Instant dt) {
+ since = GitHubClient.printInstant(dt);
return this;
}
@@ -168,7 +182,7 @@ GHThread fetch() {
// if we have fetched un-returned threads, use them first
while (idx >= 0) {
GHThread n = threads[idx--];
- long nt = n.getUpdatedAt().getTime();
+ long nt = n.getUpdatedAt().toEpochMilli();
if (nt >= lastUpdated) {
lastUpdated = nt;
return n;
@@ -243,7 +257,7 @@ public void markAsRead() throws IOException {
public void markAsRead(long timestamp) throws IOException {
final Requester req = root().createRequest();
if (timestamp >= 0)
- req.with("last_read_at", GitHubClient.printDate(new Date(timestamp)));
+ req.with("last_read_at", GitHubClient.printInstant(Instant.ofEpochMilli(timestamp)));
req.withUrlPath(apiUrl).fetchHttpStatusCode();
}
diff --git a/src/main/java/org/kohsuke/github/GHObject.java b/src/main/java/org/kohsuke/github/GHObject.java
index 9d9b2f4fe0..ebd24372ad 100644
--- a/src/main/java/org/kohsuke/github/GHObject.java
+++ b/src/main/java/org/kohsuke/github/GHObject.java
@@ -1,6 +1,7 @@
package org.kohsuke.github;
import com.fasterxml.jackson.annotation.JacksonInject;
+import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
@@ -9,6 +10,7 @@
import java.io.IOException;
import java.lang.reflect.Field;
import java.net.URL;
+import java.time.Instant;
import java.util.Date;
import java.util.List;
import java.util.Map;
@@ -78,8 +80,9 @@ public Map> getResponseHeaderFields() {
* @throws IOException
* on error
*/
- public Date getCreatedAt() throws IOException {
- return GitHubClient.parseDate(createdAt);
+ @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
+ public Instant getCreatedAt() throws IOException {
+ return GitHubClient.parseInstant(createdAt);
}
/**
@@ -98,8 +101,9 @@ public URL getUrl() {
* @throws IOException
* on error
*/
- public Date getUpdatedAt() throws IOException {
- return GitHubClient.parseDate(updatedAt);
+ @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
+ public Instant getUpdatedAt() throws IOException {
+ return GitHubClient.parseInstant(updatedAt);
}
/**
diff --git a/src/main/java/org/kohsuke/github/GHPerson.java b/src/main/java/org/kohsuke/github/GHPerson.java
index 1b87779a6b..a2ed44c047 100644
--- a/src/main/java/org/kohsuke/github/GHPerson.java
+++ b/src/main/java/org/kohsuke/github/GHPerson.java
@@ -1,8 +1,11 @@
package org.kohsuke.github;
+import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
+
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URL;
+import java.time.Instant;
import java.util.Collections;
import java.util.Date;
import java.util.Map;
@@ -208,7 +211,8 @@ public String getTwitterUsername() throws IOException {
* @throws IOException
* Signals that an I/O exception has occurred.
*/
- public Date getCreatedAt() throws IOException {
+ @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
+ public Instant getCreatedAt() throws IOException {
populate();
return super.getCreatedAt();
}
@@ -220,7 +224,8 @@ public Date getCreatedAt() throws IOException {
* @throws IOException
* Signals that an I/O exception has occurred.
*/
- public Date getUpdatedAt() throws IOException {
+ @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
+ public Instant getUpdatedAt() throws IOException {
populate();
return super.getUpdatedAt();
}
diff --git a/src/main/java/org/kohsuke/github/GHProjectsV2Item.java b/src/main/java/org/kohsuke/github/GHProjectsV2Item.java
index 30e0424d1c..6e6075e18c 100644
--- a/src/main/java/org/kohsuke/github/GHProjectsV2Item.java
+++ b/src/main/java/org/kohsuke/github/GHProjectsV2Item.java
@@ -1,8 +1,10 @@
package org.kohsuke.github;
+import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
import org.kohsuke.github.internal.EnumUtils;
import java.net.URL;
+import java.time.Instant;
import java.util.Date;
// TODO: Auto-generated Javadoc
@@ -76,8 +78,9 @@ public GHUser getCreator() {
*
* @return the archived at
*/
- public Date getArchivedAt() {
- return GitHubClient.parseDate(archivedAt);
+ @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
+ public Instant getArchivedAt() {
+ return GitHubClient.parseInstant(archivedAt);
}
/**
diff --git a/src/main/java/org/kohsuke/github/GHProjectsV2ItemChanges.java b/src/main/java/org/kohsuke/github/GHProjectsV2ItemChanges.java
index d9636537ef..e703cb6577 100644
--- a/src/main/java/org/kohsuke/github/GHProjectsV2ItemChanges.java
+++ b/src/main/java/org/kohsuke/github/GHProjectsV2ItemChanges.java
@@ -1,8 +1,10 @@
package org.kohsuke.github;
+import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.kohsuke.github.internal.EnumUtils;
+import java.time.Instant;
import java.util.Date;
// TODO: Auto-generated Javadoc
@@ -12,7 +14,7 @@
* Note that this is best effort only as nothing is documented in the GitHub documentation.
*/
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_FIELD" }, justification = "JSON API")
-public class GHProjectsV2ItemChanges {
+public class GHProjectsV2ItemChanges extends GitHubBridgeAdapterObject {
/**
* Create default GHProjectsV2ItemChanges instance
@@ -138,8 +140,9 @@ public FromToDate() {
*
* @return the from
*/
- public Date getFrom() {
- return GitHubClient.parseDate(from);
+ @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
+ public Instant getFrom() {
+ return GitHubClient.parseInstant(from);
}
/**
@@ -147,8 +150,9 @@ public Date getFrom() {
*
* @return the to
*/
- public Date getTo() {
- return GitHubClient.parseDate(to);
+ @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
+ public Instant getTo() {
+ return GitHubClient.parseInstant(to);
}
}
diff --git a/src/main/java/org/kohsuke/github/GHPullRequest.java b/src/main/java/org/kohsuke/github/GHPullRequest.java
index ac91ad8c3b..28920f58e5 100644
--- a/src/main/java/org/kohsuke/github/GHPullRequest.java
+++ b/src/main/java/org/kohsuke/github/GHPullRequest.java
@@ -23,11 +23,13 @@
*/
package org.kohsuke.github;
+import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.apache.commons.lang3.StringUtils;
import java.io.IOException;
import java.net.URL;
+import java.time.Instant;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -170,8 +172,9 @@ public URL getDiffUrl() {
*
* @return the merged at
*/
- public Date getMergedAt() {
- return GitHubClient.parseDate(merged_at);
+ @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
+ public Instant getMergedAt() {
+ return GitHubClient.parseInstant(merged_at);
}
/**
diff --git a/src/main/java/org/kohsuke/github/GHPullRequestReview.java b/src/main/java/org/kohsuke/github/GHPullRequestReview.java
index 6c97354dfd..6e1bbab3cc 100644
--- a/src/main/java/org/kohsuke/github/GHPullRequestReview.java
+++ b/src/main/java/org/kohsuke/github/GHPullRequestReview.java
@@ -23,10 +23,12 @@
*/
package org.kohsuke.github;
+import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.IOException;
import java.net.URL;
+import java.time.Instant;
import java.util.Date;
import javax.annotation.CheckForNull;
@@ -144,8 +146,9 @@ protected String getApiRoute() {
*
* @return the submitted at
*/
- public Date getSubmittedAt() {
- return GitHubClient.parseDate(submitted_at);
+ @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
+ public Instant getSubmittedAt() {
+ return GitHubClient.parseInstant(submitted_at);
}
/**
@@ -156,7 +159,8 @@ public Date getSubmittedAt() {
* Signals that an I/O exception has occurred.
*/
@Override
- public Date getCreatedAt() throws IOException {
+ @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
+ public Instant getCreatedAt() throws IOException {
return getSubmittedAt();
}
diff --git a/src/main/java/org/kohsuke/github/GHRateLimit.java b/src/main/java/org/kohsuke/github/GHRateLimit.java
index b7ca406a72..9fcb290d28 100644
--- a/src/main/java/org/kohsuke/github/GHRateLimit.java
+++ b/src/main/java/org/kohsuke/github/GHRateLimit.java
@@ -8,6 +8,7 @@
import org.kohsuke.github.connector.GitHubConnectorResponse;
import java.time.Duration;
+import java.time.Instant;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
@@ -129,8 +130,10 @@ static GHRateLimit fromRecord(@Nonnull Record record, @Nonnull RateLimitTarget r
* Returns the date at which the Core API rate limit will reset.
*
* @return the calculated date at which the rate limit has or will reset.
+ * @deprecated use {@link #getCore()}
*/
@Nonnull
+ @Deprecated
public Date getResetDate() {
return getCore().getResetDate();
}
@@ -140,7 +143,9 @@ public Date getResetDate() {
*
* @return an integer
* @since 1.100
+ * @deprecated use {@link #getCore()}
*/
+ @Deprecated
public int getRemaining() {
return getCore().getRemaining();
}
@@ -150,7 +155,9 @@ public int getRemaining() {
*
* @return an integer
* @since 1.100
+ * @deprecated use {@link #getCore()}
*/
+ @Deprecated
public int getLimit() {
return getCore().getLimit();
}
@@ -160,7 +167,9 @@ public int getLimit() {
*
* @return a long
* @since 1.100
+ * @deprecated use {@link #getCore()}
*/
+ @Deprecated
public long getResetEpochSeconds() {
return getCore().getResetEpochSeconds();
}
@@ -170,7 +179,9 @@ public long getResetEpochSeconds() {
*
* @return true if the rate limit reset date has passed. Otherwise false.
* @since 1.100
+ * @deprecated use {@link #getCore()}
*/
+ @Deprecated
public boolean isExpired() {
return getCore().isExpired();
}
@@ -412,11 +423,11 @@ public static class Record {
* The date at which the rate limit will reset, adjusted to local machine time if the local machine's clock not
* synchronized with to the same clock as the GitHub server.
*
- * @see #calculateResetDate(String)
- * @see #getResetDate()
+ * @see #calculateResetInstant(String)
+ * @see #getResetInstant()
*/
@Nonnull
- private final Date resetDate;
+ private final Instant resetInstant;
/**
* Instantiates a new Record.
@@ -458,7 +469,7 @@ public Record(@JsonProperty(value = "limit", required = true) int limit,
if (connectorResponse != null) {
updatedAt = connectorResponse.header("Date");
}
- this.resetDate = calculateResetDate(updatedAt);
+ this.resetInstant = calculateResetInstant(updatedAt);
}
/**
@@ -508,11 +519,11 @@ && getRemaining() <= other.getRemaining())) {
}
/**
- * Recalculates the {@link #resetDate} relative to the local machine clock.
+ * Recalculates the {@link #resetInstant} relative to the local machine clock.
*
- * {@link RateLimitChecker}s and {@link RateLimitHandler}s use {@link #getResetDate()} to make decisions about
- * how long to wait for until for the rate limit to reset. That means that {@link #getResetDate()} needs to be
- * calculated based on the local machine clock.
+ * {@link RateLimitChecker}s and {@link RateLimitHandler}s use {@link #getResetInstant()} to make decisions
+ * about how long to wait for until for the rate limit to reset. That means that {@link #getResetInstant()}
+ * needs to be calculated based on the local machine clock.
*
*
* When we say that the clock on two machines is "synchronized", we mean that the UTC time returned from
@@ -535,7 +546,7 @@ && getRemaining() <= other.getRemaining())) {
* @return reset date based on the passed date
*/
@Nonnull
- private Date calculateResetDate(@CheckForNull String updatedAt) {
+ private Instant calculateResetInstant(@CheckForNull String updatedAt) {
long updatedAtEpochSeconds = createdAtEpochSeconds;
if (!StringUtils.isBlank(updatedAt)) {
try {
@@ -552,7 +563,7 @@ private Date calculateResetDate(@CheckForNull String updatedAt) {
// This may seem odd but it results in an accurate or slightly pessimistic reset date
// based on system time rather than assuming the system time synchronized with the server
long calculatedSecondsUntilReset = resetEpochSeconds - updatedAtEpochSeconds;
- return new Date((createdAtEpochSeconds + calculatedSecondsUntilReset) * 1000);
+ return Instant.ofEpochMilli((createdAtEpochSeconds + calculatedSecondsUntilReset) * 1000);
}
/**
@@ -578,10 +589,10 @@ public int getLimit() {
*
* This is the raw value returned by the server. This value is not adjusted if local machine time is not
* synchronized with server time. If attempting to check when the rate limit will reset, use
- * {@link #getResetDate()} or implement a {@link RateLimitChecker} instead.
+ * {@link #getResetInstant()} or implement a {@link RateLimitChecker} instead.
*
* @return a long representing the time in epoch seconds when the rate limit will reset
- * @see #getResetDate()
+ * @see #getResetInstant()
*/
public long getResetEpochSeconds() {
return resetEpochSeconds;
@@ -595,7 +606,7 @@ public long getResetEpochSeconds() {
* @return true if the rate limit reset date has passed. Otherwise false.
*/
public boolean isExpired() {
- return getResetDate().getTime() < System.currentTimeMillis();
+ return getResetInstant().toEpochMilli() < System.currentTimeMillis();
}
/**
@@ -605,10 +616,25 @@ public boolean isExpired() {
* If attempting to wait for the rate limit to reset, consider implementing a {@link RateLimitChecker} instead.
*
* @return the calculated date at which the rate limit has or will reset.
+ * @deprecated Use {@link #getResetInstant()}
*/
@Nonnull
+ @Deprecated
public Date getResetDate() {
- return new Date(resetDate.getTime());
+ return Date.from(getResetInstant());
+ }
+
+ /**
+ * The Instant at which the rate limit will reset, adjusted to local machine time if the local machine's clock
+ * not synchronized with to the same clock as the GitHub server.
+ *
+ * If attempting to wait for the rate limit to reset, consider implementing a {@link RateLimitChecker} instead.
+ *
+ * @return the calculated date at which the rate limit has or will reset.
+ */
+ @Nonnull
+ public Instant getResetInstant() {
+ return resetInstant;
}
/**
@@ -618,8 +644,8 @@ public Date getResetDate() {
*/
@Override
public String toString() {
- return "{" + "remaining=" + getRemaining() + ", limit=" + getLimit() + ", resetDate=" + getResetDate()
- + '}';
+ return "{" + "remaining=" + getRemaining() + ", limit=" + getLimit() + ", resetDate="
+ + GitHubClient.printInstant(getResetInstant()) + '}';
}
/**
@@ -640,7 +666,7 @@ public boolean equals(Object o) {
Record record = (Record) o;
return getRemaining() == record.getRemaining() && getLimit() == record.getLimit()
&& getResetEpochSeconds() == record.getResetEpochSeconds()
- && getResetDate().equals(record.getResetDate());
+ && getResetInstant().equals(record.getResetInstant());
}
/**
@@ -650,7 +676,7 @@ && getResetEpochSeconds() == record.getResetEpochSeconds()
*/
@Override
public int hashCode() {
- return Objects.hash(getRemaining(), getLimit(), getResetEpochSeconds(), getResetDate());
+ return Objects.hash(getRemaining(), getLimit(), getResetEpochSeconds(), getResetInstant());
}
}
diff --git a/src/main/java/org/kohsuke/github/GHRelease.java b/src/main/java/org/kohsuke/github/GHRelease.java
index 1c6c82851d..e0b8b0853c 100644
--- a/src/main/java/org/kohsuke/github/GHRelease.java
+++ b/src/main/java/org/kohsuke/github/GHRelease.java
@@ -8,11 +8,12 @@
import java.io.InputStream;
import java.net.URL;
import java.net.URLEncoder;
+import java.time.Instant;
import java.util.Collections;
import java.util.Date;
import java.util.List;
-import static java.lang.String.*;
+import static java.lang.String.format;
// TODO: Auto-generated Javadoc
/**
@@ -42,7 +43,7 @@ public GHRelease() {
private String body;
private boolean draft;
private boolean prerelease;
- private Date published_at;
+ private String publishedAt;
private String tarball_url;
private String zipball_url;
private String discussion_url;
@@ -101,16 +102,6 @@ public String getName() {
return name;
}
- /**
- * Sets name.
- *
- * @param name
- * the name
- */
- public void setName(String name) {
- this.name = name;
- }
-
/**
* Gets owner.
*
@@ -134,9 +125,20 @@ public boolean isPrerelease() {
* Gets published at.
*
* @return the published at
+ * @deprecated Use #getPublishedAt()
*/
+ @Deprecated
public Date getPublished_at() {
- return new Date(published_at.getTime());
+ return Date.from(getPublishedAt());
+ }
+
+ /**
+ * Gets published at.
+ *
+ * @return the published at
+ */
+ public Instant getPublishedAt() {
+ return GitHubClient.parseInstant(publishedAt);
}
/**
diff --git a/src/main/java/org/kohsuke/github/GHRepository.java b/src/main/java/org/kohsuke/github/GHRepository.java
index 65487caba9..baa02bbd09 100644
--- a/src/main/java/org/kohsuke/github/GHRepository.java
+++ b/src/main/java/org/kohsuke/github/GHRepository.java
@@ -24,6 +24,7 @@
package org.kohsuke.github;
import com.fasterxml.jackson.annotation.JsonProperty;
+import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
@@ -37,6 +38,7 @@
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.URL;
+import java.time.Instant;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
@@ -815,8 +817,9 @@ public int getSubscribersCount() {
*
* @return null if the repository was never pushed at.
*/
- public Date getPushedAt() {
- return GitHubClient.parseDate(pushed_at);
+ @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
+ public Instant getPushedAt() {
+ return GitHubClient.parseInstant(pushed_at);
}
/**
diff --git a/src/main/java/org/kohsuke/github/GHRepositoryDiscussion.java b/src/main/java/org/kohsuke/github/GHRepositoryDiscussion.java
index a04f234497..7c1195114c 100644
--- a/src/main/java/org/kohsuke/github/GHRepositoryDiscussion.java
+++ b/src/main/java/org/kohsuke/github/GHRepositoryDiscussion.java
@@ -1,8 +1,10 @@
package org.kohsuke.github;
+import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
import org.kohsuke.github.internal.EnumUtils;
import java.net.URL;
+import java.time.Instant;
import java.util.Date;
// TODO: Auto-generated Javadoc
@@ -69,8 +71,9 @@ public URL getAnswerHtmlUrl() {
*
* @return the answer chosen at
*/
- public Date getAnswerChosenAt() {
- return GitHubClient.parseDate(answerChosenAt);
+ @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
+ public Instant getAnswerChosenAt() {
+ return GitHubClient.parseInstant(answerChosenAt);
}
/**
@@ -191,7 +194,7 @@ public String getTimelineUrl() {
* "https://docs.github.com/en/graphql/guides/using-the-graphql-api-for-discussions#discussioncategory">The
* GraphQL API for Discussions
*/
- public static class Category {
+ public static class Category extends GitHubBridgeAdapterObject {
/**
* Create default Category instance
@@ -269,8 +272,9 @@ public String getDescription() {
*
* @return the created at
*/
- public Date getCreatedAt() {
- return GitHubClient.parseDate(createdAt);
+ @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
+ public Instant getCreatedAt() {
+ return GitHubClient.parseInstant(createdAt);
}
/**
@@ -278,8 +282,9 @@ public Date getCreatedAt() {
*
* @return the updated at
*/
- public Date getUpdatedAt() {
- return GitHubClient.parseDate(updatedAt);
+ @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
+ public Instant getUpdatedAt() {
+ return GitHubClient.parseInstant(updatedAt);
}
/**
diff --git a/src/main/java/org/kohsuke/github/GHRepositoryTraffic.java b/src/main/java/org/kohsuke/github/GHRepositoryTraffic.java
index 49738fceff..63bd6bcc98 100644
--- a/src/main/java/org/kohsuke/github/GHRepositoryTraffic.java
+++ b/src/main/java/org/kohsuke/github/GHRepositoryTraffic.java
@@ -1,5 +1,8 @@
package org.kohsuke.github;
+import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
+
+import java.time.Instant;
import java.util.Date;
import java.util.List;
@@ -7,7 +10,7 @@
/**
* The type GHRepositoryTraffic.
*/
-public abstract class GHRepositoryTraffic implements TrafficInfo {
+public abstract class GHRepositoryTraffic extends GitHubBridgeAdapterObject implements TrafficInfo {
private int count;
private int uniques;
@@ -68,8 +71,9 @@ public static abstract class DailyInfo implements TrafficInfo {
*
* @return the timestamp
*/
- public Date getTimestamp() {
- return GitHubClient.parseDate(timestamp);
+ @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
+ public Instant getTimestamp() {
+ return GitHubClient.parseInstant(timestamp);
}
/**
diff --git a/src/main/java/org/kohsuke/github/GHStargazer.java b/src/main/java/org/kohsuke/github/GHStargazer.java
index 1b9862295a..1f41a4e0e2 100644
--- a/src/main/java/org/kohsuke/github/GHStargazer.java
+++ b/src/main/java/org/kohsuke/github/GHStargazer.java
@@ -1,7 +1,9 @@
package org.kohsuke.github;
+import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+import java.time.Instant;
import java.util.Date;
// TODO: Auto-generated Javadoc
@@ -11,7 +13,7 @@
* @author noctarius
*/
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD" }, justification = "JSON API")
-public class GHStargazer {
+public class GHStargazer extends GitHubBridgeAdapterObject {
/**
* Create default GHStargazer instance
@@ -39,8 +41,9 @@ public GHRepository getRepository() {
*
* @return the date the stargazer was added
*/
- public Date getStarredAt() {
- return GitHubClient.parseDate(starred_at);
+ @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
+ public Instant getStarredAt() {
+ return GitHubClient.parseInstant(starred_at);
}
/**
diff --git a/src/main/java/org/kohsuke/github/GHSubscription.java b/src/main/java/org/kohsuke/github/GHSubscription.java
index 1066d51b7b..d2bac440c8 100644
--- a/src/main/java/org/kohsuke/github/GHSubscription.java
+++ b/src/main/java/org/kohsuke/github/GHSubscription.java
@@ -1,8 +1,10 @@
package org.kohsuke.github;
+import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.IOException;
+import java.time.Instant;
import java.util.Date;
// TODO: Auto-generated Javadoc
@@ -31,8 +33,9 @@ public GHSubscription() {
*
* @return the created at
*/
- public Date getCreatedAt() {
- return GitHubClient.parseDate(created_at);
+ @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
+ public Instant getCreatedAt() {
+ return GitHubClient.parseInstant(created_at);
}
/**
diff --git a/src/main/java/org/kohsuke/github/GHThread.java b/src/main/java/org/kohsuke/github/GHThread.java
index 2bafc28307..5666ba056e 100644
--- a/src/main/java/org/kohsuke/github/GHThread.java
+++ b/src/main/java/org/kohsuke/github/GHThread.java
@@ -1,9 +1,11 @@
package org.kohsuke.github;
+import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.FileNotFoundException;
import java.io.IOException;
+import java.time.Instant;
import java.util.Date;
// TODO: Auto-generated Javadoc
@@ -27,7 +29,7 @@ public class GHThread extends GHObject {
/**
* The Class Subject.
*/
- static class Subject {
+ static class Subject extends GitHubBridgeAdapterObject {
/** The title. */
String title;
@@ -50,8 +52,9 @@ private GHThread() {// no external construction allowed
*
* @return the last read at
*/
- public Date getLastReadAt() {
- return GitHubClient.parseDate(last_read_at);
+ @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
+ public Instant getLastReadAt() {
+ return GitHubClient.parseInstant(last_read_at);
}
/**
diff --git a/src/main/java/org/kohsuke/github/GHUser.java b/src/main/java/org/kohsuke/github/GHUser.java
index b53da29180..376238188f 100644
--- a/src/main/java/org/kohsuke/github/GHUser.java
+++ b/src/main/java/org/kohsuke/github/GHUser.java
@@ -23,7 +23,10 @@
*/
package org.kohsuke.github;
+import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
+
import java.io.IOException;
+import java.time.Instant;
import java.util.*;
// TODO: Auto-generated Javadoc
@@ -273,9 +276,10 @@ public Optional getLdapDn() throws IOException {
* @throws IOException
* on error
*/
- public Date getSuspendedAt() throws IOException {
+ @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
+ public Instant getSuspendedAt() throws IOException {
super.populate();
- return GitHubClient.parseDate(suspendedAt);
+ return GitHubClient.parseInstant(suspendedAt);
}
/**
diff --git a/src/main/java/org/kohsuke/github/GHWorkflowJob.java b/src/main/java/org/kohsuke/github/GHWorkflowJob.java
index 76a2fddaef..9b0a4956ec 100644
--- a/src/main/java/org/kohsuke/github/GHWorkflowJob.java
+++ b/src/main/java/org/kohsuke/github/GHWorkflowJob.java
@@ -1,6 +1,7 @@
package org.kohsuke.github;
import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.apache.commons.lang3.StringUtils;
import org.kohsuke.github.GHWorkflowRun.Conclusion;
@@ -9,6 +10,7 @@
import java.io.IOException;
import java.net.URL;
+import java.time.Instant;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
@@ -83,8 +85,9 @@ public String getHeadSha() {
*
* @return start date
*/
- public Date getStartedAt() {
- return GitHubClient.parseDate(startedAt);
+ @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
+ public Instant getStartedAt() {
+ return GitHubClient.parseInstant(startedAt);
}
/**
@@ -92,8 +95,9 @@ public Date getStartedAt() {
*
* @return completion date
*/
- public Date getCompletedAt() {
- return GitHubClient.parseDate(completedAt);
+ @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
+ public Instant getCompletedAt() {
+ return GitHubClient.parseInstant(completedAt);
}
/**
@@ -262,7 +266,7 @@ GHWorkflowJob wrapUp(GHRepository owner) {
/**
* The Class Step.
*/
- public static class Step {
+ public static class Step extends GitHubBridgeAdapterObject {
/**
* Create default Step instance
@@ -302,8 +306,9 @@ public int getNumber() {
*
* @return start date
*/
- public Date getStartedAt() {
- return GitHubClient.parseDate(startedAt);
+ @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
+ public Instant getStartedAt() {
+ return GitHubClient.parseInstant(startedAt);
}
/**
@@ -311,8 +316,9 @@ public Date getStartedAt() {
*
* @return completion date
*/
- public Date getCompletedAt() {
- return GitHubClient.parseDate(completedAt);
+ @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
+ public Instant getCompletedAt() {
+ return GitHubClient.parseInstant(completedAt);
}
/**
diff --git a/src/main/java/org/kohsuke/github/GHWorkflowRun.java b/src/main/java/org/kohsuke/github/GHWorkflowRun.java
index 04a431abbd..760cffcb26 100644
--- a/src/main/java/org/kohsuke/github/GHWorkflowRun.java
+++ b/src/main/java/org/kohsuke/github/GHWorkflowRun.java
@@ -1,6 +1,7 @@
package org.kohsuke.github;
import com.fasterxml.jackson.annotation.JsonProperty;
+import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.apache.commons.lang3.StringUtils;
import org.kohsuke.github.function.InputStreamFunction;
@@ -8,6 +9,7 @@
import java.io.IOException;
import java.net.URL;
+import java.time.Instant;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
@@ -114,8 +116,9 @@ public long getRunAttempt() {
*
* @return run triggered
*/
- public Date getRunStartedAt() {
- return GitHubClient.parseDate(runStartedAt);
+ @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
+ public Instant getRunStartedAt() {
+ return GitHubClient.parseInstant(runStartedAt);
}
/**
@@ -440,7 +443,7 @@ GHWorkflowRun wrapUp(GitHub root) {
/**
* The Class HeadCommit.
*/
- public static class HeadCommit {
+ public static class HeadCommit extends GitHubBridgeAdapterObject {
/**
* Create default HeadCommit instance
@@ -487,8 +490,9 @@ public String getMessage() {
*
* @return timestamp of the commit
*/
- public Date getTimestamp() {
- return GitHubClient.parseDate(timestamp);
+ @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
+ public Instant getTimestamp() {
+ return GitHubClient.parseInstant(timestamp);
}
/**
diff --git a/src/main/java/org/kohsuke/github/GitCommit.java b/src/main/java/org/kohsuke/github/GitCommit.java
index 4478edf7cc..d7a2768973 100644
--- a/src/main/java/org/kohsuke/github/GitCommit.java
+++ b/src/main/java/org/kohsuke/github/GitCommit.java
@@ -1,7 +1,9 @@
package org.kohsuke.github;
+import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+import java.time.Instant;
import java.util.AbstractList;
import java.util.Collections;
import java.util.Date;
@@ -16,7 +18,7 @@
*/
@SuppressFBWarnings(value = { "NP_UNWRITTEN_FIELD", "UWF_UNWRITTEN_FIELD" }, justification = "JSON API")
-public class GitCommit {
+public class GitCommit extends GitHubBridgeAdapterObject {
private GHRepository owner;
private String sha, node_id, url, html_url;
private GitUser author;
@@ -159,7 +161,8 @@ public GitUser getAuthor() {
*
* @return the authored date
*/
- public Date getAuthoredDate() {
+ @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
+ public Instant getAuthoredDate() {
return author.getDate();
}
@@ -177,7 +180,8 @@ public GitUser getCommitter() {
*
* @return the commit date
*/
- public Date getCommitDate() {
+ @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
+ public Instant getCommitDate() {
return committer.getDate();
}
diff --git a/src/main/java/org/kohsuke/github/GitHubBridgeAdapterObject.java b/src/main/java/org/kohsuke/github/GitHubBridgeAdapterObject.java
new file mode 100644
index 0000000000..3477c96013
--- /dev/null
+++ b/src/main/java/org/kohsuke/github/GitHubBridgeAdapterObject.java
@@ -0,0 +1,25 @@
+package org.kohsuke.github;
+
+import java.time.Instant;
+import java.util.Date;
+
+/**
+ * Defines a base class that holds bridge adapter methods.
+ *
+ * @author Liam Newman
+ */
+abstract class GitHubBridgeAdapterObject {
+ /**
+ * Instantiates a new git hub bridge adapter object.
+ */
+ GitHubBridgeAdapterObject() {
+ }
+
+ // Used by bridge method to convert Instant to Date
+ Object instantToDate(Instant value, Class> type) {
+ if (value == null)
+ return null;
+
+ return Date.from(value);
+ }
+}
diff --git a/src/main/java/org/kohsuke/github/GitHubClient.java b/src/main/java/org/kohsuke/github/GitHubClient.java
index 176e6cb980..b6f6b6522b 100644
--- a/src/main/java/org/kohsuke/github/GitHubClient.java
+++ b/src/main/java/org/kohsuke/github/GitHubClient.java
@@ -2,6 +2,7 @@
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.introspect.VisibilityChecker;
+import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import org.apache.commons.io.IOUtils;
import org.kohsuke.github.authorization.AuthorizationProvider;
import org.kohsuke.github.authorization.UserAuthorizationProvider;
@@ -90,6 +91,7 @@ class GitHubClient {
.ofPattern("yyyy/MM/dd HH:mm:ss Z");
static {
+ MAPPER.registerModule(new JavaTimeModule());
MAPPER.setVisibility(new VisibilityChecker.Std(NONE, NONE, NONE, NONE, ANY));
MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
MAPPER.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMS, true);
@@ -874,17 +876,17 @@ static URL parseURL(String s) {
}
/**
- * Parses the date.
+ * Convert Date to Instant or null.
*
- * @param timestamp
- * the timestamp
+ * @param date
+ * the date
* @return the date
*/
- static Date parseDate(String timestamp) {
- if (timestamp == null)
+ static Instant toInstantOrNull(Date date) {
+ if (date == null)
return null;
- return Date.from(parseInstant(timestamp));
+ return date.toInstant();
}
/**
@@ -907,14 +909,14 @@ static Instant parseInstant(String timestamp) {
}
/**
- * Prints the date.
+ * Prints the instant.
*
- * @param dt
- * the dt
+ * @param instant
+ * the instant
* @return the string
*/
- static String printDate(Date dt) {
- return DateTimeFormatter.ISO_INSTANT.format(Instant.ofEpochMilli(dt.getTime()).truncatedTo(ChronoUnit.SECONDS));
+ static String printInstant(Instant instant) {
+ return DateTimeFormatter.ISO_INSTANT.format(instant.truncatedTo(ChronoUnit.SECONDS));
}
/**
diff --git a/src/main/java/org/kohsuke/github/GitHubInteractiveObject.java b/src/main/java/org/kohsuke/github/GitHubInteractiveObject.java
index a34f6485e7..97f9dcbe21 100644
--- a/src/main/java/org/kohsuke/github/GitHubInteractiveObject.java
+++ b/src/main/java/org/kohsuke/github/GitHubInteractiveObject.java
@@ -15,7 +15,7 @@
*
* @author Liam Newman
*/
-abstract class GitHubInteractiveObject {
+abstract class GitHubInteractiveObject extends GitHubBridgeAdapterObject {
@JacksonInject
@CheckForNull
private transient final GitHub root;
diff --git a/src/main/java/org/kohsuke/github/GitUser.java b/src/main/java/org/kohsuke/github/GitUser.java
index d906bc519a..f6cb1c95e4 100644
--- a/src/main/java/org/kohsuke/github/GitUser.java
+++ b/src/main/java/org/kohsuke/github/GitUser.java
@@ -1,7 +1,9 @@
package org.kohsuke.github;
+import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+import java.time.Instant;
import java.util.Date;
import javax.annotation.CheckForNull;
@@ -17,7 +19,7 @@
*/
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD" },
justification = "JSON API")
-public class GitUser {
+public class GitUser extends GitHubBridgeAdapterObject {
private String name, email, date, username;
/**
@@ -53,8 +55,9 @@ public String getUsername() {
*
* @return Commit Date.
*/
- public Date getDate() {
- return GitHubClient.parseDate(date);
+ @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
+ public Instant getDate() {
+ return GitHubClient.parseInstant(date);
}
/**
diff --git a/src/main/java/org/kohsuke/github/RateLimitChecker.java b/src/main/java/org/kohsuke/github/RateLimitChecker.java
index 5b848cd17e..05c3c6f060 100644
--- a/src/main/java/org/kohsuke/github/RateLimitChecker.java
+++ b/src/main/java/org/kohsuke/github/RateLimitChecker.java
@@ -1,5 +1,6 @@
package org.kohsuke.github;
+import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -79,13 +80,13 @@ protected boolean checkRateLimit(GHRateLimit.Record rateLimitRecord, long count)
*/
protected final boolean sleepUntilReset(GHRateLimit.Record record) throws InterruptedException {
// Sleep until reset
- long sleepMilliseconds = record.getResetDate().getTime() - System.currentTimeMillis();
+ long sleepMilliseconds = record.getResetInstant().toEpochMilli() - System.currentTimeMillis();
if (sleepMilliseconds > 0) {
String message = String.format(
"GitHub API - Current quota has %d remaining of %d. Waiting for quota to reset at %tT.",
record.getRemaining(),
record.getLimit(),
- record.getResetDate());
+ Date.from(record.getResetInstant()));
LOGGER.log(Level.INFO, message);
diff --git a/src/main/java/org/kohsuke/github/authorization/AppInstallationAuthorizationProvider.java b/src/main/java/org/kohsuke/github/authorization/AppInstallationAuthorizationProvider.java
index 7ad33ede46..9d8a724cf2 100644
--- a/src/main/java/org/kohsuke/github/authorization/AppInstallationAuthorizationProvider.java
+++ b/src/main/java/org/kohsuke/github/authorization/AppInstallationAuthorizationProvider.java
@@ -7,8 +7,8 @@
import org.kohsuke.github.GitHub;
import java.io.IOException;
-import java.time.Duration;
import java.time.Instant;
+import java.time.temporal.ChronoUnit;
import java.util.Objects;
import javax.annotation.Nonnull;
@@ -57,7 +57,7 @@ private String refreshToken() throws IOException {
GitHub gitHub = this.gitHub();
GHAppInstallation installationByOrganization = appInstallationProvider.getAppInstallation(gitHub.getApp());
GHAppInstallationToken ghAppInstallationToken = installationByOrganization.createToken().create();
- this.validUntil = ghAppInstallationToken.getExpiresAt().toInstant().minus(Duration.ofMinutes(5));
+ this.validUntil = ghAppInstallationToken.getExpiresAt().minus(5, ChronoUnit.MINUTES);
return Objects.requireNonNull(ghAppInstallationToken.getToken());
}
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 81aa4b1272..4f01efdc82 100644
--- a/src/main/java/org/kohsuke/github/extras/authorization/JwtBuilderUtil.java
+++ b/src/main/java/org/kohsuke/github/extras/authorization/JwtBuilderUtil.java
@@ -123,6 +123,8 @@ public String buildJwt(Instant issuedAt, Instant expiration, String applicationI
SignatureAlgorithm rs256 = Jwts.SIG.RS256;
JwtBuilder jwtBuilder = Jwts.builder();
+ // jjwt uses the legacy java date-time api
+ // see https://github.com/jwtk/jjwt/issues/235 for future support for java 8 date-time api
jwtBuilder = jwtBuilder.issuedAt(Date.from(issuedAt))
.expiration(Date.from(expiration))
.issuer(applicationId)
@@ -148,8 +150,12 @@ private static final class ReflectionBuilderImpl implements IJwtBuilder {
JwtBuilder jwtBuilder = Jwts.builder();
Class> jwtReflectionClass = jwtBuilder.getClass();
+ // jjwt uses the legacy java date-time api
+ // see https://github.com/jwtk/jjwt/issues/235 for future support for java 8 date-time api
+ // noinspection UseOfObsoleteDateTimeApi
setIssuedAtMethod = jwtReflectionClass.getMethod("setIssuedAt", Date.class);
setIssuerMethod = jwtReflectionClass.getMethod("setIssuer", String.class);
+ // noinspection UseOfObsoleteDateTimeApi
setExpirationMethod = jwtReflectionClass.getMethod("setExpiration", Date.class);
Class> signatureAlgorithmClass = Class.forName("io.jsonwebtoken.SignatureAlgorithm");
rs256SignatureAlgorithm = createEnumInstance(signatureAlgorithmClass, "RS256");
@@ -186,6 +192,8 @@ private String buildJwtWithReflection(Instant issuedAt,
PrivateKey privateKey) throws IllegalAccessException, InvocationTargetException {
JwtBuilder jwtBuilder = Jwts.builder();
Object builderObj = jwtBuilder;
+ // jjwt uses the legacy java date-time api
+ // see https://github.com/jwtk/jjwt/issues/235 for future support for java 8 date-time api
builderObj = setIssuedAtMethod.invoke(builderObj, Date.from(issuedAt));
builderObj = setExpirationMethod.invoke(builderObj, Date.from(expiration));
builderObj = setIssuerMethod.invoke(builderObj, applicationId);
diff --git a/src/main/java/org/kohsuke/github/internal/graphql/response/GHGraphQLResponse.java b/src/main/java/org/kohsuke/github/internal/graphql/response/GHGraphQLResponse.java
index 54960aa556..2e3469a37e 100644
--- a/src/main/java/org/kohsuke/github/internal/graphql/response/GHGraphQLResponse.java
+++ b/src/main/java/org/kohsuke/github/internal/graphql/response/GHGraphQLResponse.java
@@ -24,6 +24,8 @@ public class GHGraphQLResponse {
private final List errors;
/**
+ * GHGraphQLResponse constructor
+ *
* @param data
* GraphQL success response
* @param errors
@@ -40,6 +42,8 @@ public GHGraphQLResponse(@JsonProperty("data") T data, @JsonProperty("errors") L
}
/**
+ * Is response succesful.
+ *
* @return request is succeeded. True when error list is empty.
*/
public boolean isSuccessful() {
@@ -47,6 +51,8 @@ public boolean isSuccessful() {
}
/**
+ * Get response data.
+ *
* @return GraphQL success response
*/
public T getData() {
@@ -58,6 +64,8 @@ public T getData() {
}
/**
+ * Get response error message.
+ *
* @return GraphQL error messages from Github Response. Empty list when no errors occurred.
*/
public List getErrorMessages() {
@@ -82,7 +90,12 @@ public String getMessage() {
*/
public static class ObjectResponse extends GHGraphQLResponse