ROCKETMQ-18 Clean code closes apache/incubator-rocketmq#21

This commit is contained in:
dongeforever
2016-12-29 15:25:05 +08:00
committed by lollipop
parent 6672256880
commit 167cce0348
64 changed files with 208 additions and 258 deletions
@@ -213,7 +213,7 @@ public class AllocateMappedFileService extends ServiceThread {
requestQueue.offer(req);
try {
Thread.sleep(1);
} catch (InterruptedException e1) {
} catch (InterruptedException ignored) {
}
}
} finally {
@@ -1150,7 +1150,7 @@ public class CommitLog {
final byte[] propertiesData =
msgInner.getPropertiesString() == null ? null : msgInner.getPropertiesString().getBytes(MessageDecoder.CHARSET_UTF8);
final short propertiesLength = propertiesData == null ? 0 : (short) propertiesData.length;
final int propertiesLength = propertiesData == null ? 0 : propertiesData.length;
if (propertiesLength > Short.MAX_VALUE) {
log.warn("putMessage message properties length too long. length={}", propertiesData.length);
@@ -1158,7 +1158,7 @@ public class CommitLog {
}
final byte[] topicData = msgInner.getTopic().getBytes(MessageDecoder.CHARSET_UTF8);
final int topicLength = topicData == null ? 0 : topicData.length;
final int topicLength = topicData.length;
final int bodyLength = msgInner.getBody() == null ? 0 : msgInner.getBody().length;
@@ -1229,7 +1229,7 @@ public class CommitLog {
this.msgStoreItemMemory.put((byte) topicLength);
this.msgStoreItemMemory.put(topicData);
// 17 PROPERTIES
this.msgStoreItemMemory.putShort(propertiesLength);
this.msgStoreItemMemory.putShort((short) propertiesLength);
if (propertiesLength > 0)
this.msgStoreItemMemory.put(propertiesData);
@@ -666,7 +666,7 @@ public class DefaultMessageStore implements MessageStore {
final int size = result.getByteBuffer().getInt();
long storeTime = this.getCommitLog().pickupStoreTimestamp(phyOffset, size);
return storeTime;
} catch (Exception e) {
} catch (Exception ignored) {
} finally {
result.release();
}
@@ -1491,7 +1491,7 @@ public class DefaultMessageStore implements MessageStore {
if (deleteCount > 0 && deleteLogicsFilesInterval > 0) {
try {
Thread.sleep(deleteLogicsFilesInterval);
} catch (InterruptedException e) {
} catch (InterruptedException ignored) {
}
}
}
@@ -1592,7 +1592,7 @@ public class DefaultMessageStore implements MessageStore {
for (int i = 0; i < 50 && this.isCommitLogAvailable(); i++) {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
} catch (InterruptedException ignored) {
}
}
@@ -24,7 +24,7 @@ public class StoreUtil {
@SuppressWarnings("restriction")
public static long getTotalPhysicalMemorySize() {
long physicalTotal = 1024 * 1024 * 1024 * 24;
long physicalTotal = 1024 * 1024 * 1024 * 24L;
OperatingSystemMXBean osmxb = ManagementFactory.getOperatingSystemMXBean();
if (osmxb instanceof com.sun.management.OperatingSystemMXBean) {
physicalTotal = ((com.sun.management.OperatingSystemMXBean) osmxb).getTotalPhysicalMemorySize();
@@ -74,10 +74,10 @@ public class IndexService {
log.info("load index file OK, " + f.getFileName());
this.indexFileList.add(f);
} catch (IOException e) {
log.error("load file " + file + " error", e);
log.error("load file {} error", file, e);
return false;
} catch (NumberFormatException e) {
continue;
log.error("load file {} error", file, e);
}
}
}