Skip to content

Commit

Permalink
Changed should to must in exception messages
Browse files Browse the repository at this point in the history
  • Loading branch information
ndeevy committed Oct 17, 2020
1 parent c064a59 commit b7d5448
Show file tree
Hide file tree
Showing 26 changed files with 49 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ private void parseOption(String option) {
String key = keyValue[0].trim();
String value = (keyValue.length == 1) ? null : keyValue[1].trim();

isTrue(value != null && !value.isEmpty(), String.format("value for %s should not be null or empty", key));
isTrue(value != null && !value.isEmpty(), String.format("value for %s must not be null or empty", key));

if ("defaultReadTimeout".equals(key)) {
defaultReadTimeout = Long.parseLong(value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ protected void queryCachePredicateHandler(Node childNode, QueryCacheConfig query
}

if (classNameNode == null && sqlNode == null) {
throw new InvalidConfigurationException("Either class-name and sql should be defined for the predicate of map "
throw new InvalidConfigurationException("Either class-name and sql must be defined for the predicate of map "
+ childNode.getParentNode().getParentNode().getNodeName());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ protected void handleClients(Node node) {

if (!clientConfigDefined) {
String path = ((YamlElementAdapter) node).getYamlNode().path();
throw new InvalidConfigurationException(String.format("At least one client configuration should be defined "
throw new InvalidConfigurationException(String.format("At least one client configuration must be defined "
+ "under '%s'", path));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public static ClientConfig resolveClientConfig(ClientConfig config) {
}

/**
* For a client to be valid alternative, all configurations should be equal except
* For a client to be valid alternative, all configurations must be equal except
* Cluster name
* SecurityConfig
* Discovery related parts of NetworkConfig
Expand All @@ -97,7 +97,7 @@ public static ClientConfig resolveClientConfig(ClientConfig config) {
*/
private static void checkValidAlternative(List<ClientConfig> alternativeClientConfigs) {
if (alternativeClientConfigs.isEmpty()) {
throw new InvalidConfigurationException("ClientFailoverConfig should have at least one client config.");
throw new InvalidConfigurationException("ClientFailoverConfig must have at least one client config.");
}
ClientConfig mainConfig = alternativeClientConfigs.get(0);
for (ClientConfig alternativeClientConfig : alternativeClientConfigs.subList(1, alternativeClientConfigs.size())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ private Throwable createException(Iterator<ErrorHolder> iterator) {
Throwable throwable = null;
if (exceptionFactory == null) {
String className = errorHolder.getClassName();
assert checkClassNameForValidity(className) : "Exception should be defined in the protocol : " + className;
assert checkClassNameForValidity(className) : "Exception must be defined in the protocol : " + className;
try {
Class<? extends Throwable> exceptionClass =
(Class<? extends Throwable>) ClassLoaderUtil.loadClass(classLoader, className);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public int getWriteBatchSize() {
*/
public MapStoreConfig setWriteBatchSize(int writeBatchSize) {
if (writeBatchSize < 1) {
throw new IllegalArgumentException("Write batch size should be at least 1");
throw new IllegalArgumentException("Write batch size must be at least 1");
}
this.writeBatchSize = writeBatchSize;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,6 @@ private Collection<MemcacheEntry> getAll(String mapName, Set<String> keys,

@Override
public void handleRejection(BulkGetCommand request) {
throw new UnsupportedOperationException("not used, this method should be removed from the interface");
throw new UnsupportedOperationException("not used, remove this method from the interface");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,11 @@ private void readCRLFOrPositionChunkSize(ByteBuffer cb) {
}

private void readLF(ByteBuffer cb) {
assert cb.hasRemaining() : "'\\n' should follow '\\r'";
assert cb.hasRemaining() : "'\\n' must follow '\\r'";

byte b = cb.get();
if (b != LINE_FEED) {
throw new IllegalStateException("'\\n' should follow '\\r', but got '" + (char) b + "'");
throw new IllegalStateException("'\\n' must follow '\\r', but got '" + (char) b + "'");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,7 @@ private boolean shouldMergeTo(Address thisAddress, Address targetAddress) {
String targetAddressStr = "[" + targetAddress.getHost() + "]:" + targetAddress.getPort();

if (thisAddressStr.equals(targetAddressStr)) {
throw new IllegalArgumentException("Addresses should be different! This: "
throw new IllegalArgumentException("Addresses must be different! This: "
+ thisAddress + ", Target: " + targetAddress);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public TcpIpJoiner(Node node) {
super(node);
int tryCount = node.getProperties().getInteger(ClusterProperty.TCP_JOIN_PORT_TRY_COUNT);
if (tryCount <= 0) {
throw new IllegalArgumentException(String.format("%s should be greater than zero! Current value: %d",
throw new IllegalArgumentException(String.format("%s must be greater than zero! Current value: %d",
ClusterProperty.TCP_JOIN_PORT_TRY_COUNT, tryCount));
}
maxPortTryCount = tryCount;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ protected void queryCachePredicateHandler(Node childNode, QueryCacheConfig query
}

if (classNameNode == null && sqlNode == null) {
throw new InvalidConfigurationException("Either class-name and sql should be defined for the predicate of map "
throw new InvalidConfigurationException("Either class-name and sql must be defined for the predicate of map "
+ childNode.getParentNode().getParentNode().getNodeName());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ public class NonTerminalJsonValue extends JsonValue {

@Override
void write(JsonWriter writer) throws IOException {
throw new HazelcastException("This object should not be encoded");
throw new HazelcastException("This object must not be encoded");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ private static final class IrresolvableConstructor {
*/
@SuppressWarnings("checkstyle:RedundantModifier")
public IrresolvableConstructor() {
throw new UnsupportedOperationException("Irresolvable constructor should never be instantiated.");
throw new UnsupportedOperationException("Irresolvable constructor must never be instantiated.");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public boolean isClusterSafe() {
@Override
public boolean isMemberSafe(Member member) {
if (member == null) {
throw new NullPointerException("Parameter member should not be null");
throw new NullPointerException("Parameter member must not be null");
}
final Member localMember = nodeEngine.getLocalMember();
if (localMember.equals(member)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ final class CheckPartitionReplicaVersionTask extends AbstractPartitionPrimaryRep
BiConsumer<Object, Throwable> callback) {
super(nodeEngine, partitionId);
if (replicaIndex < 1 || replicaIndex > InternalPartition.MAX_BACKUP_COUNT) {
throw new IllegalArgumentException("Replica index should be in range [1-"
throw new IllegalArgumentException("Replica index must be in range [1-"
+ InternalPartition.MAX_BACKUP_COUNT + "]");
}
this.replicaIndex = replicaIndex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1316,7 +1316,7 @@ CompletionStage<Boolean> run() {
&& migration.getDestinationCurrentReplicaIndex() > 0
&& migration.getDestinationNewReplicaIndex() == 0) {

throw new IllegalStateException("Promotion migrations should be handled by "
throw new IllegalStateException("Promotion migrations must be handled by "
+ RepairPartitionTableTask.class.getSimpleName() + " -> " + migration);
}

Expand Down Expand Up @@ -1603,7 +1603,7 @@ public void run() {
&& migrationInfo.getDestinationCurrentReplicaIndex() > 0
&& migrationInfo.getDestinationNewReplicaIndex() == 0) {

throw new AssertionError("Promotion migrations should be handled by "
throw new AssertionError("Promotion migrations must be handled by "
+ RepairPartitionTableTask.class.getSimpleName() + "! -> " + migrationInfo);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ public static <E> E checkInstanceOf(Class<E> type, Object object, String errorMe
public static <E> E checkInstanceOf(Class<E> type, Object object) {
isNotNull(type, "type");
if (!type.isInstance(object)) {
throw new IllegalArgumentException(object + " should be instanceof " + type.getName());
throw new IllegalArgumentException(object + " must be instanceof " + type.getName());
}
return (E) object;
}
Expand Down Expand Up @@ -369,4 +369,3 @@ public static void checkState(boolean condition, String message) throws IllegalS
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -76,27 +76,27 @@ public boolean isWriteBehindMapStoreEnabled() {

@Override
public SerializationService getSerializationService() {
throw new UnsupportedOperationException("This method should not be called. No defined map store exists.");
throw new UnsupportedOperationException("This method must not be called. No defined map store exists.");
}

@Override
public ILogger getLogger(Class clazz) {
throw new UnsupportedOperationException("This method should not be called. No defined map store exists.");
throw new UnsupportedOperationException("This method must not be called. No defined map store exists.");
}

@Override
public String getMapName() {
throw new UnsupportedOperationException("This method should not be called. No defined map store exists.");
throw new UnsupportedOperationException("This method must not be called. No defined map store exists.");
}

@Override
public MapServiceContext getMapServiceContext() {
throw new UnsupportedOperationException("This method should not be called. No defined map store exists.");
throw new UnsupportedOperationException("This method must not be called. No defined map store exists.");
}

@Override
public MapStoreConfig getMapStoreConfig() {
throw new UnsupportedOperationException("This method should not be called. No defined map store exists.");
throw new UnsupportedOperationException("This method must not be called. No defined map store exists.");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ public TypeConverter tryResolve() {

@Override
public Comparable convert(Comparable value) {
throw new UnsupportedOperationException("should never be called");
throw new UnsupportedOperationException("must never be called");
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public PagingPredicateImpl() {
*/
public PagingPredicateImpl(int pageSize) {
if (pageSize <= 0) {
throw new IllegalArgumentException("pageSize should be greater than 0!");
throw new IllegalArgumentException("pageSize must be greater than 0!");
}
this.pageSize = pageSize;
anchorList = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ static <T extends CompoundPredicate> T flattenCompound(Predicate predicateLeft,
compoundPredicate.setPredicates(predicates);
return compoundPredicate;
} catch (InstantiationException | IllegalAccessException e) {
throw new IllegalArgumentException(String.format("%s should have a public default constructor", klass.getName()));
throw new IllegalArgumentException(String.format("%s must have a public default constructor", klass.getName()));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public void shutdown(boolean terminate) {
public <T, E> RingbufferContainer<T, E> getOrCreateContainer(int partitionId, ObjectNamespace namespace,
RingbufferConfig config) {
if (config == null) {
throw new NullPointerException("Ringbuffer config should not be null when ringbuffer is being created");
throw new NullPointerException("Ringbuffer config must not be null when ringbuffer is being created");
}
final Map<ObjectNamespace, RingbufferContainer> partitionContainers = getOrCreateRingbufferContainers(partitionId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ private int sendSingleBackup(BackupAwareOperation backupAwareOp, InternalPartiti
private Operation getBackupOperation(BackupAwareOperation backupAwareOp) {
Operation backupOp = backupAwareOp.getBackupOperation();
if (backupOp == null) {
throw new IllegalArgumentException("Backup operation should not be null! " + backupAwareOp);
throw new IllegalArgumentException("Backup operation must not be null! " + backupAwareOp);
}
if (ASSERTION_ENABLED) {
checkServiceNamespaces(backupAwareOp, backupOp);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ private void initialize() {

void set(DistributedObject o, boolean initialized) {
if (o == null) {
throw new IllegalArgumentException("Proxy should not be null!");
throw new IllegalArgumentException("Proxy must not be null!");
}
synchronized (this) {
if (error == null) {
Expand All @@ -122,7 +122,7 @@ void set(DistributedObject o, boolean initialized) {

void setError(Throwable t) {
if (t == null) {
throw new IllegalArgumentException("Error should not be null!");
throw new IllegalArgumentException("Error must not be null!");
}
if (proxy != null) {
throw new IllegalStateException("Proxy is already set! Proxy: " + proxy + ", error: " + t);
Expand Down
4 changes: 2 additions & 2 deletions hazelcast/src/main/java/com/hazelcast/sql/SqlStatement.java
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public long getTimeoutMillis() {
@Nonnull
public SqlStatement setTimeoutMillis(long timeout) {
if (timeout < 0 && timeout != TIMEOUT_NOT_SET) {
throw new IllegalArgumentException("Timeout should be non-negative or -1: " + timeout);
throw new IllegalArgumentException("Timeout must be non-negative or -1: " + timeout);
}

this.timeout = timeout;
Expand Down Expand Up @@ -230,7 +230,7 @@ public int getCursorBufferSize() {
@Nonnull
public SqlStatement setCursorBufferSize(int cursorBufferSize) {
if (cursorBufferSize <= 0) {
throw new IllegalArgumentException("Cursor buffer size should be positive: " + cursorBufferSize);
throw new IllegalArgumentException("Cursor buffer size must be positive: " + cursorBufferSize);
}

this.cursorBufferSize = cursorBufferSize;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,77 +49,77 @@ public Class<?> getValueClass() {

@Override
public boolean asBoolean(Object val) {
throw new UnsupportedOperationException("should never be called");
throw new UnsupportedOperationException("must never be called");
}

@Override
public byte asTinyint(Object val) {
throw new UnsupportedOperationException("should never be called");
throw new UnsupportedOperationException("must never be called");
}

@Override
public short asSmallint(Object val) {
throw new UnsupportedOperationException("should never be called");
throw new UnsupportedOperationException("must never be called");
}

@Override
public int asInt(Object val) {
throw new UnsupportedOperationException("should never be called");
throw new UnsupportedOperationException("must never be called");
}

@Override
public long asBigint(Object val) {
throw new UnsupportedOperationException("should never be called");
throw new UnsupportedOperationException("must never be called");
}

@Override
public BigDecimal asDecimal(Object val) {
throw new UnsupportedOperationException("should never be called");
throw new UnsupportedOperationException("must never be called");
}

@Override
public float asReal(Object val) {
throw new UnsupportedOperationException("should never be called");
throw new UnsupportedOperationException("must never be called");
}

@Override
public double asDouble(Object val) {
throw new UnsupportedOperationException("should never be called");
throw new UnsupportedOperationException("must never be called");
}

@Override
public String asVarchar(Object val) {
throw new UnsupportedOperationException("should never be called");
throw new UnsupportedOperationException("must never be called");
}

@Override
public LocalDate asDate(Object val) {
throw new UnsupportedOperationException("should never be called");
throw new UnsupportedOperationException("must never be called");
}

@Override
public LocalTime asTime(Object val) {
throw new UnsupportedOperationException("should never be called");
throw new UnsupportedOperationException("must never be called");
}

@Override
public LocalDateTime asTimestamp(Object val) {
throw new UnsupportedOperationException("should never be called");
throw new UnsupportedOperationException("must never be called");
}

@Override
public OffsetDateTime asTimestampWithTimezone(Object val) {
throw new UnsupportedOperationException("should never be called");
throw new UnsupportedOperationException("must never be called");
}

@Override
public Object asObject(Object val) {
throw new UnsupportedOperationException("should never be called");
throw new UnsupportedOperationException("must never be called");
}

@Override
public Object convertToSelf(Converter converter, Object value) {
throw new UnsupportedOperationException("should never be called");
throw new UnsupportedOperationException("must never be called");
}

}

0 comments on commit b7d5448

Please sign in to comment.