From c477f0d77d1770382d235fa0fcfa674ed107a935 Mon Sep 17 00:00:00 2001 From: Pil0tXia Date: Sun, 14 Apr 2024 21:27:46 +0800 Subject: [PATCH] Supplement https://github.com/apache/eventmesh/pull/4809 for `null != object` --- .../org/apache/eventmesh/common/EventMeshThreadFactory.java | 4 ++-- .../org/apache/eventmesh/common/utils/SystemUtilsTest.java | 4 ++-- .../jdbc/dialect/AbstractGeneralDatabaseDialect.java | 2 +- .../antlr4/mysql/listener/CreateTableParserListener.java | 2 +- .../jdbc/source/dialect/cdc/mysql/MysqlCdcEngine.java | 6 +++--- .../eventmesh/connector/jdbc/table/catalog/Table.java | 2 +- .../eventmesh/connector/lark/sink/ImServiceHandler.java | 4 ++-- .../eventmesh/connector/rabbitmq/client/RabbitmqClient.java | 4 ++-- .../eventmesh/meta/consul/service/ConsulMetaService.java | 2 +- .../meta/zookeeper/service/ZookeeperMetaService.java | 2 +- .../apache/eventmesh/protocol/http/HttpProtocolAdaptor.java | 2 +- .../apache/eventmesh/runtime/boot/AbstractHTTPServer.java | 4 ++-- .../runtime/core/protocol/tcp/client/session/Session.java | 6 +++--- .../org/apache/eventmesh/runtime/util/HttpTinyClient.java | 4 ++-- .../client/grpc/util/EventMeshCloudEventBuilder.java | 2 +- .../eventmesh/storage/rabbitmq/client/RabbitmqClient.java | 4 ++-- 16 files changed, 27 insertions(+), 27 deletions(-) diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/EventMeshThreadFactory.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/EventMeshThreadFactory.java index 0442ef1286..d18ec5a048 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/EventMeshThreadFactory.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/EventMeshThreadFactory.java @@ -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); } diff --git a/eventmesh-common/src/test/java/org/apache/eventmesh/common/utils/SystemUtilsTest.java b/eventmesh-common/src/test/java/org/apache/eventmesh/common/utils/SystemUtilsTest.java index b941fee1d4..32f4ae946e 100644 --- a/eventmesh-common/src/test/java/org/apache/eventmesh/common/utils/SystemUtilsTest.java +++ b/eventmesh-common/src/test/java/org/apache/eventmesh/common/utils/SystemUtilsTest.java @@ -24,7 +24,7 @@ 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()); } @@ -32,7 +32,7 @@ public void isLinuxPlatform() { @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()); } diff --git a/eventmesh-connectors/eventmesh-connector-jdbc/src/main/java/org/apache/eventmesh/connector/jdbc/dialect/AbstractGeneralDatabaseDialect.java b/eventmesh-connectors/eventmesh-connector-jdbc/src/main/java/org/apache/eventmesh/connector/jdbc/dialect/AbstractGeneralDatabaseDialect.java index 64bde49935..0a7463a187 100644 --- a/eventmesh-connectors/eventmesh-connector-jdbc/src/main/java/org/apache/eventmesh/connector/jdbc/dialect/AbstractGeneralDatabaseDialect.java +++ b/eventmesh-connectors/eventmesh-connector-jdbc/src/main/java/org/apache/eventmesh/connector/jdbc/dialect/AbstractGeneralDatabaseDialect.java @@ -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); diff --git a/eventmesh-connectors/eventmesh-connector-jdbc/src/main/java/org/apache/eventmesh/connector/jdbc/source/dialect/antlr4/mysql/listener/CreateTableParserListener.java b/eventmesh-connectors/eventmesh-connector-jdbc/src/main/java/org/apache/eventmesh/connector/jdbc/source/dialect/antlr4/mysql/listener/CreateTableParserListener.java index c24f885d75..4e30da93f9 100644 --- a/eventmesh-connectors/eventmesh-connector-jdbc/src/main/java/org/apache/eventmesh/connector/jdbc/source/dialect/antlr4/mysql/listener/CreateTableParserListener.java +++ b/eventmesh-connectors/eventmesh-connector-jdbc/src/main/java/org/apache/eventmesh/connector/jdbc/source/dialect/antlr4/mysql/listener/CreateTableParserListener.java @@ -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); } diff --git a/eventmesh-connectors/eventmesh-connector-jdbc/src/main/java/org/apache/eventmesh/connector/jdbc/source/dialect/cdc/mysql/MysqlCdcEngine.java b/eventmesh-connectors/eventmesh-connector-jdbc/src/main/java/org/apache/eventmesh/connector/jdbc/source/dialect/cdc/mysql/MysqlCdcEngine.java index 645e5c9eca..5650c3d0cc 100644 --- a/eventmesh-connectors/eventmesh-connector-jdbc/src/main/java/org/apache/eventmesh/connector/jdbc/source/dialect/cdc/mysql/MysqlCdcEngine.java +++ b/eventmesh-connectors/eventmesh-connector-jdbc/src/main/java/org/apache/eventmesh/connector/jdbc/source/dialect/cdc/mysql/MysqlCdcEngine.java @@ -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()); @@ -645,7 +645,7 @@ private void handleCdcDmlData(MysqlJdbcContext context, MysqlSourceMateData sour schema.addKeys(tableSchema.getPrimaryKey().getColumnNames()); Pair 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 beforeValues = new HashMap<>(beforeRows.length); for (int index = 0; index < columnsSize; ++index) { @@ -663,7 +663,7 @@ private void handleCdcDmlData(MysqlJdbcContext context, MysqlSourceMateData sour Pair 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 afterValues = new HashMap<>(afterRows.length); for (int index = 0; index < columnsSize; ++index) { diff --git a/eventmesh-connectors/eventmesh-connector-jdbc/src/main/java/org/apache/eventmesh/connector/jdbc/table/catalog/Table.java b/eventmesh-connectors/eventmesh-connector-jdbc/src/main/java/org/apache/eventmesh/connector/jdbc/table/catalog/Table.java index c475227248..158ffc81da 100644 --- a/eventmesh-connectors/eventmesh-connector-jdbc/src/main/java/org/apache/eventmesh/connector/jdbc/table/catalog/Table.java +++ b/eventmesh-connectors/eventmesh-connector-jdbc/src/main/java/org/apache/eventmesh/connector/jdbc/table/catalog/Table.java @@ -48,7 +48,7 @@ public Table(TableId tableId, PrimaryKey primaryKey, List uniqueKeys, this.primaryKey = primaryKey; this.uniqueKeys = uniqueKeys; this.comment = comment; - if (null != options) { + if (options != null) { this.options.putAll(options); } } diff --git a/eventmesh-connectors/eventmesh-connector-lark/src/main/java/org/apache/eventmesh/connector/lark/sink/ImServiceHandler.java b/eventmesh-connectors/eventmesh-connector-lark/src/main/java/org/apache/eventmesh/connector/lark/sink/ImServiceHandler.java index 4797d58ef9..75e51e690b 100644 --- a/eventmesh-connectors/eventmesh-connector-lark/src/main/java/org/apache/eventmesh/connector/lark/sink/ImServiceHandler.java +++ b/eventmesh-connectors/eventmesh-connector-lark/src/main/java/org/apache/eventmesh/connector/lark/sink/ImServiceHandler.java @@ -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 : ""; } /** diff --git a/eventmesh-connectors/eventmesh-connector-rabbitmq/src/main/java/org/apache/eventmesh/connector/rabbitmq/client/RabbitmqClient.java b/eventmesh-connectors/eventmesh-connector-rabbitmq/src/main/java/org/apache/eventmesh/connector/rabbitmq/client/RabbitmqClient.java index 34cda9620e..1f324b5847 100644 --- a/eventmesh-connectors/eventmesh-connector-rabbitmq/src/main/java/org/apache/eventmesh/connector/rabbitmq/client/RabbitmqClient.java +++ b/eventmesh-connectors/eventmesh-connector-rabbitmq/src/main/java/org/apache/eventmesh/connector/rabbitmq/client/RabbitmqClient.java @@ -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) { @@ -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) { diff --git a/eventmesh-meta/eventmesh-meta-consul/src/main/java/org/apache/eventmesh/meta/consul/service/ConsulMetaService.java b/eventmesh-meta/eventmesh-meta-consul/src/main/java/org/apache/eventmesh/meta/consul/service/ConsulMetaService.java index 2d9b921efb..a3849d2cc8 100644 --- a/eventmesh-meta/eventmesh-meta-consul/src/main/java/org/apache/eventmesh/meta/consul/service/ConsulMetaService.java +++ b/eventmesh-meta/eventmesh-meta-consul/src/main/java/org/apache/eventmesh/meta/consul/service/ConsulMetaService.java @@ -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"); diff --git a/eventmesh-meta/eventmesh-meta-zookeeper/src/main/java/org/apache/eventmesh/meta/zookeeper/service/ZookeeperMetaService.java b/eventmesh-meta/eventmesh-meta-zookeeper/src/main/java/org/apache/eventmesh/meta/zookeeper/service/ZookeeperMetaService.java index 359e7427f0..18520feb4d 100644 --- a/eventmesh-meta/eventmesh-meta-zookeeper/src/main/java/org/apache/eventmesh/meta/zookeeper/service/ZookeeperMetaService.java +++ b/eventmesh-meta/eventmesh-meta-zookeeper/src/main/java/org/apache/eventmesh/meta/zookeeper/service/ZookeeperMetaService.java @@ -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"); diff --git a/eventmesh-protocol-plugin/eventmesh-protocol-http/src/main/java/org/apache/eventmesh/protocol/http/HttpProtocolAdaptor.java b/eventmesh-protocol-plugin/eventmesh-protocol-http/src/main/java/org/apache/eventmesh/protocol/http/HttpProtocolAdaptor.java index a232781ff6..08c4718825 100644 --- a/eventmesh-protocol-plugin/eventmesh-protocol-http/src/main/java/org/apache/eventmesh/protocol/http/HttpProtocolAdaptor.java +++ b/eventmesh-protocol-plugin/eventmesh-protocol-http/src/main/java/org/apache/eventmesh/protocol/http/HttpProtocolAdaptor.java @@ -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 dataContentMap = JsonUtils.parseTypeReferenceObject( new String(Objects.requireNonNull(cloudEvent.getData()).toBytes(), Constants.DEFAULT_CHARSET), new TypeReference>() { diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/AbstractHTTPServer.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/AbstractHTTPServer.java index 8dd9525170..5065b73a01 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/AbstractHTTPServer.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/AbstractHTTPServer.java @@ -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(); } } diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/session/Session.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/session/Session.java index 37c5a1e372..e2e36690a6 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/session/Session.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/session/Session.java @@ -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; diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/util/HttpTinyClient.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/util/HttpTinyClient.java index 38d3019de3..24142a6821 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/util/HttpTinyClient.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/util/HttpTinyClient.java @@ -80,7 +80,7 @@ private static String encodingParams(Collection paramValues, String enco } private static void setHeaders(HttpURLConnection conn, Collection headers, String encoding) { - if (null != headers) { + if (headers != null) { for (Iterator iter = headers.iterator(); iter.hasNext();) { conn.addRequestProperty(iter.next(), iter.next()); } @@ -116,7 +116,7 @@ public static HttpResult httpPost(String url, List headers, List return new HttpResult(respCode, resp); } finally { - if (null != conn) { + if (conn != null) { conn.disconnect(); } } diff --git a/eventmesh-sdks/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/util/EventMeshCloudEventBuilder.java b/eventmesh-sdks/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/util/EventMeshCloudEventBuilder.java index f7ab40c20a..5621b41e0f 100644 --- a/eventmesh-sdks/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/util/EventMeshCloudEventBuilder.java +++ b/eventmesh-sdks/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/util/EventMeshCloudEventBuilder.java @@ -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()); diff --git a/eventmesh-storage-plugin/eventmesh-storage-rabbitmq/src/main/java/org/apache/eventmesh/storage/rabbitmq/client/RabbitmqClient.java b/eventmesh-storage-plugin/eventmesh-storage-rabbitmq/src/main/java/org/apache/eventmesh/storage/rabbitmq/client/RabbitmqClient.java index 4e44c77fe3..678ba0884d 100644 --- a/eventmesh-storage-plugin/eventmesh-storage-rabbitmq/src/main/java/org/apache/eventmesh/storage/rabbitmq/client/RabbitmqClient.java +++ b/eventmesh-storage-plugin/eventmesh-storage-rabbitmq/src/main/java/org/apache/eventmesh/storage/rabbitmq/client/RabbitmqClient.java @@ -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) { @@ -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) {