You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bookkeeper.apache.org by eo...@apache.org on 2021/01/27 07:27:09 UTC
[bookkeeper] branch branch-4.12 updated: Check np for
LifecycleComponent close
This is an automated email from the ASF dual-hosted git repository.
eolivelli pushed a commit to branch branch-4.12
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git
The following commit(s) were added to refs/heads/branch-4.12 by this push:
new bf8d2ea Check np for LifecycleComponent close
bf8d2ea is described below
commit bf8d2ea82cb43e33e196b81daf5acc8b8c3e294e
Author: Rudy Steiner <ru...@163.com>
AuthorDate: Wed Jan 27 15:26:44 2021 +0800
Check np for LifecycleComponent close
Descriptions of the changes in this PR:
Check NP of BookKeeper Stream Storage Server LifecycleComponents
### Motivation
Fix issue #2505
### Changes
(Describe: what changes you have made)
Master Issue: #2505
Reviewers: Flavio Paiva Junqueira <fp...@apache.org>, Enrico Olivelli <eo...@apache.org>
This closes #2542 from rudy2steiner/Stream_npe_check
(cherry picked from commit e0e3e3442e09d56c6f33e87c31799a3876ea1c95)
Signed-off-by: Enrico Olivelli <eo...@apache.org>
---
.../apache/bookkeeper/stream/server/service/GrpcService.java | 8 ++++++--
.../stream/server/service/RegistrationStateService.java | 12 ++++++++++--
.../bookkeeper/stream/server/service/StorageService.java | 4 +++-
3 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/stream/server/src/main/java/org/apache/bookkeeper/stream/server/service/GrpcService.java b/stream/server/src/main/java/org/apache/bookkeeper/stream/server/service/GrpcService.java
index 1056590..bef2ddf 100644
--- a/stream/server/src/main/java/org/apache/bookkeeper/stream/server/service/GrpcService.java
+++ b/stream/server/src/main/java/org/apache/bookkeeper/stream/server/service/GrpcService.java
@@ -43,11 +43,15 @@ public class GrpcService extends AbstractLifecycleComponent<StorageServerConfigu
@Override
protected void doStop() {
- this.server.stop();
+ if (null != server) {
+ this.server.stop();
+ }
}
@Override
protected void doClose() throws IOException {
- this.server.close();
+ if (null != server) {
+ this.server.close();
+ }
}
}
diff --git a/stream/server/src/main/java/org/apache/bookkeeper/stream/server/service/RegistrationStateService.java b/stream/server/src/main/java/org/apache/bookkeeper/stream/server/service/RegistrationStateService.java
index df34e87..8a47b8c 100644
--- a/stream/server/src/main/java/org/apache/bookkeeper/stream/server/service/RegistrationStateService.java
+++ b/stream/server/src/main/java/org/apache/bookkeeper/stream/server/service/RegistrationStateService.java
@@ -95,6 +95,10 @@ public class RegistrationStateService
@Override
protected void doStop() {
+ if (null == stateManager) {
+ log.info("State Manager is null, no need to stop it.");
+ return;
+ }
stateManager.forceToShuttingDown();
// turn the server to readonly during shutting down process
@@ -104,7 +108,11 @@ public class RegistrationStateService
@Override
protected void doClose() throws IOException {
- stateManager.close();
- regManager.close();
+ if (null != stateManager) {
+ stateManager.close();
+ }
+ if (null != regManager) {
+ regManager.close();
+ }
}
}
diff --git a/stream/server/src/main/java/org/apache/bookkeeper/stream/server/service/StorageService.java b/stream/server/src/main/java/org/apache/bookkeeper/stream/server/service/StorageService.java
index 2ac1804..4aedd4e 100644
--- a/stream/server/src/main/java/org/apache/bookkeeper/stream/server/service/StorageService.java
+++ b/stream/server/src/main/java/org/apache/bookkeeper/stream/server/service/StorageService.java
@@ -54,7 +54,9 @@ public class StorageService
@Override
protected void doClose() throws IOException {
- store.close();
+ if (null != store) {
+ store.close();
+ }
}
@Override