Skip to content

Commit

Permalink
[ISSUE #4808] Unify all null == object usage to standard `object ==…
Browse files Browse the repository at this point in the history
… null` (#4809)
  • Loading branch information
Pil0tXia authored Apr 4, 2024
1 parent 6594588 commit e04156b
Show file tree
Hide file tree
Showing 29 changed files with 42 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,23 +49,23 @@ public Header(int code, String desc, String seq, Map<String, Object> properties)
}

public void putProperty(final String name, final Object value) {
if (null == this.properties) {
if (this.properties == null) {
this.properties = new HashMap<>();
}

this.properties.put(name, value);
}

public Object getProperty(final String name) {
if (null == this.properties) {
if (this.properties == null) {
return null;
}
return this.properties.get(name);
}

public String getStringProperty(final String name) {
Object property = getProperty(name);
if (null == property) {
if (property == null) {
return null;
}
return property.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ protected Object decode(ChannelHandlerContext ctx, ByteBuf in) throws Exception

try {
target = (ByteBuf) super.decode(ctx, in);
if (null == target) {
if (target == null) {
return null;
}
byte[] flagBytes = parseFlag(target);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ private static String normalizeHostAddress(final InetAddress localHost) {
}

public static String parseChannelRemoteAddr(final Channel channel) {
if (null == channel) {
if (channel == null) {
return "";
}
SocketAddress remote = channel.remoteAddress();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static void sleep(long timeout, TimeUnit timeUnit) {
}

public static void sleepWithThrowException(long timeout, TimeUnit timeUnit) throws InterruptedException {
if (null == timeUnit) {
if (timeUnit == null) {
return;
}
timeUnit.sleep(timeout);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public void put(List<ConnectRecord> sinkRecords) {
orgGroupSendHeaders.xAcsDingtalkAccessToken = accessToken;

String templateTypeKey = record.getExtension(ConnectRecordExtensionKeys.DINGTALK_TEMPLATE_TYPE);
if (null == templateTypeKey || "null".equals(templateTypeKey)) {
if (templateTypeKey == null || "null".equals(templateTypeKey)) {
templateTypeKey = DingDingMessageTemplateType.PLAIN_TEXT.getTemplateType();
}
DingDingMessageTemplateType templateType = DingDingMessageTemplateType.of(templateTypeKey);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public String getDefaultDatabase() {

@Override
public boolean databaseExists(String databaseName) throws CatalogException {
if (null == databaseName || databaseName.trim().isEmpty()) {
if (databaseName == null || databaseName.trim().isEmpty()) {
return false;
}
List<String> databases = listDatabases();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void init() {
}

private void doHandleEvent(Event event) {
if (null == event) {
if (event == null) {
return;
}
JdbcConnectData jdbcConnectData = event.getJdbcConnectData();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ public EventMeshGtidSet filterGtidSet(MysqlJdbcContext offsetContext, EventMeshG
*/
private void eventMeshMysqlEventListener(Event event, MysqlJdbcContext context) {

if (null == event) {
if (event == null) {
return;
}
final EventHeader eventHeader = event.getHeader();
Expand Down Expand Up @@ -366,7 +366,7 @@ public void run() {
Event event = null;
try {
event = eventQueue.poll(5, TimeUnit.SECONDS);
if (null == event) {
if (event == null) {
continue;
}
eventHandlers.getOrDefault(event.getHeader().getEventType(), ignore -> ignoreEvent(context, ignore)).accept(event);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public EventMeshDataType<?> toEventMeshType(MysqlType connectorDataType, Map<Str
/**
* @see <a href="https://dev.mysql.com/doc/refman/8.0/en/bit-type.html">Mysql doc</a>
*/
if (null == dataTypeProperties) {
if (dataTypeProperties == null) {
return BytesEventMeshDataType.INSTANCE;
}
Integer precision = (Integer) dataTypeProperties.get(MysqlDataTypeConvertor.PRECISION);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ public void run() {
while (isRunning) {
try {
Event event = eventQueue.poll(5, TimeUnit.SECONDS);
if (null == event) {
if (event == null) {
continue;
}
consumers.forEach(consumer -> consumer.accept(event));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public class MysqlDefaultValueConvertorImpl implements DefaultValueConvertor {

@Override
public Object parseDefaultValue(Column<?> column, String defaultValueExpression) {
if (null == defaultValueExpression) {
if (defaultValueExpression == null) {
return null;
}
defaultValueExpression = defaultValueExpression.trim();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ private CreateMessageReq convertCreateMessageReq(ConnectRecord connectRecord) {
.uuid(UUID.randomUUID().toString());

String templateTypeKey = connectRecord.getExtension(ConnectRecordExtensionKeys.TEMPLATE_TYPE_4_LARK);
if (null == templateTypeKey || "null".equals(templateTypeKey)) {
if (templateTypeKey == null || "null".equals(templateTypeKey)) {
templateTypeKey = LarkMessageTemplateType.PLAIN_TEXT.getTemplateKey();
}
LarkMessageTemplateType templateType = LarkMessageTemplateType.of(templateTypeKey);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public void run(String... args) throws Exception {
while (sinkConnector.isRunning()) {
try {
poll = sinkConnector.getQueue().poll(annotation.requestTimeout(), TimeUnit.SECONDS);
if (null == poll || null == poll.getData()) {
if (poll == null || poll.getData() == null) {
continue;
}
String messageBody = new String((byte[]) poll.getData());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public static void main(String[] args) throws Exception {
final Package response = client.rr(event, EventMeshCommon.DEFAULT_TIME_OUT_MILLS);
// check-NPE EventFormat
final EventFormat eventFormat = EventFormatProvider.getInstance().resolveFormat(JsonFormat.CONTENT_TYPE);
if (null == eventFormat) {
if (eventFormat == null) {
log.error("eventFormat is null. end the process");
return;
}
Expand All @@ -75,7 +75,7 @@ public static void main(String[] args) throws Exception {

// check-NPE CloudEventData
final CloudEventData cloudEventData = replyEvent.getData();
if (null == cloudEventData) {
if (cloudEventData == null) {
log.error("replyEvent.data is null. end the process");
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public void init() throws MetaException {
eventMeshRegisterInfoMap = new ConcurrentHashMap<>(ConfigurationContextUtil.KEYS.size());
for (String key : ConfigurationContextUtil.KEYS) {
CommonConfiguration commonConfiguration = ConfigurationContextUtil.get(key);
if (null == commonConfiguration) {
if (commonConfiguration == null) {
continue;
}
if (StringUtils.isBlank(commonConfiguration.getMetaStorageAddr())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public void init() throws MetaException {
eventMeshRegisterInfoMap = new ConcurrentHashMap<>(ConfigurationContextUtil.KEYS.size());
for (String key : ConfigurationContextUtil.KEYS) {
CommonConfiguration commonConfiguration = ConfigurationContextUtil.get(key);
if (null == commonConfiguration) {
if (commonConfiguration == null) {
continue;
}
if (StringUtils.isBlank(commonConfiguration.getMetaStorageAddr())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public void init() throws MetaException {
eventMeshRegisterInfoMap = new ConcurrentHashMap<>(ConfigurationContextUtil.KEYS.size());
for (String key : ConfigurationContextUtil.KEYS) {
CommonConfiguration commonConfiguration = ConfigurationContextUtil.get(key);
if (null == commonConfiguration) {
if (commonConfiguration == null) {
continue;
}
if (StringUtils.isBlank(commonConfiguration.getMetaStorageAddr())) {
Expand Down Expand Up @@ -285,7 +285,7 @@ public void removeMetaData(String key) {
public boolean register(EventMeshRegisterInfo eventMeshRegisterInfo) throws MetaException {
try {
String[] ipPort = eventMeshRegisterInfo.getEndPoint().split(ZookeeperConstant.IP_PORT_SEPARATOR);
if (null == ipPort || ipPort.length < 2) {
if (ipPort == null || ipPort.length < 2) {
return false;
}
String ip = ipPort[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void start() {

// merge the updated connectorRecord & recordOffset to memory store
public void mergeOffset(ConnectorRecordPartition connectorRecordPartition, RecordOffset recordOffset) {
if (null == connectorRecordPartition || connectorRecordPartition.getPartition().isEmpty()) {
if (connectorRecordPartition == null || connectorRecordPartition.getPartition().isEmpty()) {
return;
}
if (positionStore.getKVMap().containsKey(connectorRecordPartition)) {
Expand Down Expand Up @@ -172,7 +172,7 @@ public void putPosition(ConnectorRecordPartition partition, RecordOffset positio

@Override
public void removePosition(List<ConnectorRecordPartition> partitions) {
if (null == partitions) {
if (partitions == null) {
return;
}
for (ConnectorRecordPartition partition : partitions) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public static List<io.cloudevents.CloudEvent> buildBatchEvents(CloudEventBatch c
}

public static EventMeshCloudEventWrapper buildEventMeshCloudEvent(io.cloudevents.CloudEvent cloudEvent) {
if (null == cloudEvent) {
if (cloudEvent == null) {
return new EventMeshCloudEventWrapper(null);
}
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ public class GrpcEventMeshCloudEventProtocolResolver {
private static final EventFormat eventFormat = EventFormatProvider.getInstance().resolveFormat(ProtobufFormat.PROTO_CONTENT_TYPE);

public static io.cloudevents.CloudEvent buildEvent(CloudEvent cloudEvent) {
if (null == cloudEvent) {
if (cloudEvent == null) {
return null;
}
io.cloudevents.CloudEvent event = eventFormat.deserialize(cloudEvent.toByteArray());
return event;
}

public static EventMeshCloudEventWrapper buildEventMeshCloudEvent(io.cloudevents.CloudEvent cloudEvent) {
if (null == cloudEvent) {
if (cloudEvent == null) {
return new EventMeshCloudEventWrapper(null);
}
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public static boolean validateCloudEventAttributes(CloudEvent cloudEvent) {
}

public static boolean validateCloudEventBatchAttributes(CloudEventBatch cloudEventBatch) {
if (null == cloudEventBatch || cloudEventBatch.getEventsCount() < 1) {
if (cloudEventBatch == null || cloudEventBatch.getEventsCount() < 1) {
return false;
}
List<CloudEvent> eventsList = cloudEventBatch.getEventsList();
Expand Down Expand Up @@ -99,7 +99,7 @@ public static boolean validateCloudEventData(CloudEvent cloudEvent) {
}

public static boolean validateCloudEventBatchData(CloudEventBatch cloudEventBatch) {
if (null == cloudEventBatch || cloudEventBatch.getEventsCount() < 1) {
if (cloudEventBatch == null || cloudEventBatch.getEventsCount() < 1) {
return false;
}
List<CloudEvent> eventsList = cloudEventBatch.getEventsList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class HttpTinyClient {
public static HttpResult httpGet(String url, List<String> headers, List<String> paramValues,
String encoding, long readTimeoutMs) throws IOException {
String encodedContent = encodingParams(paramValues, encoding);
url += (null == encodedContent) ? "" : ("?" + encodedContent);
url += (encodedContent == null) ? "" : ("?" + encodedContent);

HttpURLConnection conn = null;
try {
Expand Down Expand Up @@ -65,7 +65,7 @@ public static HttpResult httpGet(String url, List<String> headers, List<String>
private static String encodingParams(Collection<String> paramValues, String encoding)
throws UnsupportedEncodingException {
StringBuilder sb = new StringBuilder();
if (null == paramValues) {
if (paramValues == null) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public static SocketAddress string2SocketAddress(final String addr) {
}

public static String parseChannelRemoteAddr(final Channel channel) {
if (null == channel) {
if (channel == null) {
return "";
}

Expand All @@ -67,7 +67,7 @@ public static String parseChannelRemoteAddr(final Channel channel) {
}

public static String parseChannelLocalAddr(final Channel channel) {
if (null == channel) {
if (channel == null) {
return "";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) thro
int bodyLength = 0;

try {
if (null == in) {
if (in == null) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public EventMeshMessageProducer(EventMeshGrpcClientConfig clientConfig, Publishe
@Override
public Response publish(EventMeshMessage message) {

if (null == message) {
if (message == null) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ public static <T> CloudEventBatch buildEventMeshCloudEventBatch(final List<T> me
@SuppressWarnings("unchecked")
public static <T> T buildMessageFromEventMeshCloudEvent(final CloudEvent cloudEvent, final EventMeshProtocolType protocolType) {

if (null == cloudEvent) {
if (cloudEvent == null) {
return null;
}
final String seq = EventMeshCloudEventUtils.getSeqNum(cloudEvent);
Expand All @@ -251,7 +251,7 @@ public static <T> T buildMessageFromEventMeshCloudEvent(final CloudEvent cloudEv

});
}
if (null == protocolType) {
if (protocolType == null) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static void authTokenByPublicKey(AclProperties aclProperties) {
token = token.replace("Bearer ", "");
for (String key : ConfigurationContextUtil.KEYS) {
CommonConfiguration commonConfiguration = ConfigurationContextUtil.get(key);
if (null == commonConfiguration) {
if (commonConfiguration == null) {
continue;
}
if (StringUtils.isBlank(commonConfiguration.getEventMeshSecurityPublickey())) {
Expand Down Expand Up @@ -98,7 +98,7 @@ public static void helloTaskAuthTokenByPublicKey(AclProperties aclProperties) {
token = token.replace("Bearer ", "");
for (String key : ConfigurationContextUtil.KEYS) {
CommonConfiguration commonConfiguration = ConfigurationContextUtil.get(key);
if (null == commonConfiguration) {
if (commonConfiguration == null) {
continue;
}
if (StringUtils.isBlank(commonConfiguration.getEventMeshSecurityPublickey())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public PushConsumerImpl(final Properties properties) {
}
this.rocketmqPushConsumer.setNamesrvAddr(accessPoints.replace(',', ';'));
String consumerGroup = clientConfig.getConsumerId();
if (null == consumerGroup || consumerGroup.isEmpty()) {
if (consumerGroup == null || consumerGroup.isEmpty()) {
throw new StorageRuntimeException(
"Consumer Group is necessary for RocketMQ, please set it.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ public void run() {
hasException = true;
}
long consumeRT = System.currentTimeMillis() - beginTimestamp;
if (null == status) {
if (status == null) {
if (hasException) {
returnType = ConsumeReturnType.EXCEPTION;
} else {
Expand All @@ -457,7 +457,7 @@ public void run() {
Objects.requireNonNull(consumeMessageContext).getProps().put(MixAll.CONSUME_CONTEXT_TYPE, returnType.name());
}

if (null == status) {
if (status == null) {
log.warn("consumeMessage return null, Group: {} Msgs: {} MQ: {}",
ConsumeMessageConcurrentlyService.this.consumerGroup,
msgs,
Expand Down

0 comments on commit e04156b

Please sign in to comment.