Skip to content

Commit

Permalink
Supplement #4809 for null != object
Browse files Browse the repository at this point in the history
  • Loading branch information
Pil0tXia committed Apr 14, 2024
1 parent 0b1050a commit c477f0d
Show file tree
Hide file tree
Showing 16 changed files with 27 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ public EventMeshThreadFactory(final String threadNamePrefix) {
public Thread newThread(@Nonnull final Runnable runnable) {

StringBuilder threadName = new StringBuilder(threadNamePrefix);
if (null != threadIndex) {
if (threadIndex != null) {
threadName.append("-").append(threadIndex.incrementAndGet());
}
Thread thread = new Thread(runnable, threadName.toString());
thread.setDaemon(daemon);
if (null != priority) {
if (priority != null) {
thread.setPriority(priority);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ public class SystemUtilsTest {

@Test
public void isLinuxPlatform() {
if (null != SystemUtils.OS_NAME && SystemUtils.OS_NAME.toLowerCase().contains("linux")) {
if (SystemUtils.OS_NAME != null && SystemUtils.OS_NAME.toLowerCase().contains("linux")) {
Assertions.assertTrue(SystemUtils.isLinuxPlatform());
Assertions.assertFalse(SystemUtils.isWindowsPlatform());
}
}

@Test
public void isWindowsPlatform() {
if (null != SystemUtils.OS_NAME && SystemUtils.OS_NAME.toLowerCase().contains("windows")) {
if (SystemUtils.OS_NAME != null && SystemUtils.OS_NAME.toLowerCase().contains("windows")) {
Assertions.assertFalse(SystemUtils.isLinuxPlatform());
Assertions.assertTrue(SystemUtils.isWindowsPlatform());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ protected void registerType(Type type) {
@Override
public String getTypeName(Dialect hibernateDialect, Column<?> column) {
Type type = this.getType(column);
if (null != type) {
if (type != null) {
return type.getTypeName(column);
}
Long length = Optional.ofNullable(column.getColumnLength()).orElse(0L);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public void enterTableOptionCharset(TableOptionCharsetContext ctx) {
@Override
public void enterTableOptionAutoIncrement(TableOptionAutoIncrementContext ctx) {
DecimalLiteralContext decimalLiteralContext = ctx.decimalLiteral();
if (null != decimalLiteralContext) {
if (decimalLiteralContext != null) {
String autoIncrementNumber = Antlr4Utils.getText(decimalLiteralContext);
this.tableEditor.withOption(MysqlTableOptions.AUTO_INCREMENT, autoIncrementNumber);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ private void enableGtidHandle() {
EventMeshGtidSet purgedServerEventMeshGtidSet = new EventMeshGtidSet(purgedServerGtid);

EventMeshGtidSet filteredEventMeshGtidSet = filterGtidSet(context, executedEventMeshGtidSet, purgedServerEventMeshGtidSet);
if (null != filteredEventMeshGtidSet) {
if (filteredEventMeshGtidSet != null) {
client.setGtidSet(filteredEventMeshGtidSet.toString());
this.context.completedGtidSet(filteredEventMeshGtidSet.toString());
localGtidSet = new com.github.shyiko.mysql.binlog.GtidSet(filteredEventMeshGtidSet.toString());
Expand Down Expand Up @@ -645,7 +645,7 @@ private void handleCdcDmlData(MysqlJdbcContext context, MysqlSourceMateData sour
schema.addKeys(tableSchema.getPrimaryKey().getColumnNames());
Pair<Serializable[], BitSet> beforePair = Optional.ofNullable(pair.getLeft()).orElse(new Pair<>());
Serializable[] beforeRows = beforePair.getLeft();
if (null != beforeRows && beforeRows.length != 0) {
if (beforeRows != null && beforeRows.length != 0) {
BitSet includedColumns = beforePair.getRight();
Map<String, Object> beforeValues = new HashMap<>(beforeRows.length);
for (int index = 0; index < columnsSize; ++index) {
Expand All @@ -663,7 +663,7 @@ private void handleCdcDmlData(MysqlJdbcContext context, MysqlSourceMateData sour

Pair<Serializable[], BitSet> afterPair = Optional.ofNullable(pair.getRight()).orElse(new Pair<>());
Serializable[] afterRows = afterPair.getLeft();
if (null != afterRows && afterRows.length != 0) {
if (afterRows != null && afterRows.length != 0) {
BitSet includedColumns = afterPair.getRight();
Map<String, Object> afterValues = new HashMap<>(afterRows.length);
for (int index = 0; index < columnsSize; ++index) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public Table(TableId tableId, PrimaryKey primaryKey, List<UniqueKey> uniqueKeys,
this.primaryKey = primaryKey;
this.uniqueKeys = uniqueKeys;
this.comment = comment;
if (null != options) {
if (options != null) {
this.options.putAll(options);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,12 +313,12 @@ private String createInteractiveContent(ConnectRecord connectRecord, String titl

private boolean needAtAll(ConnectRecord connectRecord) {
String atAll = connectRecord.getExtension(ConnectRecordExtensionKeys.AT_ALL_4_LARK);
return null != atAll && !"null".equals(atAll) && Boolean.parseBoolean(atAll);
return atAll != null && !"null".equals(atAll) && Boolean.parseBoolean(atAll);
}

private String needAtUser(ConnectRecord connectRecord) {
String atUsers = connectRecord.getExtension(ConnectRecordExtensionKeys.AT_USERS_4_LARK);
return null != atUsers && !"null".equals(atUsers) ? atUsers : "";
return atUsers != null && !"null".equals(atUsers) ? atUsers : "";
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public void unbinding(Channel channel, String exchangeName, String routingKey, S
* @param connection connection
*/
public void closeConnection(Connection connection) {
if (null != connection) {
if (connection != null) {
try {
connection.close();
} catch (Exception ex) {
Expand All @@ -135,7 +135,7 @@ public void closeConnection(Connection connection) {
* @param channel channel
*/
public void closeChannel(Channel channel) {
if (null != channel) {
if (channel != null) {
try {
channel.close();
} catch (Exception ex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void init() throws MetaException {
if (initStatus.compareAndSet(false, true)) {
for (String key : ConfigurationContextUtil.KEYS) {
CommonConfiguration commonConfiguration = ConfigurationContextUtil.get(key);
if (null != commonConfiguration) {
if (commonConfiguration != null) {
String metaStorageAddr = commonConfiguration.getMetaStorageAddr();
if (StringUtils.isBlank(metaStorageAddr)) {
throw new MetaException("namesrvAddr cannot be null");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public void shutdown() throws MetaException {
if (!startStatus.compareAndSet(true, false)) {
return;
}
if (null != zkClient) {
if (zkClient != null) {
zkClient.close();
}
log.info("ZookeeperRegistryService closed");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public ProtocolTransportObject fromCloudEvent(CloudEvent cloudEvent) throws Prot
}
httpEventWrapper.setSysHeaderMap(sysHeaderMap);
// ce data
if (null != cloudEvent.getData()) {
if (cloudEvent.getData() != null) {
Map<String, Object> dataContentMap = JsonUtils.parseTypeReferenceObject(
new String(Objects.requireNonNull(cloudEvent.getData()).toBytes(), Constants.DEFAULT_CHARSET),
new TypeReference<Map<String, Object>>() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -451,11 +451,11 @@ public void channelReadComplete(final ChannelHandlerContext ctx) throws Exceptio

@Override
public void exceptionCaught(final ChannelHandlerContext ctx, final Throwable cause) {
if (null != cause) {
if (cause != null) {
log.error("", cause);
}

if (null != ctx) {
if (ctx != null) {
ctx.close();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,15 +238,15 @@ public boolean equals(Object o) {
@Override
public int hashCode() {
int result = 1001; // primeNumber
if (null != client) {
if (client != null) {
result += 31 * result + Objects.hash(client);
}

if (null != context) {
if (context != null) {
result += 31 * result + Objects.hash(context);
}

if (null != sessionState) {
if (sessionState != null) {
result += 31 * result + Objects.hash(sessionState);
}
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ private static String encodingParams(Collection<String> paramValues, String enco
}

private static void setHeaders(HttpURLConnection conn, Collection<String> headers, String encoding) {
if (null != headers) {
if (headers != null) {
for (Iterator<String> iter = headers.iterator(); iter.hasNext();) {
conn.addRequestProperty(iter.next(), iter.next());
}
Expand Down Expand Up @@ -116,7 +116,7 @@ public static HttpResult httpPost(String url, List<String> headers, List<String>

return new HttpResult(respCode, resp);
} finally {
if (null != conn) {
if (conn != null) {
conn.disconnect();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ private static CloudEvent switchEventMeshMessage2EventMeshCloudEvent(EventMeshMe
CloudEventAttributeValue.newBuilder().setCeString(Constants.PROTOCOL_DESC_GRPC_CLOUD_EVENT).build());
attributeValueMap.put(ProtocolKey.PRODUCERGROUP,
CloudEventAttributeValue.newBuilder().setCeString(clientConfig.getProducerGroup()).build());
if (null != message.getTopic()) {
if (message.getTopic() != null) {
attributeValueMap.put(ProtocolKey.SUBJECT, CloudEventAttributeValue.newBuilder().setCeString(message.getTopic()).build());
}
attributeValueMap.put(ProtocolKey.DATA_CONTENT_TYPE, CloudEventAttributeValue.newBuilder().setCeString("text/plain").build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public void unbinding(Channel channel, String exchangeName, String routingKey, S
* @param connection connection
*/
public void closeConnection(Connection connection) {
if (null != connection) {
if (connection != null) {
try {
connection.close();
} catch (Exception ex) {
Expand All @@ -135,7 +135,7 @@ public void closeConnection(Connection connection) {
* @param channel channel
*/
public void closeChannel(Channel channel) {
if (null != channel) {
if (channel != null) {
try {
channel.close();
} catch (Exception ex) {
Expand Down

0 comments on commit c477f0d

Please sign in to comment.