mirror of
https://github.com/jlengrand/github-api.git
synced 2026-03-12 00:11:22 +00:00
Compare commits
10 Commits
github-api
...
github-api
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3d03659508 | ||
|
|
0374d2de48 | ||
|
|
2627dc5ee4 | ||
|
|
1f4325e7db | ||
|
|
f2e7b40425 | ||
|
|
4ee3086b6d | ||
|
|
a3a715c3ba | ||
|
|
6cad4a3c33 | ||
|
|
b9b6f4fd44 | ||
|
|
17d1994a53 |
4
pom.xml
4
pom.xml
@@ -7,7 +7,7 @@
|
|||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>github-api</artifactId>
|
<artifactId>github-api</artifactId>
|
||||||
<version>1.83</version>
|
<version>1.85</version>
|
||||||
<name>GitHub API for Java</name>
|
<name>GitHub API for Java</name>
|
||||||
<url>http://github-api.kohsuke.org/</url>
|
<url>http://github-api.kohsuke.org/</url>
|
||||||
<description>GitHub API for Java</description>
|
<description>GitHub API for Java</description>
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
<connection>scm:git:git@github.com/kohsuke/${project.artifactId}.git</connection>
|
<connection>scm:git:git@github.com/kohsuke/${project.artifactId}.git</connection>
|
||||||
<developerConnection>scm:git:ssh://git@github.com/kohsuke/${project.artifactId}.git</developerConnection>
|
<developerConnection>scm:git:ssh://git@github.com/kohsuke/${project.artifactId}.git</developerConnection>
|
||||||
<url>http://${project.artifactId}.kohsuke.org/</url>
|
<url>http://${project.artifactId}.kohsuke.org/</url>
|
||||||
<tag>github-api-1.83</tag>
|
<tag>github-api-1.85</tag>
|
||||||
</scm>
|
</scm>
|
||||||
|
|
||||||
<distributionManagement>
|
<distributionManagement>
|
||||||
|
|||||||
@@ -47,13 +47,12 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import javax.annotation.CheckForNull;
|
import javax.annotation.CheckForNull;
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import org.apache.commons.codec.Charsets;
|
import org.apache.commons.codec.Charsets;
|
||||||
import org.apache.commons.codec.binary.Base64;
|
import org.apache.commons.codec.binary.Base64;
|
||||||
|
import org.apache.commons.io.IOUtils;
|
||||||
|
|
||||||
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.ANY;
|
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.ANY;
|
||||||
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
|
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
|
||||||
@@ -303,7 +302,7 @@ public class GitHub {
|
|||||||
GHRateLimit r = new GHRateLimit();
|
GHRateLimit r = new GHRateLimit();
|
||||||
r.limit = r.remaining = 1000000;
|
r.limit = r.remaining = 1000000;
|
||||||
long hour = 60L * 60L; // this is madness, storing the date as seconds in a Date object
|
long hour = 60L * 60L; // this is madness, storing the date as seconds in a Date object
|
||||||
r.reset = new Date((System.currentTimeMillis() + hour) / 1000L );
|
r.reset = new Date(System.currentTimeMillis() / 1000L + hour);
|
||||||
return rateLimit = r;
|
return rateLimit = r;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -314,7 +313,7 @@ public class GitHub {
|
|||||||
|| headerRateLimit.getResetDate().getTime() < observed.getResetDate().getTime()
|
|| headerRateLimit.getResetDate().getTime() < observed.getResetDate().getTime()
|
||||||
|| headerRateLimit.remaining > observed.remaining) {
|
|| headerRateLimit.remaining > observed.remaining) {
|
||||||
headerRateLimit = observed;
|
headerRateLimit = observed;
|
||||||
LOGGER.log(Level.INFO, "Rate limit now: {0}", headerRateLimit);
|
LOGGER.log(FINE, "Rate limit now: {0}", headerRateLimit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -703,8 +702,18 @@ public class GitHub {
|
|||||||
Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
|
Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
|
||||||
X-Content-Type-Options: nosniff
|
X-Content-Type-Options: nosniff
|
||||||
*/
|
*/
|
||||||
return uc.getResponseCode() == HTTP_UNAUTHORIZED
|
try {
|
||||||
&& uc.getHeaderField("X-GitHub-Media-Type") != null;
|
return uc.getResponseCode() == HTTP_UNAUTHORIZED
|
||||||
|
&& uc.getHeaderField("X-GitHub-Media-Type") != null;
|
||||||
|
} finally {
|
||||||
|
// ensure that the connection opened by getResponseCode gets closed
|
||||||
|
try {
|
||||||
|
IOUtils.closeQuietly(uc.getInputStream());
|
||||||
|
} catch (IOException ignore) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
IOUtils.closeQuietly(uc.getErrorStream());
|
||||||
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,6 @@ import java.util.List;
|
|||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
@@ -58,7 +57,7 @@ import org.apache.commons.io.IOUtils;
|
|||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
|
||||||
import static java.util.Arrays.asList;
|
import static java.util.Arrays.asList;
|
||||||
import static java.util.logging.Level.FINE;
|
import static java.util.logging.Level.*;
|
||||||
import static org.kohsuke.github.GitHub.MAPPER;
|
import static org.kohsuke.github.GitHub.MAPPER;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -352,16 +351,16 @@ class Requester {
|
|||||||
try {
|
try {
|
||||||
observed.limit = Integer.parseInt(limit);
|
observed.limit = Integer.parseInt(limit);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
if (LOGGER.isLoggable(Level.FINEST)) {
|
if (LOGGER.isLoggable(FINEST)) {
|
||||||
LOGGER.log(Level.FINEST, "Malformed X-RateLimit-Limit header value " + limit, e);
|
LOGGER.log(FINEST, "Malformed X-RateLimit-Limit header value " + limit, e);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
observed.remaining = Integer.parseInt(remaining);
|
observed.remaining = Integer.parseInt(remaining);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
if (LOGGER.isLoggable(Level.FINEST)) {
|
if (LOGGER.isLoggable(FINEST)) {
|
||||||
LOGGER.log(Level.FINEST, "Malformed X-RateLimit-Remaining header value " + remaining, e);
|
LOGGER.log(FINEST, "Malformed X-RateLimit-Remaining header value " + remaining, e);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -369,8 +368,8 @@ class Requester {
|
|||||||
observed.reset = new Date(Long.parseLong(reset)); // this is madness, storing the date as seconds
|
observed.reset = new Date(Long.parseLong(reset)); // this is madness, storing the date as seconds
|
||||||
root.updateRateLimit(observed);
|
root.updateRateLimit(observed);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
if (LOGGER.isLoggable(Level.FINEST)) {
|
if (LOGGER.isLoggable(FINEST)) {
|
||||||
LOGGER.log(Level.FINEST, "Malformed X-RateLimit-Reset header value " + reset, e);
|
LOGGER.log(FINEST, "Malformed X-RateLimit-Reset header value " + reset, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -642,6 +641,24 @@ class Requester {
|
|||||||
" handling exception " + e, e);
|
" handling exception " + e, e);
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
InputStream es = wrapStream(uc.getErrorStream());
|
||||||
|
if (es != null) {
|
||||||
|
try {
|
||||||
|
String error = IOUtils.toString(es, "UTF-8");
|
||||||
|
if (e instanceof FileNotFoundException) {
|
||||||
|
// pass through 404 Not Found to allow the caller to handle it intelligently
|
||||||
|
e = (IOException) new FileNotFoundException(error).initCause(e);
|
||||||
|
} else if (e instanceof HttpException) {
|
||||||
|
HttpException http = (HttpException) e;
|
||||||
|
e = new HttpException(error, http.getResponseCode(), http.getResponseMessage(),
|
||||||
|
http.getUrl(), e);
|
||||||
|
} else {
|
||||||
|
e = (IOException) new IOException(error).initCause(e);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
IOUtils.closeQuietly(es);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (responseCode == HttpURLConnection.HTTP_UNAUTHORIZED) // 401 / Unauthorized == bad creds
|
if (responseCode == HttpURLConnection.HTTP_UNAUTHORIZED) // 401 / Unauthorized == bad creds
|
||||||
throw e;
|
throw e;
|
||||||
|
|
||||||
@@ -657,24 +674,7 @@ class Requester {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
InputStream es = wrapStream(uc.getErrorStream());
|
throw e;
|
||||||
try {
|
|
||||||
if (es!=null) {
|
|
||||||
String error = IOUtils.toString(es, "UTF-8");
|
|
||||||
if (e instanceof FileNotFoundException) {
|
|
||||||
// pass through 404 Not Found to allow the caller to handle it intelligently
|
|
||||||
throw (IOException) new FileNotFoundException(error).initCause(e);
|
|
||||||
} else if (e instanceof HttpException) {
|
|
||||||
HttpException http = (HttpException) e;
|
|
||||||
throw (IOException) new HttpException(error, http.getResponseCode(), http.getResponseMessage(), http.getUrl(), e);
|
|
||||||
} else {
|
|
||||||
throw (IOException) new IOException(error).initCause(e);
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
throw e;
|
|
||||||
} finally {
|
|
||||||
IOUtils.closeQuietly(es);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final List<String> METHODS_WITHOUT_BODY = asList("GET", "DELETE");
|
private static final List<String> METHODS_WITHOUT_BODY = asList("GET", "DELETE");
|
||||||
|
|||||||
Reference in New Issue
Block a user