Skip to content

Commit c477f0d

Browse files
committed
Supplement apache#4809 for null != object
1 parent 0b1050a commit c477f0d

File tree

16 files changed

+27
-27
lines changed

16 files changed

+27
-27
lines changed

eventmesh-common/src/main/java/org/apache/eventmesh/common/EventMeshThreadFactory.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@ public EventMeshThreadFactory(final String threadNamePrefix) {
6767
public Thread newThread(@Nonnull final Runnable runnable) {
6868

6969
StringBuilder threadName = new StringBuilder(threadNamePrefix);
70-
if (null != threadIndex) {
70+
if (threadIndex != null) {
7171
threadName.append("-").append(threadIndex.incrementAndGet());
7272
}
7373
Thread thread = new Thread(runnable, threadName.toString());
7474
thread.setDaemon(daemon);
75-
if (null != priority) {
75+
if (priority != null) {
7676
thread.setPriority(priority);
7777
}
7878

eventmesh-common/src/test/java/org/apache/eventmesh/common/utils/SystemUtilsTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ public class SystemUtilsTest {
2424

2525
@Test
2626
public void isLinuxPlatform() {
27-
if (null != SystemUtils.OS_NAME && SystemUtils.OS_NAME.toLowerCase().contains("linux")) {
27+
if (SystemUtils.OS_NAME != null && SystemUtils.OS_NAME.toLowerCase().contains("linux")) {
2828
Assertions.assertTrue(SystemUtils.isLinuxPlatform());
2929
Assertions.assertFalse(SystemUtils.isWindowsPlatform());
3030
}
3131
}
3232

3333
@Test
3434
public void isWindowsPlatform() {
35-
if (null != SystemUtils.OS_NAME && SystemUtils.OS_NAME.toLowerCase().contains("windows")) {
35+
if (SystemUtils.OS_NAME != null && SystemUtils.OS_NAME.toLowerCase().contains("windows")) {
3636
Assertions.assertFalse(SystemUtils.isLinuxPlatform());
3737
Assertions.assertTrue(SystemUtils.isWindowsPlatform());
3838
}

eventmesh-connectors/eventmesh-connector-jdbc/src/main/java/org/apache/eventmesh/connector/jdbc/dialect/AbstractGeneralDatabaseDialect.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ protected void registerType(Type type) {
146146
@Override
147147
public String getTypeName(Dialect hibernateDialect, Column<?> column) {
148148
Type type = this.getType(column);
149-
if (null != type) {
149+
if (type != null) {
150150
return type.getTypeName(column);
151151
}
152152
Long length = Optional.ofNullable(column.getColumnLength()).orElse(0L);

eventmesh-connectors/eventmesh-connector-jdbc/src/main/java/org/apache/eventmesh/connector/jdbc/source/dialect/antlr4/mysql/listener/CreateTableParserListener.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public void enterTableOptionCharset(TableOptionCharsetContext ctx) {
166166
@Override
167167
public void enterTableOptionAutoIncrement(TableOptionAutoIncrementContext ctx) {
168168
DecimalLiteralContext decimalLiteralContext = ctx.decimalLiteral();
169-
if (null != decimalLiteralContext) {
169+
if (decimalLiteralContext != null) {
170170
String autoIncrementNumber = Antlr4Utils.getText(decimalLiteralContext);
171171
this.tableEditor.withOption(MysqlTableOptions.AUTO_INCREMENT, autoIncrementNumber);
172172
}

eventmesh-connectors/eventmesh-connector-jdbc/src/main/java/org/apache/eventmesh/connector/jdbc/source/dialect/cdc/mysql/MysqlCdcEngine.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ private void enableGtidHandle() {
392392
EventMeshGtidSet purgedServerEventMeshGtidSet = new EventMeshGtidSet(purgedServerGtid);
393393

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

664664
Pair<Serializable[], BitSet> afterPair = Optional.ofNullable(pair.getRight()).orElse(new Pair<>());
665665
Serializable[] afterRows = afterPair.getLeft();
666-
if (null != afterRows && afterRows.length != 0) {
666+
if (afterRows != null && afterRows.length != 0) {
667667
BitSet includedColumns = afterPair.getRight();
668668
Map<String, Object> afterValues = new HashMap<>(afterRows.length);
669669
for (int index = 0; index < columnsSize; ++index) {

eventmesh-connectors/eventmesh-connector-jdbc/src/main/java/org/apache/eventmesh/connector/jdbc/table/catalog/Table.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public Table(TableId tableId, PrimaryKey primaryKey, List<UniqueKey> uniqueKeys,
4848
this.primaryKey = primaryKey;
4949
this.uniqueKeys = uniqueKeys;
5050
this.comment = comment;
51-
if (null != options) {
51+
if (options != null) {
5252
this.options.putAll(options);
5353
}
5454
}

eventmesh-connectors/eventmesh-connector-lark/src/main/java/org/apache/eventmesh/connector/lark/sink/ImServiceHandler.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -313,12 +313,12 @@ private String createInteractiveContent(ConnectRecord connectRecord, String titl
313313

314314
private boolean needAtAll(ConnectRecord connectRecord) {
315315
String atAll = connectRecord.getExtension(ConnectRecordExtensionKeys.AT_ALL_4_LARK);
316-
return null != atAll && !"null".equals(atAll) && Boolean.parseBoolean(atAll);
316+
return atAll != null && !"null".equals(atAll) && Boolean.parseBoolean(atAll);
317317
}
318318

319319
private String needAtUser(ConnectRecord connectRecord) {
320320
String atUsers = connectRecord.getExtension(ConnectRecordExtensionKeys.AT_USERS_4_LARK);
321-
return null != atUsers && !"null".equals(atUsers) ? atUsers : "";
321+
return atUsers != null && !"null".equals(atUsers) ? atUsers : "";
322322
}
323323

324324
/**

eventmesh-connectors/eventmesh-connector-rabbitmq/src/main/java/org/apache/eventmesh/connector/rabbitmq/client/RabbitmqClient.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public void unbinding(Channel channel, String exchangeName, String routingKey, S
120120
* @param connection connection
121121
*/
122122
public void closeConnection(Connection connection) {
123-
if (null != connection) {
123+
if (connection != null) {
124124
try {
125125
connection.close();
126126
} catch (Exception ex) {
@@ -135,7 +135,7 @@ public void closeConnection(Connection connection) {
135135
* @param channel channel
136136
*/
137137
public void closeChannel(Channel channel) {
138-
if (null != channel) {
138+
if (channel != null) {
139139
try {
140140
channel.close();
141141
} catch (Exception ex) {

eventmesh-meta/eventmesh-meta-consul/src/main/java/org/apache/eventmesh/meta/consul/service/ConsulMetaService.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public void init() throws MetaException {
7272
if (initStatus.compareAndSet(false, true)) {
7373
for (String key : ConfigurationContextUtil.KEYS) {
7474
CommonConfiguration commonConfiguration = ConfigurationContextUtil.get(key);
75-
if (null != commonConfiguration) {
75+
if (commonConfiguration != null) {
7676
String metaStorageAddr = commonConfiguration.getMetaStorageAddr();
7777
if (StringUtils.isBlank(metaStorageAddr)) {
7878
throw new MetaException("namesrvAddr cannot be null");

eventmesh-meta/eventmesh-meta-zookeeper/src/main/java/org/apache/eventmesh/meta/zookeeper/service/ZookeeperMetaService.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ public void shutdown() throws MetaException {
175175
if (!startStatus.compareAndSet(true, false)) {
176176
return;
177177
}
178-
if (null != zkClient) {
178+
if (zkClient != null) {
179179
zkClient.close();
180180
}
181181
log.info("ZookeeperRegistryService closed");

eventmesh-protocol-plugin/eventmesh-protocol-http/src/main/java/org/apache/eventmesh/protocol/http/HttpProtocolAdaptor.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public ProtocolTransportObject fromCloudEvent(CloudEvent cloudEvent) throws Prot
9797
}
9898
httpEventWrapper.setSysHeaderMap(sysHeaderMap);
9999
// ce data
100-
if (null != cloudEvent.getData()) {
100+
if (cloudEvent.getData() != null) {
101101
Map<String, Object> dataContentMap = JsonUtils.parseTypeReferenceObject(
102102
new String(Objects.requireNonNull(cloudEvent.getData()).toBytes(), Constants.DEFAULT_CHARSET),
103103
new TypeReference<Map<String, Object>>() {

eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/AbstractHTTPServer.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -451,11 +451,11 @@ public void channelReadComplete(final ChannelHandlerContext ctx) throws Exceptio
451451

452452
@Override
453453
public void exceptionCaught(final ChannelHandlerContext ctx, final Throwable cause) {
454-
if (null != cause) {
454+
if (cause != null) {
455455
log.error("", cause);
456456
}
457457

458-
if (null != ctx) {
458+
if (ctx != null) {
459459
ctx.close();
460460
}
461461
}

eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/session/Session.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -238,15 +238,15 @@ public boolean equals(Object o) {
238238
@Override
239239
public int hashCode() {
240240
int result = 1001; // primeNumber
241-
if (null != client) {
241+
if (client != null) {
242242
result += 31 * result + Objects.hash(client);
243243
}
244244

245-
if (null != context) {
245+
if (context != null) {
246246
result += 31 * result + Objects.hash(context);
247247
}
248248

249-
if (null != sessionState) {
249+
if (sessionState != null) {
250250
result += 31 * result + Objects.hash(sessionState);
251251
}
252252
return result;

eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/util/HttpTinyClient.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ private static String encodingParams(Collection<String> paramValues, String enco
8080
}
8181

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

117117
return new HttpResult(respCode, resp);
118118
} finally {
119-
if (null != conn) {
119+
if (conn != null) {
120120
conn.disconnect();
121121
}
122122
}

eventmesh-sdks/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/util/EventMeshCloudEventBuilder.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ private static CloudEvent switchEventMeshMessage2EventMeshCloudEvent(EventMeshMe
157157
CloudEventAttributeValue.newBuilder().setCeString(Constants.PROTOCOL_DESC_GRPC_CLOUD_EVENT).build());
158158
attributeValueMap.put(ProtocolKey.PRODUCERGROUP,
159159
CloudEventAttributeValue.newBuilder().setCeString(clientConfig.getProducerGroup()).build());
160-
if (null != message.getTopic()) {
160+
if (message.getTopic() != null) {
161161
attributeValueMap.put(ProtocolKey.SUBJECT, CloudEventAttributeValue.newBuilder().setCeString(message.getTopic()).build());
162162
}
163163
attributeValueMap.put(ProtocolKey.DATA_CONTENT_TYPE, CloudEventAttributeValue.newBuilder().setCeString("text/plain").build());

eventmesh-storage-plugin/eventmesh-storage-rabbitmq/src/main/java/org/apache/eventmesh/storage/rabbitmq/client/RabbitmqClient.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public void unbinding(Channel channel, String exchangeName, String routingKey, S
120120
* @param connection connection
121121
*/
122122
public void closeConnection(Connection connection) {
123-
if (null != connection) {
123+
if (connection != null) {
124124
try {
125125
connection.close();
126126
} catch (Exception ex) {
@@ -135,7 +135,7 @@ public void closeConnection(Connection connection) {
135135
* @param channel channel
136136
*/
137137
public void closeChannel(Channel channel) {
138-
if (null != channel) {
138+
if (channel != null) {
139139
try {
140140
channel.close();
141141
} catch (Exception ex) {

0 commit comments

Comments
 (0)