alibaba / alibaba/Sentinel

Use getParameterCount() in place of getParameterTypes().length

Open
#3,186 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
23.1k
Forks
8.1k
PR merge metrics
No merged PRs in 30d

Description

## Issue Description
Usages of `getParameterTypes().length` should be replaced by `getParameterCount()`, as `getParameterTypes().length` is inefficient because it creates an array clone, while `getParameterCount()` directly returns the length.

```
Targets
Occurrences of 'getParameterTypes().length' in Sentinel
Found Occurrences in Directory Sentinel (4 usages found)
Unclassified (4 usages found)
sentinel-annotation-aspectj (2 usages found)
com.alibaba.csp.sentinel.annotation.aspectj (2 usages found)
AbstractSentinelAspectSupport.java (2 usages found)
handleFallback(ProceedingJoinPoint, String, String, Class[], Throwable) (1 usage found)
96 int paramCount = fallbackMethod.getParameterTypes().length;
handleDefaultFallback(ProceedingJoinPoint, String, Class[], Throwable) (1 usage found)
117 Object[] args = fallbackMethod.getParameterTypes().length == 0 ? new Object[0] : new Object[] {ex};
sentinel-annotation-cdi-interceptor (2 usages found)
com.alibaba.csp.sentinel.annotation.cdi.interceptor (2 usages found)
AbstractSentinelInterceptorSupport.java (2 usages found)
handleFallback(InvocationContext, String, String, Class[], Throwable) (1 usage found)
96 int paramCount = fallbackMethod.getParameterTypes().length;
handleDefaultFallback(InvocationContext, String, Class[], Throwable) (1 usage found)
125 Object[] args = fallbackMethod.getParameterTypes().length == 0 ? new Object[0] : new Object[] {ex};
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.