Skip to content

Commit

Permalink
Merge pull request #259 from Shredder121/animal-sniffer
Browse files Browse the repository at this point in the history
Animal sniffer
  • Loading branch information
kohsuke committed Mar 19, 2016
2 parents 14dcb37 + 0cd5147 commit 7307bec
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 12 deletions.
21 changes: 21 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,27 @@

<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>animal-sniffer-maven-plugin</artifactId>
<version>1.15</version>
<configuration>
<signature>
<groupId>org.codehaus.mojo.signature</groupId>
<artifactId>java15</artifactId>
<version>1.0</version>
</signature>
</configuration>
<executions>
<execution>
<id>ensure-java-1.5-class-library</id>
<phase>test</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.infradna.tool</groupId>
<artifactId>bridge-method-injector</artifactId>
Expand Down
10 changes: 6 additions & 4 deletions src/main/java/org/kohsuke/github/GHCompare.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -72,15 +70,19 @@ 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;
}

/**
* Gets an array of commits.
* @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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}.
Expand Down Expand Up @@ -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;
}
}
2 changes: 1 addition & 1 deletion src/main/java/org/kohsuke/github/GHRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
9 changes: 4 additions & 5 deletions src/main/java/org/kohsuke/github/GitHub.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

/**
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
}
Expand Down

0 comments on commit 7307bec

Please sign in to comment.