diff --git a/pom.xml b/pom.xml index 0af43488f1..63ff3acb00 100644 --- a/pom.xml +++ b/pom.xml @@ -34,6 +34,27 @@ + + org.codehaus.mojo + animal-sniffer-maven-plugin + 1.15 + + + org.codehaus.mojo.signature + java15 + 1.0 + + + + + ensure-java-1.5-class-library + test + + check + + + + com.infradna.tool bridge-method-injector diff --git a/src/main/java/org/kohsuke/github/GHCompare.java b/src/main/java/org/kohsuke/github/GHCompare.java index c9c882ba4e..100753db01 100644 --- a/src/main/java/org/kohsuke/github/GHCompare.java +++ b/src/main/java/org/kohsuke/github/GHCompare.java @@ -4,8 +4,6 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.net.URL; -import java.util.Arrays; -import java.util.Date; /** * The model user for comparing 2 commits in the GitHub API. @@ -72,7 +70,9 @@ public Commit getMergeBaseCommit() { * @return A copy of the array being stored in the class. */ public Commit[] getCommits() { - return Arrays.copyOf(commits, commits.length); + Commit[] newValue = new Commit[commits.length]; + System.arraycopy(commits, 0, newValue, 0, commits.length); + return newValue; } /** @@ -80,7 +80,9 @@ public Commit[] getCommits() { * @return A copy of the array being stored in the class. */ public GHCommit.File[] getFiles() { - return Arrays.copyOf(files, files.length); + GHCommit.File[] newValue = new GHCommit.File[files.length]; + System.arraycopy(files, 0, newValue, 0, files.length); + return newValue; } public GHCompare wrap(GHRepository owner) { diff --git a/src/main/java/org/kohsuke/github/GHPullRequestCommitDetail.java b/src/main/java/org/kohsuke/github/GHPullRequestCommitDetail.java index d4b48da538..e6c558b9e1 100644 --- a/src/main/java/org/kohsuke/github/GHPullRequestCommitDetail.java +++ b/src/main/java/org/kohsuke/github/GHPullRequestCommitDetail.java @@ -27,7 +27,6 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.net.URL; -import java.util.Arrays; /** * Commit detail inside a {@link GHPullRequest}. @@ -144,6 +143,8 @@ public URL getCommentsUrl() { } public CommitPointer[] getParents() { - return Arrays.copyOf(parents, parents.length); + CommitPointer[] newValue = new CommitPointer[parents.length]; + System.arraycopy(parents, 0, newValue, 0, parents.length); + return newValue; } } diff --git a/src/main/java/org/kohsuke/github/GHRepository.java b/src/main/java/org/kohsuke/github/GHRepository.java index fbd64709a6..c74d9095aa 100644 --- a/src/main/java/org/kohsuke/github/GHRepository.java +++ b/src/main/java/org/kohsuke/github/GHRepository.java @@ -1152,7 +1152,7 @@ public GHContentUpdateResponse createContent(String content, String commitMessag try { payload = content.getBytes("UTF-8"); } catch (UnsupportedEncodingException ex) { - throw new IOException("UTF-8 encoding is not supported", ex); + throw (IOException) new IOException("UTF-8 encoding is not supported").initCause(ex); } return createContent(payload, commitMessage, path, branch); } diff --git a/src/main/java/org/kohsuke/github/GitHub.java b/src/main/java/org/kohsuke/github/GitHub.java index d957212b2b..22792a8798 100644 --- a/src/main/java/org/kohsuke/github/GitHub.java +++ b/src/main/java/org/kohsuke/github/GitHub.java @@ -48,7 +48,6 @@ import java.util.Map; import java.util.Set; import java.util.TimeZone; -import java.util.concurrent.TimeUnit; import org.apache.commons.codec.Charsets; import org.apache.commons.codec.binary.Base64; @@ -57,7 +56,6 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.introspect.VisibilityChecker.Std; import com.infradna.tool.bridge_method_injector.WithBridgeMethods; -import java.nio.charset.Charset; import java.util.logging.Logger; /** @@ -134,8 +132,8 @@ public class GitHub { } else { if (password!=null) { String authorization = (login + ':' + password); - Charset charset = Charsets.UTF_8; - encodedAuthorization = "Basic "+new String(Base64.encodeBase64(authorization.getBytes(charset)), charset); + String charsetName = Charsets.UTF_8.name(); + encodedAuthorization = "Basic "+new String(Base64.encodeBase64(authorization.getBytes(charsetName)), charsetName); } else {// anonymous access encodedAuthorization = null; } @@ -265,7 +263,8 @@ public GHRateLimit getRateLimit() throws IOException { // see issue #78 GHRateLimit r = new GHRateLimit(); r.limit = r.remaining = 1000000; - r.reset = new Date(System.currentTimeMillis() + TimeUnit.HOURS.toMillis(1)); + long hours = 1000L * 60 * 60; + r.reset = new Date(System.currentTimeMillis() + 1 * hours ); return r; } }