adoroszlai commented on code in PR #9999:
URL: https://github.com/apache/ozone/pull/9999#discussion_r3006150051
##########
dev-support/pmd/pmd-ruleset.xml:
##########
@@ -43,6 +43,9 @@
<rule ref="category/java/performance.xml/InefficientStringBuffering"/>
<rule ref="category/java/performance.xml/StringInstantiation"/>
<rule ref="category/java/performance.xml/UseStringBufferLength"/>
+ <rule ref="category/java/performance.xml/StringToString"/>
+ <rule ref="category/java/performance.xml/UseArraysAsList"/>
+ <rule ref="category/java/performance.xml/UseIndexOfChar"/>
Review Comment:
nit: please keep alphabetical order, which makes it easier to spot enabled
rules at a glance
##########
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/protocolPB/GrpcOmTransport.java:
##########
@@ -231,9 +231,9 @@ private Exception unwrapException(Exception ex) {
IOException remote = null;
try {
String cause = status.getDescription();
- cause = cause.substring(cause.indexOf(":") + 2);
- remote = new RemoteException(cause.substring(0, cause.indexOf(":")),
- cause.substring(cause.indexOf(":") + 1));
+ cause = cause.substring(cause.indexOf(':') + 2);
+ remote = new RemoteException(cause.substring(0, cause.indexOf(':')),
+ cause.substring(cause.indexOf(':') + 1));
Review Comment:
nit: store `cause.indexOf(':')`
##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/FetchMetrics.java:
##########
@@ -133,7 +133,7 @@ private void writeAttribute(JsonGenerator jg, ObjectName
oname, MBeanAttributeIn
if (attr.isReadable()) {
String attName = attr.getName();
if (!"modelerType".equals(attName)) {
- if (attName.indexOf("=") < 0 && attName.indexOf(":") < 0 &&
attName.indexOf(" ") < 0) {
+ if (!attName.contains("=") && !attName.contains(":") &&
!attName.contains(" ")) {
Review Comment:
nit: Replace `indexOf(String)` with `indexOf(int)`, not `contains(String)`,
for efficiency.
##########
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/server/http/ProfileServlet.java:
##########
@@ -166,9 +166,9 @@ private Integer getPid() {
if (StringUtils.isBlank(pidStr)) {
String name = ManagementFactory.getRuntimeMXBean().getName();
if (name != null) {
- int idx = name.indexOf("@");
+ int idx = name.indexOf('@');
if (idx != -1) {
- pidStr = name.substring(0, name.indexOf("@"));
+ pidStr = name.substring(0, name.indexOf('@'));
Review Comment:
```suggestion
pidStr = name.substring(0, idx);
```
##########
hadoop-ozone/cli-shell/src/main/java/org/apache/hadoop/ozone/shell/keys/DeleteKeyHandler.java:
##########
@@ -117,7 +117,7 @@ private void deleteFSOKey(OzoneBucket bucket, String
keyName)
String trashDirectory = (keyName.contains("/")
? new Path(userTrashCurrent, keyName.substring(0,
- keyName.lastIndexOf("/")))
+ keyName.lastIndexOf('/')))
Review Comment:
nit: store `keyName.lastIndexOf('/')` to replace `contains("/")`
##########
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/VirtualHostStyleFilter.java:
##########
@@ -145,7 +145,7 @@ private String getDomainName(String host) {
private String checkHostWithoutPort(String host) {
if (host.contains(":")) {
- return host.substring(0, host.lastIndexOf(":"));
+ return host.substring(0, host.lastIndexOf(':'));
Review Comment:
nit: store `lastIndexOf` and replace `contains`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]