Skip to content

Commit 14b4d46

Browse files
317787106claude
andcommitted
fix(log): suppress spurious error logs when solidity node exits
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 156af72 commit 14b4d46

2 files changed

Lines changed: 338 additions & 286 deletions

File tree

framework/src/main/java/org/tron/program/SolidityNode.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,15 @@ private void getBlock() {
117117
Block block = getBlockByNum(blockNum);
118118
blockQueue.put(block);
119119
blockNum = ID.incrementAndGet();
120+
} catch (InterruptedException e) {
121+
Thread.currentThread().interrupt();
122+
logger.info("getBlock interrupted, exiting.");
123+
return;
120124
} catch (Exception e) {
125+
if (!flag) {
126+
logger.info("getBlock stopped during shutdown, last block: {}.", blockNum);
127+
return;
128+
}
121129
logger.error("Failed to get block {}, reason: {}.", blockNum, e.getMessage());
122130
sleep(exceptionSleepTime);
123131
}
@@ -167,6 +175,11 @@ private Block getBlockByNum(long blockNum) {
167175
try {
168176
long time = System.currentTimeMillis();
169177
Block block = databaseGrpcClient.getBlock(blockNum);
178+
if (block == null) {
179+
logger.warn("Got null block for num: {}, retrying.", blockNum);
180+
sleep(exceptionSleepTime);
181+
continue;
182+
}
170183
long num = block.getBlockHeader().getRawData().getNumber();
171184
if (num == blockNum) {
172185
logger.info("Success to get block: {}, cost: {}ms.",
@@ -194,6 +207,10 @@ private long getLastSolidityBlockNum() {
194207
blockNum, remoteBlockNum, System.currentTimeMillis() - time);
195208
return blockNum;
196209
} catch (Exception e) {
210+
if (!flag) {
211+
logger.info("getLastSolidityBlockNum stopped during shutdown.");
212+
return 0;
213+
}
197214
logger.error("Failed to get last solid blockNum: {}, reason: {}.", remoteBlockNum.get(),
198215
e.getMessage());
199216
sleep(exceptionSleepTime);
@@ -205,8 +222,8 @@ private long getLastSolidityBlockNum() {
205222
public void sleep(long time) {
206223
try {
207224
Thread.sleep(time);
208-
} catch (Exception e1) {
209-
logger.error(e1.getMessage());
225+
} catch (InterruptedException e) {
226+
Thread.currentThread().interrupt();
210227
}
211228
}
212229

0 commit comments

Comments
 (0)