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

code optimization #3167

Merged
merged 1 commit into from
Jan 8, 2019
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
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
package org.apache.dubbo.rpc;

import org.apache.dubbo.common.utils.StringUtils;

import java.util.HashMap;
import java.util.Map;

Expand Down Expand Up @@ -58,7 +60,7 @@ public String getAttachment(String key) {
@Override
public String getAttachment(String key, String defaultValue) {
String result = attachments.get(key);
if (result == null || result.length() == 0) {
if (StringUtils.isEmpty(result)) {
result = defaultValue;
}
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.threadlocal.InternalThreadLocal;
import org.apache.dubbo.common.utils.NetUtils;
import org.apache.dubbo.common.utils.StringUtils;

import java.net.InetSocketAddress;
import java.util.ArrayList;
Expand Down Expand Up @@ -364,7 +365,7 @@ public String getLocalAddressString() {
*/
public String getLocalHostName() {
String host = localAddress == null ? null : localAddress.getHostName();
if (host == null || host.length() == 0) {
if (StringUtils.isEmpty(host)) {
return getLocalHost();
}
return host;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@
public static final int SERIALIZATION_EXCEPTION = 5;
public static final int NO_INVOKER_AVAILABLE_AFTER_FILTER = 6;
private static final long serialVersionUID = 7815426752583648734L;
private int code; // RpcException cannot be extended, use error code for exception type to keep compatibility
/**
* RpcException cannot be extended, use error code for exception type to keep compatibility
*/
private int code;

public RpcException() {
super();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.utils.StringUtils;

import java.io.Serializable;
import java.lang.reflect.Method;
Expand Down Expand Up @@ -198,7 +199,7 @@ public String getAttachment(String key, String defaultValue) {
return defaultValue;
}
String value = attachments.get(key);
if (value == null || value.length() == 0) {
if (StringUtils.isEmpty(value)) {
return defaultValue;
}
return value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public interface GenericService {
* @param parameterTypes Parameter types
* @param args Arguments
* @return invocation return value
* @throws Throwable potential exception thrown from the invocation
* @throws GenericException potential exception thrown from the invocation
*/
Object $invoke(String method, String[] parameterTypes, Object[] args) throws GenericException;

Expand Down