Skip to content

Commit

Permalink
RATIS-2182. Fix some Objects.requireNonNull messages (#1172)
Browse files Browse the repository at this point in the history
  • Loading branch information
jianghuazhu authored Oct 31, 2024
1 parent bf15765 commit 237b7c0
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ public static SizeInBytes valueOf(long size) {
}

public static SizeInBytes valueOf(long n, TraditionalBinaryPrefix prefix) {
final long size = Objects.requireNonNull(prefix, "prefix = null").toLong(n);
final long size = Objects.requireNonNull(prefix, "prefix == null").toLong(n);
final String input = n + " " + prefix.getSymbol();
final String description = input + " (=" + size + ")";
return new SizeInBytes(size, input, description);
}

public static SizeInBytes valueOf(String input) {
input = Objects.requireNonNull(input, "input = null").trim();
input = Objects.requireNonNull(input, "input == null").trim();

final int last = input.length() - 1;
final String s = "b".equalsIgnoreCase(input.substring(last))?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public static long parse(String timeString, TimeUnit targetUnit) {
* @return a {@link TimeDuration} in the target unit.
*/
public static TimeDuration valueOf(String timeString, TimeUnit defaultUnit) {
Objects.requireNonNull(timeString, "timeString = null");
Objects.requireNonNull(timeString, "timeString == null");
final String lower = timeString.trim().replace("_", "").toLowerCase();
for(Abbreviation a : Abbreviation.values()) {
for(String s : a.getSymbols()) {
Expand Down Expand Up @@ -172,7 +172,7 @@ public static TimeDuration valueOf(long duration, TimeUnit unit) {

private TimeDuration(long duration, TimeUnit unit) {
this.duration = duration;
this.unit = Objects.requireNonNull(unit, "unit = null");
this.unit = Objects.requireNonNull(unit, "unit == null");
}

/** @return the duration value. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ public TransactionContext build() {
return newTransactionContext(stateMachine, clientRequest,
stateMachineLogEntry, logData, stateMachineData, stateMachineContext);
} else {
Objects.requireNonNull(logEntry, "logEntry MUST NOT be null since clientRequest == null");
Objects.requireNonNull(logEntry, "logEntry must not be null since clientRequest == null");
Preconditions.assertTrue(logEntry.hasStateMachineLogEntry(),
() -> "Unexpected logEntry: stateMachineLogEntry not found, logEntry=" + logEntry);
return newTransactionContext(serverRole, stateMachine, logEntry);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ RaftClientReply convert(RaftClientRequest q, RaftClientReply p) {
}

TermIndex getTermIndex() {
return Objects.requireNonNull(termIndex, "termIndex");
return Objects.requireNonNull(termIndex, "termIndex == null");
}

RaftClientRequest getRequest() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ static final class Builder {
private Builder() {}

Builder setConf(PeerConfiguration conf) {
Objects.requireNonNull(conf);
Objects.requireNonNull(conf, "PeerConfiguration == null");
Preconditions.assertTrue(this.conf == null, "conf is already set.");
this.conf = conf;
return this;
Expand All @@ -73,7 +73,7 @@ Builder setConf(Iterable<RaftPeer> peers, Iterable<RaftPeer> listeners) {
}

Builder setConf(RaftConfigurationImpl transitionalConf) {
Objects.requireNonNull(transitionalConf);
Objects.requireNonNull(transitionalConf, "transitionalConf == null");
Preconditions.assertTrue(transitionalConf.isTransitional());

Preconditions.assertTrue(!forceTransitional);
Expand All @@ -83,7 +83,7 @@ Builder setConf(RaftConfigurationImpl transitionalConf) {


Builder setOldConf(PeerConfiguration oldConf) {
Objects.requireNonNull(oldConf);
Objects.requireNonNull(oldConf, "oldConf == null");
Preconditions.assertTrue(this.oldConf == null, "oldConf is already set.");
this.oldConf = oldConf;
return this;
Expand All @@ -94,7 +94,7 @@ Builder setOldConf(Iterable<RaftPeer> oldPeers, Iterable<RaftPeer> oldListeners)
}

Builder setOldConf(RaftConfigurationImpl stableConf) {
Objects.requireNonNull(stableConf);
Objects.requireNonNull(stableConf, "stableConf == null");
Preconditions.assertTrue(stableConf.isStable());

Preconditions.assertTrue(!forceStable);
Expand Down Expand Up @@ -133,7 +133,7 @@ RaftConfigurationImpl build() {

private RaftConfigurationImpl(PeerConfiguration conf, PeerConfiguration oldConf,
long logEntryIndex) {
this.conf = Objects.requireNonNull(conf);
this.conf = Objects.requireNonNull(conf, "PeerConfiguration == null");
this.oldConf = oldConf;
this.logEntryIndex = logEntryIndex;
}
Expand Down

0 comments on commit 237b7c0

Please sign in to comment.