name
stringlengths 12
178
| code_snippet
stringlengths 8
36.5k
| score
float64 3.26
3.68
|
---|---|---|
dubbo_ApplicationModel_getProviderModel_rdh | /**
*
* @deprecated use {@link FrameworkServiceRepository#lookupExportedService(String)}
*/
@Deprecated
public static ProviderModel getProviderModel(String serviceKey) {
return defaultModel().getDefaultModule().getServiceRepository().lookupExportedService(serviceKey);
} | 3.26 |
dubbo_ApplicationModel_getApplication_rdh | /**
*
* @deprecated Replace to {@link ApplicationModel#getApplicationName()}
*/
@Deprecated
public static String getApplication() {
return
getName();
} | 3.26 |
dubbo_ApplicationModel_getServiceRepository_rdh | /**
*
* @deprecated Replace to {@link ApplicationModel#getApplicationServiceRepository()}
*/
@Deprecated
public static ServiceRepository getServiceRepository() {
return defaultModel().getApplicationServiceRepository();
} | 3.26 |
dubbo_AbstractHttpServer_canHandleIdle_rdh | /**
* Following methods are extended from RemotingServer, useless for http servers
*/
@Override
public boolean canHandleIdle() {
return
false;
} | 3.26 |
dubbo_ConfigurationUtils_getCachedDynamicProperty_rdh | /**
* For compact single instance
*
* @deprecated Replaced to {@link ConfigurationUtils#getCachedDynamicProperty(ScopeModel, String, String)}
*/@Deprecated
public static String getCachedDynamicProperty(String key, String defaultValue) {
return getCachedDynamicProperty(ApplicationModel.defaultModel(), key, defaultValue);
}
/**
* For compact single instance
*
* @deprecated Replaced to {@link ConfigurationUtils#getDynamicProperty(ScopeModel, String)} | 3.26 |
dubbo_ConfigurationUtils_getDynamicConfigurationFactory_rdh | /**
* Get an instance of {@link DynamicConfigurationFactory} by the specified name. If not found, take the default
* extension of {@link DynamicConfigurationFactory}
*
* @param name
* the name of extension of {@link DynamicConfigurationFactory}
* @return non-null
* @see 2.7.4
*/
public static DynamicConfigurationFactory getDynamicConfigurationFactory(ExtensionAccessor extensionAccessor, String name) {
ExtensionLoader<DynamicConfigurationFactory> loader = extensionAccessor.getExtensionLoader(DynamicConfigurationFactory.class);
return loader.getOrDefaultExtension(name);
} | 3.26 |
dubbo_ConfigurationUtils_getDynamicGlobalConfiguration_rdh | /**
* For compact single instance
*
* @deprecated Replaced to {@link ConfigurationUtils#getDynamicGlobalConfiguration(ScopeModel)}
*/
@Deprecated
public static Configuration getDynamicGlobalConfiguration() {
return ApplicationModel.defaultModel().getDefaultModule().modelEnvironment().getDynamicGlobalConfiguration();
} | 3.26 |
dubbo_ConfigurationUtils_getSystemConfiguration_rdh | /**
* For compact single instance
*
* @deprecated Replaced to {@link ConfigurationUtils#getSystemConfiguration(ScopeModel)}
*/
@Deprecated
public static Configuration getSystemConfiguration() {
return ApplicationModel.defaultModel().modelEnvironment().getSystemConfiguration();
} | 3.26 |
dubbo_ConfigurationUtils_get_rdh | /**
* For compact single instance
*
* @deprecated Replaced to {@link ConfigurationUtils#get(ScopeModel, String, int)}
*/
@Deprecated
public static int get(String property, int defaultValue) {
return get(ApplicationModel.defaultModel(), property, defaultValue);} | 3.26 |
dubbo_ConfigurationUtils_getSubProperties_rdh | /**
* Search props and extract sub properties.
* <pre>
* # properties
* dubbo.protocol.name=dubbo
* dubbo.protocol.port=1234
*
* # extract protocol props
* Map props = getSubProperties("dubbo.protocol.");
*
* # result
* props: {"name": "dubbo", "port" : "1234"}
*
* </pre>
*
* @param configMaps
* @param prefix
* @param <V>
* @return */
public static <V extends Object> Map<String, V> getSubProperties(Collection<Map<String, V>> configMaps, String prefix) {
Map<String, V> map = new LinkedHashMap<>();
for (Map<String, V> configMap : configMaps) {
getSubProperties(configMap, prefix, map);
}
return map;
} | 3.26 |
dubbo_ConfigurationUtils_getServerShutdownTimeout_rdh | // FIXME
/**
* Server shutdown wait timeout mills
*
* @return */
@SuppressWarnings("deprecation")
public static int getServerShutdownTimeout(ScopeModel scopeModel) {
if (expectedShutdownTime < System.currentTimeMillis()) {
return 1;
}
int timeout = DEFAULT_SERVER_SHUTDOWN_TIMEOUT;
Configuration configuration = getGlobalConfiguration(scopeModel);
String value = StringUtils.trim(configuration.getString(SHUTDOWN_WAIT_KEY));
if (StringUtils.isNotEmpty(value)) {
try {
timeout = Integer.parseInt(value);
} catch (Exception e) {
// ignore
}
} else {
value = StringUtils.trim(configuration.getString(SHUTDOWN_WAIT_SECONDS_KEY));
if (StringUtils.isNotEmpty(value)) {
try {
timeout = Integer.parseInt(value) * 1000;
} catch (Exception e) {
// ignore
}
}
}
if ((expectedShutdownTime - System.currentTimeMillis()) < timeout) {
return ((int) (Math.max(1, expectedShutdownTime - System.currentTimeMillis())));
}
return timeout;
} | 3.26 |
dubbo_ConfigurationUtils_getDynamicProperty_rdh | /**
* For compact single instance
*
* @deprecated Replaced to {@link ConfigurationUtils#getDynamicProperty(ScopeModel, String, String)}
*/
@Deprecated
public static String getDynamicProperty(String property, String defaultValue) {
return getDynamicProperty(ApplicationModel.defaultModel(), property, defaultValue);
} | 3.26 |
dubbo_ConfigurationUtils_getEnvConfiguration_rdh | /**
* For compact single instance
*
* @deprecated Replaced to {@link ConfigurationUtils#getEnvConfiguration(ScopeModel)}
*/
@Deprecated
public static Configuration getEnvConfiguration() {
return ApplicationModel.defaultModel().modelEnvironment().getEnvironmentConfiguration();
} | 3.26 |
dubbo_ConfigurationUtils_getProperty_rdh | /**
* For compact single instance
*
* @deprecated Replaced to {@link ConfigurationUtils#getProperty(ScopeModel, String, String)}
*/
@Deprecated
public static String getProperty(String property, String defaultValue) {
return getProperty(ApplicationModel.defaultModel(), property, defaultValue);
} | 3.26 |
dubbo_ConfigurationUtils_getGlobalConfiguration_rdh | /**
* For compact single instance
*
* @deprecated Replaced to {@link ConfigurationUtils#getGlobalConfiguration(ScopeModel)}
*/
@Deprecated
public static Configuration getGlobalConfiguration() {
return ApplicationModel.defaultModel().modelEnvironment().getConfiguration();
} | 3.26 |
dubbo_ConfigurationUtils_getSubIds_rdh | /**
* Search props and extract config ids
* <pre>
* # properties
* dubbo.registries.registry1.address=xxx
* dubbo.registries.registry2.port=xxx
*
* # extract ids
* Set configIds = getSubIds("dubbo.registries.")
*
* # result
* configIds: ["registry1", "registry2"]
* </pre>
*
* @param configMaps
* @param prefix
* @return */
public static <V extends Object> Set<String>
getSubIds(Collection<Map<String, V>> configMaps, String prefix) {
if (!prefix.endsWith(".")) {
prefix += ".";
}
Set<String> ids = new LinkedHashSet<>();
for (Map<String, V> configMap : configMaps) {
Map<String, V> copy;
synchronized(configMap) {
copy
= new HashMap<>(configMap);
}
for (Map.Entry<String, V> entry : copy.entrySet()) {
String key = entry.getKey();
V val = entry.getValue();
if ((StringUtils.startsWithIgnoreCase(key, prefix) && (key.length() > prefix.length())) && (!ConfigurationUtils.isEmptyValue(val))) {
String k = key.substring(prefix.length());
int endIndex
= k.indexOf(".");
if (endIndex > 0) {
String id = k.substring(0, endIndex);
ids.add(id);
}
}
}
}
return ids;
} | 3.26 |
dubbo_KubernetesServiceDiscovery_setCurrentHostname_rdh | /**
* UT used only
*/
@Deprecated
public void setCurrentHostname(String currentHostname) {
this.currentHostname = currentHostname;
} | 3.26 |
dubbo_KubernetesServiceDiscovery_doUpdate_rdh | /**
* Comparing to {@link AbstractServiceDiscovery#doUpdate(ServiceInstance, ServiceInstance)}, unregister() is unnecessary here.
*/
@Override
public void doUpdate(ServiceInstance oldServiceInstance, ServiceInstance newServiceInstance) throws RuntimeException {
reportMetadata(newServiceInstance.getServiceMetadata());
this.doRegister(newServiceInstance);
} | 3.26 |
dubbo_NamedThreadFactory_getThreadNum_rdh | // for test
public AtomicInteger getThreadNum() {
return mThreadNum;
} | 3.26 |
dubbo_Page_hasData_rdh | /**
* Returns whether the page has data at all.
*
* @return */
default boolean hasData() {
return getDataSize() > 0;
} | 3.26 |
dubbo_FileCacheStore_getCacheFilePath_rdh | /**
* for unit test only
*/
@Deprecated
protected String getCacheFilePath() {
return cacheFilePath;
} | 3.26 |
dubbo_NettyHttpRestServer_getChildChannelOptionMap_rdh | /**
* create child channel options map
*
* @param url
* @return */
protected Map<ChannelOption, Object> getChildChannelOptionMap(URL url) {
Map<ChannelOption, Object> channelOption = new HashMap<>();
channelOption.put(ChannelOption.SO_KEEPALIVE, url.getParameter(Constants.KEEP_ALIVE_KEY, Constants.DEFAULT_KEEP_ALIVE));
return channelOption;
} | 3.26 |
dubbo_NettyHttpRestServer_getNettyServer_rdh | /**
* for triple override
*
* @return */
protected NettyServer getNettyServer() {
return new NettyServer();
} | 3.26 |
dubbo_NettyHttpRestServer_getChannelOptionMap_rdh | /**
* create channel options map
*
* @param url
* @return */
protected Map<ChannelOption, Object> getChannelOptionMap(URL url) {
Map<ChannelOption, Object> options = new HashMap<>();
options.put(ChannelOption.SO_REUSEADDR, Boolean.TRUE);
options.put(ChannelOption.TCP_NODELAY, Boolean.TRUE);
options.put(ChannelOption.SO_BACKLOG, url.getPositiveParameter(BACKLOG_KEY,
Constants.DEFAULT_BACKLOG));
options.put(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT);
return options;
} | 3.26 |
dubbo_NettyHttpRestServer_getChannelHandlers_rdh | /**
* create channel handler
*
* @param url
* @return */
protected List<ChannelHandler> getChannelHandlers(URL url) {
List<ChannelHandler> channelHandlers = new ArrayList<>();
return channelHandlers;
} | 3.26 |
dubbo_AbstractRegistry_notify_rdh | /**
* Notify changes from the provider side.
*
* @param url
* consumer side url
* @param listener
* listener
* @param urls
* provider latest urls
*/
protected void notify(URL url, NotifyListener listener, List<URL> urls) {
if (url == null) {
throw new IllegalArgumentException("notify url == null");
}
if (listener == null) {
throw new IllegalArgumentException("notify listener == null");
}
if (CollectionUtils.isEmpty(urls) && (!ANY_VALUE.equals(url.getServiceInterface()))) {
// 1-4 Empty address.
logger.warn(REGISTRY_EMPTY_ADDRESS, "", "", "Ignore empty notify urls for subscribe url " + url);
return;
}
if (logger.isInfoEnabled()) {
logger.info((("Notify urls for subscribe url " + url) + ", url size: ") + urls.size());}
// keep every provider's category.
Map<String, List<URL>> result = new HashMap<>();
for (URL u : urls) {
if (UrlUtils.isMatch(url, u)) {
String category = u.getCategory(DEFAULT_CATEGORY);
List<URL> categoryList = result.computeIfAbsent(category, k -> new ArrayList<>());
categoryList.add(u);
}
}
if (result.size() == 0) {
return;
}
Map<String, List<URL>> categoryNotified = notified.computeIfAbsent(url, u -> new ConcurrentHashMap<>());
for (Map.Entry<String, List<URL>> entry : result.entrySet()) {
String category = entry.getKey();
List<URL> categoryList = entry.getValue();
categoryNotified.put(category, categoryList);
listener.notify(categoryList);
// We will update our cache file after each notification.
// When our Registry has a subscribed failure due to network jitter, we can return at least the existing
// cache URL.
if (localCacheEnabled) {
saveProperties(url);
}
}
} | 3.26 |
dubbo_SharedClientsProvider_closeReferenceCountExchangeClient_rdh | /**
* close ReferenceCountExchangeClient
*
* @param client
*/
private void closeReferenceCountExchangeClient(ReferenceCountExchangeClient client) {
if (client == null) {
return;
}
try {
if (logger.isInfoEnabled()) {
logger.info((("Close dubbo connect: " + client.getLocalAddress()) + "-->") + client.getRemoteAddress());
}
client.close(ConfigurationUtils.reCalShutdownTime(client.getShutdownWaitTime()));
// TODO
/* At this time, ReferenceCountExchangeClient#client has been replaced with LazyConnectExchangeClient.
Do you need to call client.close again to ensure that LazyConnectExchangeClient is also closed?
*/
} catch (Throwable t) {
logger.warn(PROTOCOL_ERROR_CLOSE_CLIENT, "", "", t.getMessage(), t);
}
} | 3.26 |
dubbo_SharedClientsProvider_checkClientCanUse_rdh | /**
* Check if the client list is all available
*
* @param referenceCountExchangeClients
* @return true-available,false-unavailable
*/
private boolean checkClientCanUse(List<ReferenceCountExchangeClient> referenceCountExchangeClients) {
if (CollectionUtils.isEmpty(referenceCountExchangeClients)) {
return false;
}
// As long as one client is not available, you need to replace the unavailable client with the available one.
return referenceCountExchangeClients.stream().noneMatch(referenceCountExchangeClient -> ((referenceCountExchangeClient == null) || (referenceCountExchangeClient.getCount() <= 0)) || referenceCountExchangeClient.isClosed());
} | 3.26 |
dubbo_SharedClientsProvider_batchClientRefIncr_rdh | /**
* Increase the reference Count if we create new invoker shares same connection, the connection will be closed without any reference.
*
* @param referenceCountExchangeClients
*/
private void batchClientRefIncr(List<ReferenceCountExchangeClient> referenceCountExchangeClients) {
if (CollectionUtils.isEmpty(referenceCountExchangeClients)) {
return;
}
referenceCountExchangeClients.stream().filter(Objects::nonNull).forEach(ReferenceCountExchangeClient::incrementAndGetCount);
} | 3.26 |
dubbo_MeshAppRuleListener_getMeshRuleDispatcher_rdh | /**
* For ut only
*/
@Deprecated
public MeshRuleDispatcher getMeshRuleDispatcher() {
return meshRuleDispatcher;} | 3.26 |
dubbo_ReferenceBeanBuilder_setInjvm_rdh | /**
*
* @param injvm
* @deprecated instead, use the parameter <b>scope</b> to judge if it's in jvm, scope=local
*/
@Deprecated
public ReferenceBeanBuilder setInjvm(Boolean injvm) {
attributes.put(ReferenceAttributes.INJVM, injvm);
return this;} | 3.26 |
dubbo_ReferenceBeanBuilder_setRegistry_rdh | // @Deprecated
// public ReferenceBeanBuilder setApplication(ApplicationConfig application) {
// attributes.put(ReferenceAttributes.APPLICATION, application);
// return this;
// }
// @Deprecated
// public ReferenceBeanBuilder setModule(ModuleConfig module) {
// attributes.put(ReferenceAttributes.MODULE, module);
// return this;
// }
public ReferenceBeanBuilder setRegistry(String[] registryIds) {
attributes.put(ReferenceAttributes.REGISTRY, registryIds);
return this;
} | 3.26 |
dubbo_ReferenceBeanBuilder_setStub_rdh | // public ReferenceBeanBuilder setRouter(String router) {
// attributes.put(ReferenceAttributes.ROUTER, router);
// return this;
// }
public ReferenceBeanBuilder setStub(String stub) {
attributes.put(ReferenceAttributes.STUB, stub);
return this;
} | 3.26 |
dubbo_MockInvoker_normalizeMock_rdh | /**
* Normalize mock string:
*
* <ol>
* <li>return => return null</li>
* <li>fail => default</li>
* <li>force => default</li>
* <li>fail:throw/return foo => throw/return foo</li>
* <li>force:throw/return foo => throw/return foo</li>
* </ol>
*
* @param mock
* mock string
* @return normalized mock string
*/
public static String normalizeMock(String mock) {
if (mock == null) {
return mock;
}
mock = mock.trim();
if (mock.length() == 0) {
return mock;
}
if (RETURN_KEY.equalsIgnoreCase(mock)) {
return RETURN_PREFIX + "null";
}
if ((ConfigUtils.isDefault(mock) || "fail".equalsIgnoreCase(mock)) || "force".equalsIgnoreCase(mock)) {
return "default";
}
if (mock.startsWith(FAIL_PREFIX)) {
mock = mock.substring(FAIL_PREFIX.length()).trim();
}
if (mock.startsWith(FORCE_PREFIX)) {
mock
= mock.substring(FORCE_PREFIX.length()).trim();
}
if (mock.startsWith(RETURN_PREFIX) || mock.startsWith(THROW_PREFIX)) {
mock = mock.replace('`', '"');
}
return mock;
} | 3.26 |
dubbo_ProtocolBuilder_path_rdh | /**
*
* @param path
* @return ProtocolBuilder
* @see ProtocolBuilder#contextpath(String)
*/
@Deprecated
public ProtocolBuilder path(String path) {
this.contextpath = path;
return getThis();
} | 3.26 |
dubbo_ProtocolBuilder_dispather_rdh | /**
*
* @param dispather
* @return ProtocolBuilder
* @see ProtocolBuilder#dispatcher(String)
*/
@Deprecated
public ProtocolBuilder dispather(String dispather) {
this.dispatcher = dispather;
return getThis();
} | 3.26 |
dubbo_RestRPCInvocationUtil_parseMethodArgs_rdh | /**
* service method real args parse
*
* @param rpcInvocation
* @param request
* @param servletRequest
* @param servletResponse
* @param restMethodMetadata
*/
public static void parseMethodArgs(RpcInvocation rpcInvocation, RequestFacade request, Object servletRequest, Object servletResponse, RestMethodMetadata restMethodMetadata) {
try {
ProviderParseContext parseContext = createParseContext(request, servletRequest,
servletResponse, restMethodMetadata);
Object[] args = ParamParserManager.providerParamParse(parseContext);
List<ArgInfo> argInfos = parseContext.getArgInfos();
for (ArgInfo argInfo : argInfos) {
// TODO set default value
if (argInfo.getParamType().isPrimitive() && (args[argInfo.getIndex()] == null)) {
throw new
ParamParseException((((("\n dubbo provider primitive arg not exist in request, method is: " + restMethodMetadata.getReflectMethod()) + "\n type is: ") + argInfo.getParamType()) + " \n and arg index is: ") + argInfo.getIndex());
}
}
rpcInvocation.setArguments(args);
} catch (Exception e) {
logger.error("", e.getMessage(), "", "dubbo rest provider method args parse error: ", e);
throw new ParamParseException(e.getMessage());
}
} | 3.26 |
dubbo_RestRPCInvocationUtil_getInvoker_rdh | /**
* get invoker by path matcher
*
* @param pathMatcher
* @return */
public static Invoker getInvoker(PathMatcher pathMatcher, ServiceDeployer serviceDeployer) {
InvokerAndRestMethodMetadataPair pair = getRestMethodMetadataAndInvokerPair(pathMatcher, serviceDeployer);
if (pair == null) {
return null;
}
return pair.getInvoker();
} | 3.26 |
dubbo_RestRPCInvocationUtil_getInvokerByRequest_rdh | /**
* get invoker by request
*
* @param request
* @return */
public static Invoker getInvokerByRequest(RequestFacade request) {
PathMatcher pathMatcher = createPathMatcher(request);
return getInvoker(pathMatcher, request.getServiceDeployer());
} | 3.26 |
dubbo_RestRPCInvocationUtil_getInvokerByServiceInvokeMethod_rdh | /**
* get invoker by service method
* <p>
* compare method`s name,param types
*
* @param serviceMethod
* @return */
public static Invoker getInvokerByServiceInvokeMethod(Method serviceMethod, ServiceDeployer serviceDeployer) {if (serviceMethod == null) {
return null;
}
PathMatcher pathMatcher = PathMatcher.getInvokeCreatePathMatcher(serviceMethod);
InvokerAndRestMethodMetadataPair pair = getRestMethodMetadataAndInvokerPair(pathMatcher, serviceDeployer);
if (pair == null) {
return null;
}
return pair.getInvoker();
} | 3.26 |
dubbo_RestRPCInvocationUtil_getRestMethodMetadataAndInvokerPair_rdh | /**
* get InvokerAndRestMethodMetadataPair from rpc context
*
* @param request
* @return */
public static InvokerAndRestMethodMetadataPair getRestMethodMetadataAndInvokerPair(RequestFacade request) {
PathMatcher pathMather = createPathMatcher(request);
return getRestMethodMetadataAndInvokerPair(pathMather, request.getServiceDeployer());} | 3.26 |
dubbo_RestRPCInvocationUtil_createParseContext_rdh | /**
* create parseMethodArgs context
*
* @param request
* @param originRequest
* @param originResponse
* @param restMethodMetadata
* @return */
private static ProviderParseContext createParseContext(RequestFacade request, Object originRequest, Object originResponse, RestMethodMetadata restMethodMetadata) {
ProviderParseContext parseContext = new ProviderParseContext(request);
parseContext.setResponse(originResponse);parseContext.setRequest(originRequest);
Object[] objects = new Object[restMethodMetadata.getArgInfos().size()];
parseContext.setArgs(Arrays.asList(objects));
parseContext.setArgInfos(restMethodMetadata.getArgInfos());
return
parseContext;
} | 3.26 |
dubbo_RestRPCInvocationUtil_createPathMatcher_rdh | /**
* create path matcher by request
*
* @param request
* @return */
public static PathMatcher createPathMatcher(RequestFacade request) {
String path = request.getPath();
String version = request.getHeader(RestHeaderEnum.VERSION.getHeader());
String group = request.getHeader(RestHeaderEnum.GROUP.getHeader());
String method = request.getMethod();
return PathMatcher.getInvokeCreatePathMatcher(path, version, group, null, method);
} | 3.26 |
dubbo_RestRPCInvocationUtil_createBaseRpcInvocation_rdh | /**
* build RpcInvocation
*
* @param request
* @param restMethodMetadata
* @return */public static RpcInvocation createBaseRpcInvocation(RequestFacade request, RestMethodMetadata restMethodMetadata) {
RpcInvocation rpcInvocation = new RpcInvocation();
rpcInvocation.setParameterTypes(restMethodMetadata.getReflectMethod().getParameterTypes());
rpcInvocation.setReturnType(restMethodMetadata.getReflectMethod().getReturnType());
rpcInvocation.setMethodName(restMethodMetadata.getMethod().getName());
// TODO set protocolServiceKey ,but no set method
//
HttpHeaderUtil.parseRequest(rpcInvocation, request);
String serviceKey = BaseServiceMetadata.buildServiceKey(request.getHeader(RestHeaderEnum.PATH.getHeader()), request.getHeader(RestHeaderEnum.GROUP.getHeader()), request.getHeader(RestHeaderEnum.VERSION.getHeader()));
rpcInvocation.setTargetServiceUniqueName(serviceKey);
return rpcInvocation;
} | 3.26 |
dubbo_MessageFormatter_deeplyAppendParameter_rdh | // special treatment of array values was suggested by 'lizongbo'
private static void deeplyAppendParameter(StringBuffer sbuf, Object o, Map<Object[], Void> seenMap) {
if (o == null) {
sbuf.append("null");
return;
}
if (!o.getClass().isArray()) {
safeObjectAppend(sbuf, o);
} else // check for primitive array types because they
// unfortunately cannot be cast to Object[]
if (o instanceof boolean[]) {booleanArrayAppend(sbuf, ((boolean[]) (o)));} else if (o instanceof byte[]) {
byteArrayAppend(sbuf, ((byte[]) (o)));
} else if (o instanceof char[]) {
charArrayAppend(sbuf, ((char[]) (o)));
} else if (o instanceof short[]) {
shortArrayAppend(sbuf, ((short[]) (o)));
} else if (o instanceof int[]) {
intArrayAppend(sbuf, ((int[]) (o)));
} else if (o instanceof long[]) {
longArrayAppend(sbuf, ((long[]) (o)));
} else if (o instanceof float[]) {
floatArrayAppend(sbuf, ((float[]) (o)));
} else if (o instanceof double[]) {
doubleArrayAppend(sbuf, ((double[]) (o)));
} else {
objectArrayAppend(sbuf, ((Object[]) (o)), seenMap);
}
} | 3.26 |
dubbo_MessageFormatter_arrayFormat_rdh | /**
* Same principle as the {@link #format(String, Object)} and
* {@link #format(String, Object, Object)} methods except that any number of
* arguments can be passed in an array.
*
* @param messagePattern
* The message pattern which will be parsed and formatted
* @param argArray
* An array of arguments to be substituted in place of formatting
* anchors
* @return The formatted message
*/
static FormattingTuple arrayFormat(final String messagePattern, final Object[] argArray) {
Throwable throwableCandidate = getThrowableCandidate(argArray);
if (messagePattern == null) {
return new FormattingTuple(null, argArray, throwableCandidate);
}
if (argArray == null) {
return new FormattingTuple(messagePattern);}
int i = 0;
int j;
StringBuffer sbuf =
new StringBuffer(messagePattern.length() + 50);
int l;
for (l = 0; l < argArray.length; l++) {
j = messagePattern.indexOf(DELIM_STR, i);
if (j == (-1)) {
// no more variables
if (i == 0) {
// this is a simple string
return new FormattingTuple(messagePattern, argArray, throwableCandidate);
} else {
// add the tail string which contains no variables and return
// the result.
sbuf.append(messagePattern.substring(i));
return new FormattingTuple(sbuf.toString(), argArray, throwableCandidate);
}
} else if (isEscapedDelimeter(messagePattern, j)) {
if (!isDoubleEscaped(messagePattern, j)) {
l--;// DELIM_START was escaped, thus should not be incremented
sbuf.append(messagePattern, i, j - 1);
sbuf.append(DELIM_START);
i = j + 1;
} else {
// The escape character preceding the delimiter start is
// itself escaped: "abc x:\\{}"
// we have to consume one backward slash
sbuf.append(messagePattern, i, j - 1);
deeplyAppendParameter(sbuf,
argArray[l], new HashMap<Object[], Void>());
i = j + 2;}
} else {
// normal case
sbuf.append(messagePattern, i, j);
deeplyAppendParameter(sbuf, argArray[l], new HashMap<Object[], Void>());
i = j + 2;
}
}
// append the characters following the last {} pair.
sbuf.append(messagePattern.substring(i));
if (l < (argArray.length - 1)) {
return new
FormattingTuple(sbuf.toString(), argArray, throwableCandidate);
} else {
return new FormattingTuple(sbuf.toString(), argArray,
null);
}
} | 3.26 |
dubbo_MessageFormatter_format_rdh | /**
* Performs a two argument substitution for the 'messagePattern' passed as
* parameter.
* <p/>
* For example,
* <p/>
* <pre>
* MessageFormatter.format("Hi {}. My name is {}.", "Alice", "Bob");
* </pre>
* <p/>
* will return the string "Hi Alice. My name is Bob.".
*
* @param messagePattern
* The message pattern which will be parsed and formatted
* @param argA
* The argument to be substituted in place of the first formatting
* anchor
* @param argB
* The argument to be substituted in place of the second formatting
* anchor
* @return The formatted message
*/
static FormattingTuple format(final String messagePattern, Object argA, Object argB) {
return arrayFormat(messagePattern, new Object[]{ argA, argB });
} | 3.26 |
dubbo_MetricsApplicationListener_onPostEventBuild_rdh | /**
* Perform auto-increment on the monitored key,
* Can use a custom listener instead of this generic operation
*
* @param metricsKey
* Monitor key
* @param collector
* Corresponding collector
*/
public static AbstractMetricsKeyListener onPostEventBuild(MetricsKey metricsKey, CombMetricsCollector<?> collector) {
return AbstractMetricsKeyListener.onEvent(metricsKey, event -> collector.increment(metricsKey));
} | 3.26 |
dubbo_MetricsApplicationListener_onFinishEventBuild_rdh | /**
* To end the monitoring normally, in addition to increasing the number of corresponding indicators,
* use the introspection method to calculate the relevant rt indicators
*
* @param metricsKey
* Monitor key
* @param collector
* Corresponding collector
*/
public static AbstractMetricsKeyListener onFinishEventBuild(MetricsKey metricsKey, MetricsPlaceValue placeType, CombMetricsCollector<?> collector) {
return AbstractMetricsKeyListener.onFinish(metricsKey, event -> {
collector.increment(metricsKey);
collector.addApplicationRt(placeType.getType(), event.getTimePair().calc());
});
} | 3.26 |
dubbo_MetricsApplicationListener_onErrorEventBuild_rdh | /**
* Similar to onFinishEventBuild
*/
public static AbstractMetricsKeyListener onErrorEventBuild(MetricsKey metricsKey, MetricsPlaceValue placeType, CombMetricsCollector<?> collector) {
return AbstractMetricsKeyListener.onError(metricsKey, event -> {
collector.increment(metricsKey);
collector.addApplicationRt(placeType.getType(), event.getTimePair().calc());
});
} | 3.26 |
dubbo_AbstractServerCall_buildInvocation_rdh | /**
* Build the RpcInvocation with metadata and execute headerFilter
*
* @return RpcInvocation
*/
protected RpcInvocation buildInvocation(MethodDescriptor methodDescriptor) {
final URL url = invoker.getUrl();
RpcInvocation inv = new RpcInvocation(url.getServiceModel(), methodDescriptor.getMethodName(), serviceDescriptor.getInterfaceName(), url.getProtocolServiceKey(), methodDescriptor.getParameterClasses(), new Object[0]);
inv.setTargetServiceUniqueName(url.getServiceKey());
inv.setReturnTypes(methodDescriptor.getReturnTypes());
inv.setObjectAttachments(StreamUtils.toAttachments(requestMetadata));
inv.put(REMOTE_ADDRESS_KEY, stream.remoteAddress());
// handle timeout
String timeout = ((String) (requestMetadata.get(TripleHeaderEnum.TIMEOUT.getHeader())));
try {
if (Objects.nonNull(timeout)) {
this.timeout = parseTimeoutToMills(timeout);
}
} catch (Throwable t) {
LOGGER.warn(PROTOCOL_FAILED_PARSE, "", "", String.format("Failed to parse request timeout set from:%s, service=%s " + "method=%s", timeout, serviceDescriptor.getInterfaceName(), methodName));
}
if (null != requestMetadata.get(TripleHeaderEnum.CONSUMER_APP_NAME_KEY.getHeader())) {
inv.put(TripleHeaderEnum.CONSUMER_APP_NAME_KEY, requestMetadata.get(TripleHeaderEnum.CONSUMER_APP_NAME_KEY.getHeader()));
}
return inv; } | 3.26 |
dubbo_AbstractServerCall_responseErr_rdh | /**
* Error in create stream, unsupported config or triple protocol error.
*
* @param status
* response status
*/
protected void responseErr(TriRpcStatus status) {
if (closed) {
return;
}
closed = true;
stream.complete(status, null, false, CommonConstants.TRI_EXCEPTION_CODE_NOT_EXISTS);
LOGGER.error(PROTOCOL_FAILED_REQUEST, "", "", (("Triple request error: service=" + serviceName) + " method") + methodName, status.asException());
} | 3.26 |
dubbo_JValidator_createMemberValue_rdh | // Copy from javassist.bytecode.annotation.Annotation.createMemberValue(ConstPool, CtClass);
private static MemberValue createMemberValue(ConstPool cp, CtClass type, Object value) throws NotFoundException {MemberValue memberValue = annotation.Annotation.createMemberValue(cp, type);
if (memberValue instanceof BooleanMemberValue)
{
((BooleanMemberValue) (memberValue)).setValue(((Boolean) (value)));
} else if (memberValue instanceof ByteMemberValue) {
((ByteMemberValue) (memberValue)).setValue(((Byte) (value)));
} else if (memberValue instanceof CharMemberValue) {
((CharMemberValue) (memberValue)).setValue(((Character) (value)));
} else if (memberValue instanceof ShortMemberValue) {((ShortMemberValue) (memberValue)).setValue(((Short) (value)));
} else if (memberValue instanceof IntegerMemberValue) {
((IntegerMemberValue) (memberValue)).setValue(((Integer) (value)));
} else if (memberValue instanceof LongMemberValue) {
((LongMemberValue) (memberValue)).setValue(((Long) (value)));
} else if (memberValue instanceof FloatMemberValue) {
((FloatMemberValue) (memberValue)).setValue(((Float) (value)));} else if
(memberValue instanceof DoubleMemberValue) {
((DoubleMemberValue) (memberValue)).setValue(((Double) (value)));
} else if (memberValue
instanceof ClassMemberValue) {
((ClassMemberValue) (memberValue)).setValue(((Class<?>) (value)).getName());
} else if (memberValue instanceof StringMemberValue) {
((StringMemberValue) (memberValue)).setValue(((String) (value)));
} else if (memberValue instanceof EnumMemberValue) {
((EnumMemberValue)
(memberValue)).setValue(((Enum<?>) (value)).name());
} else if (memberValue instanceof ArrayMemberValue) {
CtClass arrayType = type.getComponentType();
int len = Array.getLength(value);
MemberValue[] members = new MemberValue[len];
for (int i = 0; i < len; i++) {
members[i] = createMemberValue(cp,
arrayType, Array.get(value, i));
}
((ArrayMemberValue) (memberValue)).setValue(members);
}
return memberValue;
} | 3.26 |
dubbo_JValidator_generateMethodParameterClass_rdh | /**
* try to generate methodParameterClass.
*
* @param clazz
* interface class
* @param method
* invoke method
* @param parameterClassName
* generated parameterClassName
* @return Class<?> generated methodParameterClass
*/
private static Class<?> generateMethodParameterClass(Class<?> clazz, Method method, String parameterClassName) throws Exception {
ClassPool pool = ClassGenerator.getClassPool(clazz.getClassLoader());
synchronized(parameterClassName.intern()) {
CtClass ctClass = null;
try {
ctClass
= pool.getCtClass(parameterClassName);
} catch (NotFoundException ignore) {
}
if (null == ctClass) {
ctClass = pool.makeClass(parameterClassName);
ClassFile classFile = ctClass.getClassFile();
ctClass.addConstructor(CtNewConstructor.defaultConstructor(pool.getCtClass(parameterClassName)));
// parameter fields
Parameter[] parameters = method.getParameters();
Annotation[][] parameterAnnotations = method.getParameterAnnotations();
for (int i = 0; i < parameters.length; i++) {
Annotation[] annotations = parameterAnnotations[i];
AnnotationsAttribute attribute = new AnnotationsAttribute(classFile.getConstPool(), AnnotationsAttribute.visibleTag);
for (Annotation annotation : annotations) {if (annotation.annotationType().isAnnotationPresent(Constraint.class)) { Annotation ja = new Annotation(classFile.getConstPool(), pool.getCtClass(annotation.annotationType().getName()));Method[] members = annotation.annotationType().getMethods();
for (Method member : members) {
if ((Modifier.isPublic(member.getModifiers()) && (member.getParameterTypes().length == 0)) && (member.getDeclaringClass() == annotation.annotationType())) {
Object value = member.invoke(annotation);
if (null != value) {
MemberValue memberValue = createMemberValue(classFile.getConstPool(), pool.get(member.getReturnType().getName()), value);
ja.addMemberValue(member.getName(), memberValue);
}
}
}
attribute.addAnnotation(ja);
}
}
Parameter parameter = parameters[i];
Class<?> type = parameter.getType();
String
fieldName = parameter.getName();
CtField ctField = CtField.make(((("public " + type.getCanonicalName()) + " ") + fieldName) +
";", pool.getCtClass(parameterClassName)); ctField.getFieldInfo().addAttribute(attribute);
ctClass.addField(ctField);
}
return pool.toClass(ctClass, clazz, clazz.getClassLoader(), clazz.getProtectionDomain());
} else {
return Class.forName(parameterClassName, true, clazz.getClassLoader());
}
}
} | 3.26 |
dubbo_ServiceDiscoveryRegistry_createServiceDiscovery_rdh | /**
* Create the {@link ServiceDiscovery} from the registry {@link URL}
*
* @param registryURL
* the {@link URL} to connect the registry
* @return non-null
*/
protected ServiceDiscovery createServiceDiscovery(URL registryURL) { return getServiceDiscovery(registryURL.addParameter(INTERFACE_KEY, ServiceDiscovery.class.getName()).removeParameter(REGISTRY_TYPE_KEY));
}
/**
* Get the instance {@link ServiceDiscovery} from the registry {@link URL} using
* {@link ServiceDiscoveryFactory} SPI
*
* @param registryURL
* the {@link URL} | 3.26 |
dubbo_ServiceDiscoveryRegistry_supports_rdh | /**
* Supports or not ?
*
* @param registryURL
* the {@link URL url} of registry
* @return if supported, return <code>true</code>, or <code>false</code>
*/
public static boolean supports(URL registryURL) {
return SERVICE_REGISTRY_TYPE.equalsIgnoreCase(registryURL.getParameter(REGISTRY_TYPE_KEY));
} | 3.26 |
dubbo_StringToDurationConverter_detectAndParse_rdh | /**
* Detect the style then parse the value to return a duration.
*
* @param value
* the value to parse
* @return the parsed duration
* @throws IllegalArgumentException
* if the value is not a known style or cannot be
* parsed
*/
public static Duration detectAndParse(String value) {
return detectAndParse(value, null);
}
/**
* Detect the style then parse the value to return a duration.
*
* @param value
* the value to parse
* @param unit
* the duration unit to use if the value doesn't specify one ({@code null} | 3.26 |
dubbo_StringToDurationConverter_parse_rdh | /**
* Parse the given value to a duration.
*
* @param value
* the value to parse
* @return a duration
*/public Duration parse(String value) {
return parse(value,
null);
} | 3.26 |
dubbo_StringToDurationConverter_detect_rdh | /**
* Detect the style from the given source value.
*
* @param value
* the source value
* @return the duration style
* @throws IllegalArgumentException
* if the value is not a known style
*/
public static DurationStyle detect(String value) {
Assert.notNull(value, "Value must not be null");
for (DurationStyle candidate : values()) {
if (candidate.matches(value)) {
return candidate;
}
}throw new IllegalArgumentException(("'" + value) + "' is not a valid duration");
} | 3.26 |
dubbo_AbstractAnnotationBeanPostProcessor_prepareInjection_rdh | /**
* Prepare injection data after found injection elements
*
* @param metadata
* @throws Exception
*/
protected void prepareInjection(AnnotatedInjectionMetadata metadata) throws Exception {
} | 3.26 |
dubbo_AbstractAnnotationBeanPostProcessor_getInjectedObject_rdh | /**
* Get injected-object from specified {@link AnnotationAttributes annotation attributes} and Bean Class
*
* @param attributes
* {@link AnnotationAttributes the annotation attributes}
* @param bean
* Current bean that will be injected
* @param beanName
* Current bean name that will be injected
* @param injectedType
* the type of injected-object
* @param injectedElement
* {@link AnnotatedInjectElement}
* @return An injected object
* @throws Exception
* If getting is failed
*/
protected Object getInjectedObject(AnnotationAttributes attributes, Object bean, String beanName, Class<?> injectedType, AnnotatedInjectElement injectedElement)
throws Exception {
return doGetInjectedBean(attributes, bean, beanName, injectedType, injectedElement);
} | 3.26 |
dubbo_AbstractAnnotationBeanPostProcessor_findFieldAnnotationMetadata_rdh | /**
* Finds {@link InjectionMetadata.InjectedElement} Metadata from annotated fields
*
* @param beanClass
* The {@link Class} of Bean
* @return non-null {@link List}
*/
private List<AbstractAnnotationBeanPostProcessor.AnnotatedFieldElement> findFieldAnnotationMetadata(final Class<?> beanClass) {
final List<AbstractAnnotationBeanPostProcessor.AnnotatedFieldElement> elements = new LinkedList<>();
ReflectionUtils.doWithFields(beanClass, field -> {
for (Class<? extends Annotation> annotationType : getAnnotationTypes()) {
AnnotationAttributes attributes = AnnotationUtils.getAnnotationAttributes(field, annotationType, getEnvironment(), true, true);
if (attributes != null) {
if (Modifier.isStatic(field.getModifiers())) {
if (logger.isWarnEnabled()) {
logger.warn(CONFIG_DUBBO_BEAN_INITIALIZER, "", "", (("@" +
annotationType.getName()) + " is not supported on static fields: ") + field);
}
return;
}
elements.add(new AnnotatedFieldElement(field, attributes));
}
}
});
return elements;
} | 3.26 |
dubbo_AbstractAnnotationBeanPostProcessor_findAnnotatedMethodMetadata_rdh | /**
* Finds {@link InjectionMetadata.InjectedElement} Metadata from annotated methods
*
* @param beanClass
* The {@link Class} of Bean
* @return non-null {@link List}
*/
private List<AbstractAnnotationBeanPostProcessor.AnnotatedMethodElement> findAnnotatedMethodMetadata(final Class<?> beanClass) {
final List<AbstractAnnotationBeanPostProcessor.AnnotatedMethodElement> elements = new LinkedList<>();
ReflectionUtils.doWithMethods(beanClass, method -> {
Method bridgedMethod = findBridgedMethod(method);
if (!isVisibilityBridgeMethodPair(method, bridgedMethod)) {
return;
}
if (method.getAnnotation(Bean.class) != null) {
// DO NOT inject to Java-config class's @Bean method
return;
}
for (Class<? extends Annotation> annotationType : getAnnotationTypes()) {
AnnotationAttributes attributes = AnnotationUtils.getAnnotationAttributes(bridgedMethod, annotationType, getEnvironment(), true, true);
if ((attributes != null) && method.equals(ClassUtils.getMostSpecificMethod(method, beanClass))) {
if (Modifier.isStatic(method.getModifiers())) {
throw new IllegalStateException((("When using @" + annotationType.getName()) + " to inject interface proxy, it is not supported on static methods: ")
+ method);
}
if (method.getParameterTypes().length != 1) {
throw new
IllegalStateException((("When using @" + annotationType.getName()) + " to inject interface proxy, the method must have only one parameter: ") + method);
}
PropertyDescriptor pd = BeanUtils.findPropertyForMethod(bridgedMethod, beanClass);
elements.add(new AnnotatedMethodElement(method, pd, attributes));
}
}
});
return elements;
} | 3.26 |
dubbo_AbstractAnnotationBeanPostProcessor_needsRefreshInjectionMetadata_rdh | // Use custom check method to compatible with Spring 4.x
private boolean needsRefreshInjectionMetadata(AnnotatedInjectionMetadata metadata, Class<?> clazz) {
return (metadata == null) || metadata.needsRefresh(clazz);
} | 3.26 |
dubbo_AbstractProxyProtocol_isBound_rdh | /**
*
* @return */
@Overridepublic boolean isBound()
{
return false;
} | 3.26 |
dubbo_AbstractProxyProtocol_destroyInternal_rdh | // used to destroy unused clients and other resource
protected void destroyInternal(URL url) {
// subclass override
} | 3.26 |
dubbo_FixedParamValue_getN_rdh | /**
* DEFAULT value will be returned if n = 0
*
* @param n
*/
@Override
public String getN(int n) {
return values[n];
} | 3.26 |
dubbo_MetricsSupport_fillZero_rdh | /**
* Generate a complete indicator item for an interface/method
*/
public static <T> void fillZero(Map<?, Map<T, AtomicLong>> data) {
if (CollectionUtils.isEmptyMap(data)) {
return;
}
Set<T> allKeyMetrics = data.values().stream().flatMap(map -> map.keySet().stream()).collect(Collectors.toSet());
data.forEach((keyWrapper, mapVal) -> {
for (T key : allKeyMetrics)
{
mapVal.computeIfAbsent(key, k -> new AtomicLong(0));
}
});
} | 3.26 |
dubbo_MetricsSupport_incrAndAddRt_rdh | /**
* Incr method num&&rt
*/
public static void incrAndAddRt(MetricsKey metricsKey, MetricsPlaceValue
placeType, MethodMetricsCollector<TimeCounterEvent> collector, TimeCounterEvent event) {
collector.increment(event.getAttachmentValue(METHOD_METRICS), new MetricsKeyWrapper(metricsKey, placeType), SELF_INCREMENT_SIZE);
collector.addMethodRt(event.getAttachmentValue(INVOCATION), placeType.getType(), event.getTimePair().calc());} | 3.26 |
dubbo_MetricsSupport_increment_rdh | /**
* Incr method num
*/
public static void increment(MetricsKey metricsKey, MetricsPlaceValue placeType, MethodMetricsCollector<TimeCounterEvent> collector, MetricsEvent event) {
collector.increment(event.getAttachmentValue(METHOD_METRICS), new MetricsKeyWrapper(metricsKey, placeType), SELF_INCREMENT_SIZE);
} | 3.26 |
dubbo_AccessLogFilter_invoke_rdh | /**
* This method logs the access log for service method invocation call.
*
* @param invoker
* service
* @param inv
* Invocation service method.
* @return Result from service method.
* @throws RpcException
*/
@Override
public Result invoke(Invoker<?> invoker, Invocation inv) throws RpcException {
String v0 = invoker.getUrl().getParameter(Constants.ACCESS_LOG_KEY);
boolean isFixedPath = invoker.getUrl().getParameter(ACCESS_LOG_FIXED_PATH_KEY, true);
if (StringUtils.isEmpty(v0)) {
// Notice that disable accesslog of one service may cause the whole application to stop collecting
// accesslog.
// It's recommended to use application level configuration to enable or disable accesslog if dynamically
// configuration is needed .
if ((future != null) && (!future.isCancelled())) {
future.cancel(true);
logger.info("Access log task cancelled ...");
}
return invoker.invoke(inv);}
if (scheduled.compareAndSet(false, true)) {
future = inv.getModuleModel().getApplicationModel().getFrameworkModel().getBeanFactory().getBean(FrameworkExecutorRepository.class).getSharedScheduledExecutor().scheduleWithFixedDelay(new AccesslogRefreshTask(isFixedPath), LOG_OUTPUT_INTERVAL, LOG_OUTPUT_INTERVAL, TimeUnit.MILLISECONDS);
logger.info("Access log task started ...");
}
Optional<AccessLogData> optionalAccessLogData = Optional.empty();
try {
optionalAccessLogData = Optional.of(buildAccessLogData(invoker, inv));} catch (Throwable t) {
logger.warn(CONFIG_FILTER_VALIDATION_EXCEPTION, "", "", ((("Exception in AccessLogFilter of service(" + invoker) + " -> ") + inv) + ")", t);
}
try {
return invoker.invoke(inv);
} finally {
String finalAccessLogKey = v0;
optionalAccessLogData.ifPresent(logData -> {
logData.setOutTime(new Date());
log(finalAccessLogKey, logData, isFixedPath);
});
}
} | 3.26 |
dubbo_AccessLogFilter_destroy_rdh | // test purpose only
public void destroy() {
future.cancel(true);
} | 3.26 |
dubbo_SpringCompatUtils_getGenericTypeOfReturnType_rdh | /**
* Get the generic type of return type of the method.
*
* <pre>
* Source method:
* ReferenceBean<DemoService> demoService()
*
* Result: DemoService.class
* </pre>
*
* @param factoryMethodMetadata
* @return */
public static Class getGenericTypeOfReturnType(MethodMetadata factoryMethodMetadata) {
if (factoryMethodMetadata instanceof StandardMethodMetadata) {
Method introspectedMethod = ((StandardMethodMetadata) (factoryMethodMetadata)).getIntrospectedMethod();
Type v9 = introspectedMethod.getGenericReturnType();
if (v9 instanceof ParameterizedType) {
ParameterizedType parameterizedType = ((ParameterizedType) (v9));
Type actualTypeArgument = parameterizedType.getActualTypeArguments()[0];
if (actualTypeArgument instanceof Class) {
return ((Class) (actualTypeArgument));
}
}
}
return null;
} | 3.26 |
dubbo_TypeDefinition_formatType_rdh | /**
* Format the {@link String} presenting Java type
*
* @param type
* the String presenting type
* @return new String presenting Java type after be formatted
* @since 2.7.9
*/
public static String formatType(String type) {
if (isGenericType(type)) {
return formatGenericType(type);
}
return type;
} | 3.26 |
dubbo_TypeDefinition_formatTypes_rdh | /**
* Format the {@link String} array presenting Java types
*
* @param types
* the strings presenting Java types
* @return new String array of Java types after be formatted
* @since 2.7.9
*/
public static String[] formatTypes(String[] types) {
String[] newTypes = new String[types.length];
for (int i = 0; i < types.length; i++) {
newTypes[i] = formatType(types[i]);
}
return newTypes;
} | 3.26 |
dubbo_TypeDefinition_formatGenericType_rdh | /**
* Replacing <code>", "</code> to <code>","</code> will not change the semantic of
* {@link ParameterizedType#toString()}
*
* @param type
* @return formatted type
* @see sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl
*/
private static String formatGenericType(String type) {
return replace(type, ", ", ",");
} | 3.26 |
dubbo_Parameters_getExtension_rdh | /**
*
* @deprecated will be removed in 3.3.0
*/
@Deprecated
public <T> T getExtension(Class<T> type, String key, String defaultValue) {
String name = getParameter(key, defaultValue);
return ExtensionLoader.getExtensionLoader(type).getExtension(name);
} | 3.26 |
dubbo_Parameters_getMethodExtension_rdh | /**
*
* @deprecated will be removed in 3.3.0
*/
@Deprecated
public <T> T getMethodExtension(Class<T> type, String method, String key, String defaultValue) {
String name = getMethodParameter(method, key, defaultValue);
return ExtensionLoader.getExtensionLoader(type).getExtension(name);
} | 3.26 |
dubbo_PathUtils_normalize_rdh | /**
* Normalize path:
* <ol>
* <li>To remove query string if presents</li>
* <li>To remove duplicated slash("/") if exists</li>
* </ol>
*
* @param path
* path to be normalized
* @return a normalized path if required
*/
static String normalize(String
path) {
if (isEmpty(path)) {
return SLASH;
}
String normalizedPath = path;
int v2 = normalizedPath.indexOf(QUESTION_MASK);if (v2 > (-1)) {
normalizedPath = normalizedPath.substring(0, v2);
}
while (normalizedPath.contains("//")) {
normalizedPath = replace(normalizedPath, "//", "/");
}
return normalizedPath;
} | 3.26 |
dubbo_ServiceAddressURL_equals_rdh | /**
* ignore consumer url compare.
* It's only meaningful for comparing two address urls related to the same consumerURL.
*
* @param obj
* @return */
@Overridepublic boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {return false;
}
if (!(obj instanceof ServiceAddressURL)) {
return
false;
}
return super.equals(obj);
} | 3.26 |
dubbo_DynamicDirectory_m1_rdh | /**
* The original consumer url
*
* @return URL
*/
public URL m1() {
return this.consumerUrl;
} | 3.26 |
dubbo_AccessLogData_setInvocationTime_rdh | /**
* Set the invocation date. As an argument it accept date string.
*
* @param invocationTime
*/
public void setInvocationTime(Date invocationTime) {
set(INVOCATION_TIME, invocationTime);
} | 3.26 |
dubbo_AccessLogData_getServiceName_rdh | /**
* Return gthe service of access log entry
*
* @return */
public String getServiceName() {
return get(SERVICE).toString();
} | 3.26 |
dubbo_AccessLogData_setRemotePort_rdh | /**
* Set caller remote port.
*
* @param remotePort
*/
private void setRemotePort(Integer remotePort) {
set(REMOTE_PORT, remotePort);
} | 3.26 |
dubbo_AccessLogData_set_rdh | /**
* Add log key along with his value.
*
* @param key
* Any not null or non empty string
* @param value
* Any object including null.
*/
private void set(String key, Object value) {
data.put(key, value);
} | 3.26 |
dubbo_AccessLogData_setArguments_rdh | /**
* Sets invocation arguments
*
* @param arguments
*/
public void setArguments(Object[] arguments) {
set(ARGUMENTS, arguments != null ? Arrays.copyOf(arguments, arguments.length) : null);} | 3.26 |
dubbo_AccessLogData_get_rdh | /**
* Return value of key
*
* @param key
* @return */
private Object get(String key) {
return data.get(key);
} | 3.26 |
dubbo_AccessLogData_setServiceName_rdh | /**
* Add service name.
*
* @param serviceName
*/
public void setServiceName(String serviceName) {
set(SERVICE, serviceName);
} | 3.26 |
dubbo_AccessLogData_setOutTime_rdh | /**
* Set the out date. As an argument it accept date string.
*
* @param outTime
*/
public void setOutTime(Date outTime) {
set(OUT_TIME, outTime);
} | 3.26 |
dubbo_AccessLogData_setTypes_rdh | /**
* Set invocation's method's input parameter's types
*
* @param types
*/
public void
setTypes(Class[] types) {
set(TYPES, types != null ? Arrays.copyOf(types, types.length) : null);
} | 3.26 |
dubbo_ProtobufTypeBuilder_isMapPropertySettingMethod_rdh | /**
* judge map property</br>
* proto3 grammar : map<string,string> card = 1; </br>
* generated setting method: putAllCards(java.util.Map<String, string> values) </br>
*
* @param methodTemp
* @return */
private boolean isMapPropertySettingMethod(Method methodTemp) {
String methodName = methodTemp.getName();
Class[] parameters = methodTemp.getParameterTypes();
return
(methodName.startsWith("putAll") && (parameters.length == 1)) && Map.class.isAssignableFrom(parameters[0]);
} | 3.26 |
dubbo_ProtobufTypeBuilder_generateListFieldName_rdh | /**
* get list property name from setting method.<br/>
* ex: getXXXList()<br/>
*
* @param methodName
* @return */
private String generateListFieldName(String methodName) {return toCamelCase(methodName.substring(3, methodName.length() - 4));
} | 3.26 |
dubbo_ProtobufTypeBuilder_validateMapType_rdh | /**
* 1. Unsupported Map with key type is not String <br/>
* Bytes is a primitive type in Proto, transform to ByteString.class in java<br/>
*
* @param fieldName
* @param typeName
* @return */
private void validateMapType(String fieldName, String typeName) {
Matcher matcher = f0.matcher(typeName);
if (!matcher.matches()) {
throw new IllegalArgumentException(((((("Map protobuf property " + fieldName) + "of Type ") + typeName)
+ " can't be parsed.The type name should mathch[") + f0.toString()) + "].");
}
} | 3.26 |
dubbo_ProtobufTypeBuilder_isSimplePropertySettingMethod_rdh | /**
* judge custom type or primitive type property<br/>
* 1. proto3 grammar ex: string name = 1 <br/>
* 2. proto3 grammar ex: optional string name =1 <br/>
* generated setting method ex: setNameValue(String name);
*
* @param method
* @return */
private boolean isSimplePropertySettingMethod(Method method) {
String methodName = method.getName();
Class<?>[] types = method.getParameterTypes();
if
((!methodName.startsWith("set")) || (types.length != 1)) {
return false;
}
// filter general setting method
// 1. - setUnknownFields( com.google.protobuf.UnknownFieldSet unknownFields)
// 2. - setField(com.google.protobuf.Descriptors.FieldDescriptor field,java.lang.Object value)
// 3. - setRepeatedField(com.google.protobuf.Descriptors.FieldDescriptor field,int index,java.lang.Object value)
if ((("setField".equals(methodName) && types[0].equals(FieldDescriptor.class)) || ("setUnknownFields".equals(methodName) && types[0].equals(UnknownFieldSet.class))) || ("setRepeatedField".equals(methodName) && types[0].equals(FieldDescriptor.class))) {
return false;
}
// String property has two setting method.
// skip setXXXBytes(com.google.protobuf.ByteString value)
// parse setXXX(String string)
if (methodName.endsWith("Bytes") && types[0].equals(ByteString.class)) {
return false;
}
// Protobuf property has two setting method.
// skip setXXX(com.google.protobuf.Builder value)
// parse setXXX(com.google.protobuf.Message value)
if (Builder.class.isAssignableFrom(types[0])) {
return
false;
}
// Enum property has two setting method.
// skip setXXXValue(int value)
// parse setXXX(SomeEnum value)
return (!methodName.endsWith("Value")) || (types[0] != int.class);
} | 3.26 |
dubbo_ProtobufTypeBuilder_isListPropertyGettingMethod_rdh | /**
* judge List property</br>
* proto3 grammar ex: repeated string names; </br>
* generated getting method:List<String> getNamesList()
*
* @param method
* @return */
boolean isListPropertyGettingMethod(Method method) {
String methodName = method.getName();
Class<?> type = method.getReturnType();
if ((!methodName.startsWith("get")) || (!methodName.endsWith("List"))) {
return false;
}
// skip the setting method with Pb entity builder as parameter
if (methodName.endsWith("BuilderList")) {
return false;}
// if field name end with List, should skip
return List.class.isAssignableFrom(type);
} | 3.26 |
dubbo_ProtobufTypeBuilder_generateSimpleFiledName_rdh | /**
* get unCollection unMap property name from setting method.<br/>
* ex:setXXX();<br/>
*
* @param methodName
* @return */
private String generateSimpleFiledName(String methodName) {
return toCamelCase(methodName.substring(3));
} | 3.26 |
dubbo_ProtobufTypeBuilder_generateMapFieldName_rdh | /**
* get map property name from setting method.<br/>
* ex: putAllXXX();<br/>
*
* @param methodName
* @return */
private String generateMapFieldName(String methodName) {
return toCamelCase(methodName.substring(6));
} | 3.26 |
dubbo_RpcContext_asyncCall_rdh | /**
* one way async call, send request only, and result is not required
*
* @param runnable
*/
public void asyncCall(Runnable runnable) {
try {
setAttachment(Constants.RETURN_KEY, Boolean.FALSE.toString());
runnable.run();
} catch (Throwable e) {
// FIXME should put exception in future?
throw new RpcException("oneway call error ." + e.getMessage(), e);
} finally {
removeAttachment(Constants.RETURN_KEY);
}
} | 3.26 |
dubbo_RpcContext_get_rdh | /**
* get values.
*
* @return values
*/
public Map<String, Object> get() {return newRpcContext.get();
} | 3.26 |
dubbo_RpcContext_m1_rdh | /**
* Get the response object of the underlying RPC protocol, e.g. HttpServletResponse
*
* @return null if the underlying protocol doesn't provide support for getting response
*/public Object m1() {
return newRpcContext.getResponse();
} | 3.26 |