mirror of
https://github.com/jlengrand/github-api.git
synced 2026-04-04 08:21:23 +00:00
Populate Source and Parent if needed
NOTE: this also addresses a bug in push events where the repository url is incorrect
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonParseException;
|
||||
import com.fasterxml.jackson.databind.InjectableValues;
|
||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
@@ -16,6 +17,8 @@ import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.annotation.CheckForNull;
|
||||
import javax.annotation.Nonnull;
|
||||
@@ -31,6 +34,8 @@ import javax.annotation.Nonnull;
|
||||
*/
|
||||
class GitHubResponse<T> {
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(GitHubResponse.class.getName());
|
||||
|
||||
private final int statusCode;
|
||||
|
||||
@Nonnull
|
||||
@@ -83,9 +88,10 @@ class GitHubResponse<T> {
|
||||
inject.addValue(ResponseInfo.class, responseInfo);
|
||||
|
||||
return GitHubClient.getMappingObjectReader(responseInfo).forType(type).readValue(data);
|
||||
} catch (JsonMappingException e) {
|
||||
String message = "Failed to deserialize " + data;
|
||||
throw new IOException(message, e);
|
||||
} catch (JsonMappingException | JsonParseException e) {
|
||||
String message = "Failed to deserialize: " + data;
|
||||
LOGGER.log(Level.FINE, message);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,9 +114,10 @@ class GitHubResponse<T> {
|
||||
String data = responseInfo.getBodyAsString();
|
||||
try {
|
||||
return GitHubClient.getMappingObjectReader(responseInfo).withValueToUpdate(instance).readValue(data);
|
||||
} catch (JsonMappingException e) {
|
||||
String message = "Failed to deserialize " + data;
|
||||
throw new IOException(message, e);
|
||||
} catch (JsonMappingException | JsonParseException e) {
|
||||
String message = "Failed to deserialize: " + data;
|
||||
LOGGER.log(Level.FINE, message);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -307,6 +314,7 @@ class GitHubResponse<T> {
|
||||
* @throws IOException
|
||||
* if an I/O Exception occurs.
|
||||
*/
|
||||
@Nonnull
|
||||
String getBodyAsString() throws IOException {
|
||||
InputStreamReader r = null;
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user