You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by yu...@apache.org on 2022/04/17 15:46:32 UTC
[rocketmq] branch develop updated: [ISSUE #4167] cleanup code (#4013)
This is an automated email from the ASF dual-hosted git repository.
yuzhou pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/rocketmq.git
The following commit(s) were added to refs/heads/develop by this push:
new 320b728d6 [ISSUE #4167] cleanup code (#4013)
320b728d6 is described below
commit 320b728d6d51aa7e0f66bf6e92e4a906519306c9
Author: Kvicii <42...@users.noreply.github.com>
AuthorDate: Sun Apr 17 23:46:26 2022 +0800
[ISSUE #4167] cleanup code (#4013)
---
.../rocketmq/acl/common/SessionCredentials.java | 8 +---
.../acl/plain/RemoteAddressStrategyFactory.java | 10 ++--
.../rocketmq/remoting/netty/NettyServerConfig.java | 2 +-
.../org/apache/rocketmq/store/ConsumeQueue.java | 53 +++++++++++-----------
4 files changed, 32 insertions(+), 41 deletions(-)
diff --git a/acl/src/main/java/org/apache/rocketmq/acl/common/SessionCredentials.java b/acl/src/main/java/org/apache/rocketmq/acl/common/SessionCredentials.java
index ec0f68a0f..dfc06d4f3 100644
--- a/acl/src/main/java/org/apache/rocketmq/acl/common/SessionCredentials.java
+++ b/acl/src/main/java/org/apache/rocketmq/acl/common/SessionCredentials.java
@@ -148,12 +148,8 @@ public class SessionCredentials {
return false;
if (signature == null) {
- if (other.signature != null)
- return false;
- } else if (!signature.equals(other.signature))
- return false;
-
- return true;
+ return other.signature == null;
+ } else return signature.equals(other.signature);
}
@Override
diff --git a/acl/src/main/java/org/apache/rocketmq/acl/plain/RemoteAddressStrategyFactory.java b/acl/src/main/java/org/apache/rocketmq/acl/plain/RemoteAddressStrategyFactory.java
index 50e6c734c..778030625 100644
--- a/acl/src/main/java/org/apache/rocketmq/acl/plain/RemoteAddressStrategyFactory.java
+++ b/acl/src/main/java/org/apache/rocketmq/acl/plain/RemoteAddressStrategyFactory.java
@@ -214,7 +214,7 @@ public class RemoteAddressStrategyFactory {
throw new AclException(String.format("RangeRemoteAddressStrategy netaddress examine scope Exception start is %s , end is %s", start, end));
}
}
- return this.end > 0 ? true : false;
+ return this.end > 0;
}
private void setValue(int start, int end) {
@@ -237,18 +237,14 @@ public class RemoteAddressStrategyFactory {
value = netAddress.substring(this.head.length(), netAddress.lastIndexOf('.', netAddress.lastIndexOf('.') - 1));
}
Integer address = Integer.valueOf(value);
- if (address >= this.start && address <= this.end) {
- return true;
- }
+ return address >= this.start && address <= this.end;
}
} else if (validator.isValidInet6Address(netAddress)) {
netAddress = AclUtils.expandIP(netAddress, 8).toUpperCase();
if (netAddress.startsWith(this.head)) {
String value = netAddress.substring(5 * index, 5 * index + 4);
Integer address = Integer.parseInt(value, 16);
- if (address >= this.start && address <= this.end) {
- return true;
- }
+ return address >= this.start && address <= this.end;
}
}
return false;
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyServerConfig.java b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyServerConfig.java
index bd87e5b94..78c1e1d81 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyServerConfig.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyServerConfig.java
@@ -33,7 +33,7 @@ public class NettyServerConfig implements Cloneable {
private boolean serverPooledByteBufAllocatorEnable = true;
/**
- * make make install
+ * make install
*
*
* ../glibc-2.10.1/configure \ --prefix=/usr \ --with-headers=/usr/include \
diff --git a/store/src/main/java/org/apache/rocketmq/store/ConsumeQueue.java b/store/src/main/java/org/apache/rocketmq/store/ConsumeQueue.java
index fdc725db7..2f4dcf5c5 100644
--- a/store/src/main/java/org/apache/rocketmq/store/ConsumeQueue.java
+++ b/store/src/main/java/org/apache/rocketmq/store/ConsumeQueue.java
@@ -225,11 +225,11 @@ public class ConsumeQueue {
return 0;
}
- public void truncateDirtyLogicFiles(long phyOffet) {
+ public void truncateDirtyLogicFiles(long phyOffset) {
int logicFileSize = this.mappedFileSize;
- this.maxPhysicOffset = phyOffet;
+ this.maxPhysicOffset = phyOffset;
long maxExtAddr = 1;
while (true) {
MappedFile mappedFile = this.mappedFileQueue.getLastMappedFile();
@@ -246,7 +246,7 @@ public class ConsumeQueue {
long tagsCode = byteBuffer.getLong();
if (0 == i) {
- if (offset >= phyOffet) {
+ if (offset >= phyOffset) {
this.mappedFileQueue.deleteLastMappedFile();
break;
} else {
@@ -264,7 +264,7 @@ public class ConsumeQueue {
if (offset >= 0 && size > 0) {
- if (offset >= phyOffet) {
+ if (offset >= phyOffset) {
return;
}
@@ -345,29 +345,30 @@ public class ConsumeQueue {
long minExtAddr = 1;
if (mappedFile != null) {
SelectMappedBufferResult result = mappedFile.selectMappedBuffer(0);
- if (result != null) {
- try {
- for (int i = 0; i < result.getSize(); i += ConsumeQueue.CQ_STORE_UNIT_SIZE) {
- long offsetPy = result.getByteBuffer().getLong();
- result.getByteBuffer().getInt();
- long tagsCode = result.getByteBuffer().getLong();
-
- if (offsetPy >= phyMinOffset) {
- this.minLogicOffset = mappedFile.getFileFromOffset() + i;
- log.info("Compute logical min offset: {}, topic: {}, queueId: {}",
- this.getMinOffsetInQueue(), this.topic, this.queueId);
- // This maybe not take effect, when not every consume queue has extend file.
- if (isExtAddr(tagsCode)) {
- minExtAddr = tagsCode;
- }
- break;
+ if (result == null) {
+ return;
+ }
+ try {
+ for (int i = 0; i < result.getSize(); i += ConsumeQueue.CQ_STORE_UNIT_SIZE) {
+ long offsetPy = result.getByteBuffer().getLong();
+ result.getByteBuffer().getInt();
+ long tagsCode = result.getByteBuffer().getLong();
+
+ if (offsetPy >= phyMinOffset) {
+ this.minLogicOffset = mappedFile.getFileFromOffset() + i;
+ log.info("Compute logical min offset: {}, topic: {}, queueId: {}",
+ this.getMinOffsetInQueue(), this.topic, this.queueId);
+ // This maybe not take effect, when not every consume queue has extend file.
+ if (isExtAddr(tagsCode)) {
+ minExtAddr = tagsCode;
}
+ break;
}
- } catch (Exception e) {
- log.error("Exception thrown when correctMinOffset", e);
- } finally {
- result.release();
}
+ } catch (Exception e) {
+ log.error("Exception thrown when correctMinOffset", e);
+ } finally {
+ result.release();
}
}
@@ -449,7 +450,6 @@ public class ConsumeQueue {
doDispatchLmqQueue(request, maxRetries, queueName, queueOffset, queueId);
}
- return;
}
private void doDispatchLmqQueue(DispatchRequest request, int maxRetries, String queueName, long queueOffset,
@@ -547,8 +547,7 @@ public class ConsumeQueue {
if (offset >= this.getMinLogicOffset()) {
MappedFile mappedFile = this.mappedFileQueue.findMappedFileByOffset(offset);
if (mappedFile != null) {
- SelectMappedBufferResult result = mappedFile.selectMappedBuffer((int) (offset % mappedFileSize));
- return result;
+ return mappedFile.selectMappedBuffer((int) (offset % mappedFileSize));
}
}
return null;