Skip to content

Commit

Permalink
Overzealous FindBugs changes.
Browse files Browse the repository at this point in the history
Charsets that are standard on the JRE are try-lookuped,
bridge methods were removed and a stream that would be closed later is closed explicitly
  • Loading branch information
Shredder121 committed Oct 8, 2015
1 parent 6516b20 commit 5dc83cf
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 14 deletions.
15 changes: 15 additions & 0 deletions src/main/java/org/kohsuke/github/GHObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ public Date getCreatedAt() throws IOException {
return GitHub.parseDate(created_at);
}

@SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", justification = "Bridge method of getCreatedAt")
private Object createdAtStr(Date id, Class type) {
return created_at;
}

/**
* API URL of this object.
*/
Expand Down Expand Up @@ -57,4 +62,14 @@ public Date getUpdatedAt() throws IOException {
public int getId() {
return id;
}

@SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", justification = "Bridge method of getId")
private Object intToString(int id, Class type) {
return String.valueOf(id);
}

@SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", justification = "Bridge method of getHtmlUrl")
private Object urlToString(URL url, Class type) {
return url==null ? null : url.toString();
}
}
9 changes: 2 additions & 7 deletions src/main/java/org/kohsuke/github/GHRelease.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<GHAsset> getAssets() throws IOException {
Expand Down
8 changes: 2 additions & 6 deletions src/main/java/org/kohsuke/github/GitHub.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/org/kohsuke/github/Requester.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;

Expand Down Expand Up @@ -143,7 +145,7 @@ public Requester with(String key, Map<String, String> value) {
return _with(key, value);
}

public Requester with(InputStream body) {
public Requester with(@WillClose/*later*/ InputStream body) {
this.body = body;
return this;
}
Expand Down

0 comments on commit 5dc83cf

Please sign in to comment.