Skip to content

Commit

Permalink
Simplity some code (#7179)
Browse files Browse the repository at this point in the history
  • Loading branch information
strugcoder authored Feb 9, 2021
1 parent f7c6396 commit 6c08866
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ public static boolean contains(final String[] array, String valueToFind) {
}

public static int indexOf(String[] array, String valueToFind, int startIndex) {
if (isEmpty(array) || valueToFind == null) {
return -1;
} else {
if (!isEmpty(array) && valueToFind != null) {
if (startIndex < 0) {
startIndex = 0;
}
Expand All @@ -63,8 +61,8 @@ public static int indexOf(String[] array, String valueToFind, int startIndex) {
}
}

return -1;
}
return -1;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ protected void createFailoverStrategy(URL url) {
* @return true store metadata to the specified URL.
*/
protected boolean shouldRegister(URL url) {
return this.strategy == null ? true : this.strategy.shouldRegister(url);
return this.strategy == null || this.strategy.shouldRegister(url);
}

/**
Expand All @@ -70,7 +70,7 @@ protected boolean shouldRegister(URL url) {
* @return true read metadata from specified URL.
*/
protected boolean shouldQuery(URL url) {
return this.strategy == null ? true : this.strategy.shouldQuery(url);
return this.strategy == null || this.strategy.shouldQuery(url);
}

/**
Expand All @@ -82,7 +82,7 @@ protected boolean shouldQuery(URL url) {
* @return
*/
protected boolean isLocalDataCenter(URL url) {
return this.strategy == null ? true : this.strategy.isLocalDataCenter(url);
return this.strategy == null || this.strategy.isLocalDataCenter(url);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public URL getUrl() {

@Override
public boolean isAvailable() {
boolean available = serviceRegistries.isEmpty() ? true : false;
boolean available = serviceRegistries.isEmpty();
for (Registry serviceRegistry : serviceRegistries.values()) {
if (serviceRegistry.isAvailable()) {
available = true;
Expand All @@ -128,7 +128,7 @@ public boolean isAvailable() {
return false;
}

available = referenceRegistries.isEmpty() ? true : false;
available = referenceRegistries.isEmpty();
for (Registry referenceRegistry : referenceRegistries.values()) {
if (referenceRegistry.isAvailable()) {
available = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,8 @@ public NextAction handleRead(FilterChainContext context) throws IOException {
}
if (msg != null) {
context.setMessage(msg);
return context.getInvokeAction();
} else {
return context.getInvokeAction();
}
return context.getInvokeAction();
}
} while (frame.readable());
} else { // Other events are passed down directly
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ protected Result doInvoke(Invocation invocation) throws Throwable {
}
} catch (Throwable t) {
RpcException re = new RpcException("Failed to invoke redis service method. interface: " + type.getName() + ", method: " + invocation.getMethodName() + ", url: " + url + ", cause: " + t.getMessage(), t);
if (t instanceof TimeoutException || t instanceof SocketTimeoutException) {
if (t instanceof SocketTimeoutException) {
re.setCode(RpcException.TIMEOUT_EXCEPTION);
} else if (t instanceof JedisConnectionException || t instanceof IOException) {
re.setCode(RpcException.NETWORK_EXCEPTION);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class $__ClassNameTestDubboStub {

public interface Iface {

public String echo(String arg);
String echo(String arg);

}

Expand Down

0 comments on commit 6c08866

Please sign in to comment.