Skip to content

Commit

Permalink
Merge pull request #2932 from rsksmart/fix_sonar_complain_when_deseri…
Browse files Browse the repository at this point in the history
…alizing_rskTxs

Return null early in public method instead of in private one.
  • Loading branch information
marcos-iov authored Jan 13, 2025
2 parents 8f3af1d + 9b023cc commit 85dd54c
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package co.rsk.peg;

import static co.rsk.peg.federation.FederationFormatVersion.*;
import static com.google.common.base.Preconditions.checkArgument;
import static java.util.Objects.isNull;

import co.rsk.bitcoinj.core.*;
Expand Down Expand Up @@ -163,6 +164,9 @@ public static Map.Entry<Keccak256, BtcTransaction> deserializeRskTxWaitingForSig
}

RLPList rlpList = (RLPList) RLP.decode2(data).get(0);
if (rlpList.size() == 0) {
return null;
}
return deserializeRskTxWaitingForSignaturesEntry(rlpList, 0, networkParameters);
}

Expand Down Expand Up @@ -190,9 +194,7 @@ public static SortedMap<Keccak256, BtcTransaction> deserializeRskTxsWaitingForSi

private static Map.Entry<Keccak256, BtcTransaction> deserializeRskTxWaitingForSignaturesEntry(
RLPList rlpList, int index, NetworkParameters networkParameters) {
if (rlpList.size() == 0) {
return null;
}
checkArgument(rlpList.size() > 0, "RLPList cannot be empty when deserializing an rsk tx WFS entry.");

RLPElement rskTxHashRLPElement = rlpList.get(index * 2);
byte[] rskTxHashData = rskTxHashRLPElement.getRLPData();
Expand Down

0 comments on commit 85dd54c

Please sign in to comment.