You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by he...@apache.org on 2022/03/06 15:22:01 UTC
[incubator-inlong] branch master updated: [INLONG-2934][Manager] Manager client occured NPE since not check NUL (#2950)
This is an automated email from the ASF dual-hosted git repository.
healchow pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-inlong.git
The following commit(s) were added to refs/heads/master by this push:
new 73d4e51 [INLONG-2934][Manager] Manager client occured NPE since not check NUL (#2950)
73d4e51 is described below
commit 73d4e5159ca6c2efbbb5b8c79498c5133b93c5d8
Author: ciscozhou <45...@users.noreply.github.com>
AuthorDate: Sun Mar 6 23:21:54 2022 +0800
[INLONG-2934][Manager] Manager client occured NPE since not check NUL (#2950)
* [INLONG-2934][Manager] Manager client occured NPE since not check NUL
* [INLONG-2934][Manager] Replace Spring's CollectionUtils with Apache's CollectionUtils
* [INLONG-2934][Manager] Add 'filter' when deal with the List
---
.../inlong/manager/client/api/impl/InlongGroupImpl.java | 17 +++++++++++++----
.../client/api/util/InlongStreamSourceTransfer.java | 13 +++++++++----
.../service/core/impl/CommonFileServerServiceImpl.java | 4 ++--
3 files changed, 24 insertions(+), 10 deletions(-)
diff --git a/inlong-manager/manager-client/src/main/java/org/apache/inlong/manager/client/api/impl/InlongGroupImpl.java b/inlong-manager/manager-client/src/main/java/org/apache/inlong/manager/client/api/impl/InlongGroupImpl.java
index 388bef8..c0cbc73 100644
--- a/inlong-manager/manager-client/src/main/java/org/apache/inlong/manager/client/api/impl/InlongGroupImpl.java
+++ b/inlong-manager/manager-client/src/main/java/org/apache/inlong/manager/client/api/impl/InlongGroupImpl.java
@@ -20,6 +20,7 @@ package org.apache.inlong.manager.client.api.impl;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
+import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.inlong.manager.client.api.InlongGroup;
import org.apache.inlong.manager.client.api.InlongGroupConf;
@@ -190,18 +191,26 @@ public class InlongGroupImpl implements InlongGroup {
String inlongGroupId = currentGroupInfo.getInlongGroupId();
//Fetch stream in group
List<InlongStream> dataStreams = fetchDataStreams(inlongGroupId);
- dataStreams.forEach(dataStream -> groupContext.setStream(dataStream));
+ if (CollectionUtils.isNotEmpty(dataStreams)) {
+ dataStreams.forEach(dataStream -> groupContext.setStream(dataStream));
+ }
//Create group context
InlongGroupContext inlongGroupContext = new InlongGroupContext(groupContext, groupConf);
List<EventLogView> logViews = managerClient.getInlongGroupError(inlongGroupId);
- Map<String, String> errMsgs = logViews.stream().collect(
- Collectors.toMap(EventLogView::getEvent, EventLogView::getException));
- inlongGroupContext.setErrMsg(errMsgs);
+ if (CollectionUtils.isNotEmpty(logViews)) {
+ Map<String, String> errMsgs = logViews.stream()
+ .filter(x -> null != x.getEvent() && null != x.getException())
+ .collect(Collectors.toMap(EventLogView::getEvent, EventLogView::getException));
+ inlongGroupContext.setErrMsg(errMsgs);
+ }
return inlongGroupContext;
}
private List<InlongStream> fetchDataStreams(String groupId) {
List<FullStreamResponse> streamResponses = managerClient.listStreamInfo(groupId);
+ if (CollectionUtils.isEmpty(streamResponses)) {
+ return null;
+ }
return streamResponses.stream().map(InlongStreamImpl::new).collect(Collectors.toList());
}
}
diff --git a/inlong-manager/manager-client/src/main/java/org/apache/inlong/manager/client/api/util/InlongStreamSourceTransfer.java b/inlong-manager/manager-client/src/main/java/org/apache/inlong/manager/client/api/util/InlongStreamSourceTransfer.java
index d47f8cb..e46ea2e 100644
--- a/inlong-manager/manager-client/src/main/java/org/apache/inlong/manager/client/api/util/InlongStreamSourceTransfer.java
+++ b/inlong-manager/manager-client/src/main/java/org/apache/inlong/manager/client/api/util/InlongStreamSourceTransfer.java
@@ -18,6 +18,7 @@
package org.apache.inlong.manager.client.api.util;
import com.google.common.base.Joiner;
+import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.inlong.manager.client.api.DataFormat;
import org.apache.inlong.manager.client.api.StreamSource;
@@ -192,10 +193,14 @@ public class InlongStreamSourceTransfer {
sourceRequest.setServerTimezone(binlogSource.getServerTimezone());
sourceRequest.setMonitoredDdl(binlogSource.getMonitoredDdl());
sourceRequest.setAllMigration(binlogSource.isAllMigration());
- String dbNames = Joiner.on(",").join(binlogSource.getDbNames());
- sourceRequest.setDatabaseWhiteList(dbNames);
- String tableNames = Joiner.on(",").join(binlogSource.getTableNames());
- sourceRequest.setTableWhiteList(tableNames);
+ if (CollectionUtils.isNotEmpty(binlogSource.getDbNames())) {
+ String dbNames = Joiner.on(",").join(binlogSource.getDbNames());
+ sourceRequest.setDatabaseWhiteList(dbNames);
+ }
+ if (CollectionUtils.isNotEmpty(binlogSource.getTableNames())) {
+ String tableNames = Joiner.on(",").join(binlogSource.getTableNames());
+ sourceRequest.setTableWhiteList(tableNames);
+ }
sourceRequest.setSnapshotMode("initial");
sourceRequest.setIntervalMs("500");
sourceRequest.setTimestampFormatStandard(binlogSource.getTimestampFormatStandard());
diff --git a/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/impl/CommonFileServerServiceImpl.java b/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/impl/CommonFileServerServiceImpl.java
index 9cf50b9..db6c6a6 100644
--- a/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/impl/CommonFileServerServiceImpl.java
+++ b/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/impl/CommonFileServerServiceImpl.java
@@ -27,6 +27,7 @@ import java.util.Date;
import java.util.HashSet;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections.CollectionUtils;
import org.apache.inlong.manager.common.enums.EntityStatus;
import org.apache.inlong.manager.common.pojo.commonserver.CommonFileServerInfo;
import org.apache.inlong.manager.common.pojo.commonserver.CommonFileServerListVo;
@@ -42,7 +43,6 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
-import org.springframework.util.CollectionUtils;
@Slf4j
@Service
@@ -83,7 +83,7 @@ public class CommonFileServerServiceImpl implements CommonFileServerService {
info.getUsername(),
info.getIp(),
info.getPort());
- if (!CollectionUtils.isEmpty(entities)) {
+ if (CollectionUtils.isNotEmpty(entities)) {
for (CommonFileServerEntity entry : entities) {
// Have the same normal entry
if (entry.getIsDeleted() == 0) {