diff --git a/src/main/java/org/kohsuke/github/GHObject.java b/src/main/java/org/kohsuke/github/GHObject.java index 50aa0a6a86..aa7bbe7920 100644 --- a/src/main/java/org/kohsuke/github/GHObject.java +++ b/src/main/java/org/kohsuke/github/GHObject.java @@ -29,6 +29,10 @@ public Date getCreatedAt() throws IOException { return GitHub.parseDate(created_at); } + private Object createdAtStr(Date id, Class type) { + return created_at; + } + /** * API URL of this object. */ @@ -57,4 +61,12 @@ public Date getUpdatedAt() throws IOException { public int getId() { return id; } + + private Object intToString(int id, Class type) { + return String.valueOf(id); + } + + private Object urlToString(URL url, Class type) { + return url==null ? null : url.toString(); + } } diff --git a/src/main/java/org/kohsuke/github/GHRelease.java b/src/main/java/org/kohsuke/github/GHRelease.java index 901bb8f359..b61dc62b38 100644 --- a/src/main/java/org/kohsuke/github/GHRelease.java +++ b/src/main/java/org/kohsuke/github/GHRelease.java @@ -129,14 +129,9 @@ public GHAsset uploadAsset(File file, String contentType) throws IOException { String url = format("https://uploads.github.com%s/releases/%d/assets?name=%s", owner.getApiTailUrl(""), getId(), file.getName()); - FileInputStream istream = new FileInputStream(file); - try { - return builder.contentType(contentType) - .with(istream) + return builder.contentType(contentType) + .with(new FileInputStream(file)) .to(url, GHAsset.class).wrap(this); - } finally { - istream.close(); - } } public List getAssets() throws IOException { diff --git a/src/main/java/org/kohsuke/github/GitHub.java b/src/main/java/org/kohsuke/github/GitHub.java index 9e638bb4aa..2eaef53ceb 100644 --- a/src/main/java/org/kohsuke/github/GitHub.java +++ b/src/main/java/org/kohsuke/github/GitHub.java @@ -47,6 +47,7 @@ import java.util.TimeZone; import java.util.concurrent.TimeUnit; +import org.apache.commons.codec.Charsets; import org.apache.commons.codec.binary.Base64; import com.fasterxml.jackson.databind.DeserializationFeature; @@ -129,12 +130,7 @@ public class GitHub { } else { if (password!=null) { String authorization = (login + ':' + password); - final Charset charset; - try { - charset = Charset.forName("UTF-8"); - } catch (Exception ex) { - throw new IOException("UTF-8 encoding is not supported", ex); - } + Charset charset = Charsets.UTF_8; encodedAuthorization = "Basic "+new String(Base64.encodeBase64(authorization.getBytes(charset)), charset); } else {// anonymous access encodedAuthorization = null; diff --git a/src/main/java/org/kohsuke/github/Requester.java b/src/main/java/org/kohsuke/github/Requester.java index 78ead072d9..b8b53b78cd 100644 --- a/src/main/java/org/kohsuke/github/Requester.java +++ b/src/main/java/org/kohsuke/github/Requester.java @@ -53,6 +53,8 @@ import java.util.regex.Pattern; import java.util.zip.GZIPInputStream; +import javax.annotation.WillClose; + import static java.util.Arrays.asList; import static org.kohsuke.github.GitHub.*; @@ -143,7 +145,7 @@ public Requester with(String key, Map value) { return _with(key, value); } - public Requester with(InputStream body) { + public Requester with(@WillClose/*later*/ InputStream body) { this.body = body; return this; }