Skip to content

Commit a146646

Browse files
committed
[ROCKETMQ-75] Logging when RemotingCommand header decoding swallows exceptions. closes apache#51
1 parent c5d9fcb commit a146646

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingCommand.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ public static RemotingCommand createResponseCommand(Class<? extends CommandCusto
110110
return createResponseCommand(RemotingSysResponseCode.SYSTEM_ERROR, "not set any response code", classHeader);
111111
}
112112

113-
public static RemotingCommand createResponseCommand(int code, String remark, Class<? extends CommandCustomHeader> classHeader) {
113+
public static RemotingCommand createResponseCommand(int code, String remark,
114+
Class<? extends CommandCustomHeader> classHeader) {
114115
RemotingCommand cmd = new RemotingCommand();
115116
cmd.markResponseType();
116117
cmd.setCode(code);
@@ -230,7 +231,8 @@ public void writeCustomHeader(CommandCustomHeader customHeader) {
230231
this.customHeader = customHeader;
231232
}
232233

233-
public CommandCustomHeader decodeCommandCustomHeader(Class<? extends CommandCustomHeader> classHeader) throws RemotingCommandException {
234+
public CommandCustomHeader decodeCommandCustomHeader(
235+
Class<? extends CommandCustomHeader> classHeader) throws RemotingCommandException {
234236
CommandCustomHeader objectHeader;
235237
try {
236238
objectHeader = classHeader.newInstance();
@@ -279,6 +281,7 @@ public CommandCustomHeader decodeCommandCustomHeader(Class<? extends CommandCust
279281
field.set(objectHeader, valueParsed);
280282

281283
} catch (Throwable e) {
284+
log.error("Failed field [{}] decoding", fieldName, e);
282285
}
283286
}
284287
}
@@ -384,8 +387,8 @@ public void makeCustomHeaderToNet() {
384387
try {
385388
field.setAccessible(true);
386389
value = field.get(this.customHeader);
387-
} catch (IllegalArgumentException e) {
388-
} catch (IllegalAccessException e) {
390+
} catch (Exception e) {
391+
log.error("Failed to access field [{}]", name, e);
389392
}
390393

391394
if (value != null) {
@@ -401,7 +404,6 @@ public ByteBuffer encodeHeader() {
401404
return encodeHeader(this.body != null ? this.body.length : 0);
402405
}
403406

404-
405407
public ByteBuffer encodeHeader(final int bodyLength) {
406408
// 1> header length size
407409
int length = 4;

0 commit comments

Comments
 (0)