Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overzealous FindBugs changes. #225

Merged
merged 1 commit into from
Dec 1, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be inlined with static import i think

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If more people agree I'll do that then.
Shall I remove the variable declaration and inline it to the method call or just convert to static import?

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