Skip to content

Commit

Permalink
Utilizing cache to avoid duplicate parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
guyinyou committed Oct 12, 2023
1 parent 7e4879a commit 7e5d88a
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ public class RemotingCommand {
private String remark;
private HashMap<String, String> extFields;
private transient CommandCustomHeader customHeader;
private transient CommandCustomHeader cachedHeader;

private SerializeType serializeTypeCurrentRPC = serializeTypeConfigInThisServer;

Expand Down Expand Up @@ -260,7 +261,11 @@ public void writeCustomHeader(CommandCustomHeader customHeader) {

public CommandCustomHeader decodeCommandCustomHeader(
Class<? extends CommandCustomHeader> classHeader) throws RemotingCommandException {
return decodeCommandCustomHeader(classHeader, true);
if (cachedHeader != null) {
return cachedHeader;
}
cachedHeader = decodeCommandCustomHeader(classHeader, true);
return cachedHeader;
}

public CommandCustomHeader decodeCommandCustomHeader(Class<? extends CommandCustomHeader> classHeader,
Expand Down

0 comments on commit 7e5d88a

Please sign in to comment.