Skip to content
Open
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
2 changes: 1 addition & 1 deletion src/main/java/org/kohsuke/github/GHBlob.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public String getContent() {
* @return the actual bytes of the blob.
*/
public InputStream read() {
if (encoding.equals("base64")) {
if ("base64".equals(encoding)) {
try {
Base64.Decoder decoder = Base64.getMimeDecoder();
return new ByteArrayInputStream(decoder.decode(content));
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/kohsuke/github/GHContent.java
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public String getHtmlUrl() {
*/
public InputStream read() throws IOException {
refresh(content);
if (encoding.equals("base64")) {
if ("base64".equals(encoding)) {
try {
Base64.Decoder decoder = Base64.getMimeDecoder();
return new ByteArrayInputStream(decoder.decode(content.getBytes(StandardCharsets.US_ASCII)));
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/kohsuke/github/GHHook.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public String getName() {
public EnumSet<GHEvent> getEvents() {
EnumSet<GHEvent> s = EnumSet.noneOf(GHEvent.class);
for (String e : events) {
s.add(e.equals("*") ? GHEvent.ALL : EnumUtils.getEnumOrDefault(GHEvent.class, e, GHEvent.UNKNOWN));
s.add("*".equals(e) ? GHEvent.ALL : EnumUtils.getEnumOrDefault(GHEvent.class, e, GHEvent.UNKNOWN));
}
return s;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/kohsuke/github/GHRef.java
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ static PagedIterable<GHRef> readMatching(GHRepository repository, String refType

String url = repository.getApiTailUrl(String.format("git/refs/%s", refType));
// if no types, do not end with slash just to be safe.
if (refType.equals("")) {
if ("".equals(refType)) {
url = url.substring(0, url.length() - 1);
}
return repository.root().createRequest().withUrlPath(url).toIterable(GHRef[].class, item -> repository.root());
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/kohsuke/github/GHRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -2553,7 +2553,7 @@ private List<URL> getPostCommitHooks() {
try {
List<URL> r = new ArrayList<>();
for (GHHook h : getHooks()) {
if (h.getName().equals("web")) {
if ("web".equals(h.getName())) {
r.add(new URL(h.getConfig().get("url")));
}
}
Expand Down Expand Up @@ -2588,7 +2588,7 @@ public boolean remove(Object url) {
try {
String _url = ((URL) url).toExternalForm();
for (GHHook h : getHooks()) {
if (h.getName().equals("web") && h.getConfig().get("url").equals(_url)) {
if ("web".equals(h.getName()) && h.getConfig().get("url").equals(_url)) {
h.delete();
return true;
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/kohsuke/github/GHTreeEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public URL getUrl() {
* the io exception
*/
public GHBlob asBlob() throws IOException {
if (type.equals("blob"))
if ("blob".equals(type))
return tree.repo.getBlob(sha);
else
return null;
Expand All @@ -96,7 +96,7 @@ public GHBlob asBlob() throws IOException {
* the io exception
*/
public InputStream readAsBlob() throws IOException {
if (type.equals("blob"))
if ("blob".equals(type))
return tree.repo.readBlob(sha);
else
return null;
Expand All @@ -110,7 +110,7 @@ public InputStream readAsBlob() throws IOException {
* the io exception
*/
public GHTree asTree() throws IOException {
if (type.equals("tree"))
if ("tree".equals(type))
return tree.repo.getTree(sha);
else
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ protected InputStream wrapStream(InputStream stream) throws IOException {
String encoding = header("Content-Encoding");
if (encoding == null || stream == null)
return stream;
if (encoding.equals("gzip"))
if ("gzip".equals(encoding))
return new GZIPInputStream(stream);

throw new UnsupportedOperationException("Unexpected Content-Encoding: " + encoding);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,9 @@ HttpURLConnection open(URL url, @Nullable Proxy proxy) {
String protocol = url.getProtocol();
OkHttpClient copy = client.newBuilder().proxy(proxy).build();

if (protocol.equals("http"))
if ("http".equals(protocol))
return new OkHttpURLConnection(url, copy);
if (protocol.equals("https"))
if ("https".equals(protocol))
return new OkHttpsURLConnection(url, copy);
throw new IllegalArgumentException("Unexpected protocol: " + protocol);
}
Expand All @@ -194,7 +194,7 @@ HttpURLConnection open(URL url, @Nullable Proxy proxy) {
*/
@Override
public URLStreamHandler createURLStreamHandler(final String protocol) {
if (!protocol.equals("http") && !protocol.equals("https"))
if (!"http".equals(protocol) && !"https".equals(protocol))
return null;

return new URLStreamHandler() {
Expand All @@ -210,9 +210,9 @@ protected URLConnection openConnection(URL url, Proxy proxy) {

@Override
protected int getDefaultPort() {
if (protocol.equals("http"))
if ("http".equals(protocol))
return 80;
if (protocol.equals("https"))
if ("https".equals(protocol))
return 443;
throw new AssertionError();
}
Expand All @@ -224,7 +224,7 @@ static String format(Date value) {
}

static boolean permitsRequestBody(String method) {
return !(method.equals("GET") || method.equals("HEAD"));
return !("GET".equals(method) || "HEAD".equals(method));
}

/** Returns true if the response must have a (possibly 0-length) body. See RFC 7231. */
Expand Down Expand Up @@ -571,7 +571,7 @@ private Call buildCall() throws IOException {

connected = true;
if (doOutput) {
if (method.equals("GET")) {
if ("GET".equals(method)) {
method = "POST";
} else if (!permitsRequestBody(method)) {
throw new ProtocolException(method + " does not support writing");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ public static GitHubConnector create() {

static GitHubConnector create(String defaultConnectorProperty) {

if (defaultConnectorProperty.equalsIgnoreCase("okhttp")) {
if ("okhttp".equalsIgnoreCase(defaultConnectorProperty)) {
return new OkHttpGitHubConnector(new OkHttpClient.Builder().build());
} else if (defaultConnectorProperty.equalsIgnoreCase("okhttpconnector")) {
} else if ("okhttpconnector".equalsIgnoreCase(defaultConnectorProperty)) {
return new GitHubConnectorHttpConnectorAdapter(new OkHttpConnector(new OkHttpClient.Builder().build()));
} else if (defaultConnectorProperty.equalsIgnoreCase("urlconnection")) {
} else if ("urlconnection".equalsIgnoreCase(defaultConnectorProperty)) {
return new GitHubConnectorHttpConnectorAdapter(HttpConnector.DEFAULT);
} else if (defaultConnectorProperty.equalsIgnoreCase("httpclient")) {
} else if ("httpclient".equalsIgnoreCase(defaultConnectorProperty)) {
return new HttpClientGitHubConnector();
} else if (defaultConnectorProperty.equalsIgnoreCase("default")) {
} else if ("default".equalsIgnoreCase(defaultConnectorProperty)) {
try {
return new HttpClientGitHubConnector();
} catch (UnsupportedOperationException | LinkageError e) {
Expand Down