-
Notifications
You must be signed in to change notification settings - Fork 23
fix: dont NPE if initializing odo fails (#536) #589
Conversation
@sbouchet this PR has 2 commits:
The 2nd commit tries to achieve the following: public CompletableFuture<Odo> getOdo() {
if (odoFuture == null) {
this.odoFuture = OdoCliFactory.getInstance()
.getOdo(project)
.whenComplete((odo, err) -> structure.fireModified(this));
}
return odoFuture;
} The existing code does this differently. The public CompletableFuture<Odo> initializeOdo() {
return OdoCliFactory.getInstance().getOdo(project).whenComplete((odo, err) -> {
if (this.odo != null) {
this.odo.release();
return OdoCliFactory.getInstance().getOdo(project).handle((odo, e) -> {
if (e != null) {
setError(new RuntimeException("Could not initialize Odo", e.getCause()));
return null;
} else {
setOdo(odo);
return odo;
} There are 2 things that I dont like here:
I tried to address this as follows:
As a result of this change any time user code wants to use the odo binary it has to try/catch to get errors that may have happened when loading the binary and null-check in case the odo binary wasnt loaded yet: try {
Odo odo = componentNode.getRoot().getOdo().getNow(null);
if (odo == null) {
return;
}
...
} catch (Exception ex) { |
fe39db2
to
e606787
Compare
I like the idea to just call getOdo() that returns a future. this will also simplyfy the codebase by removing the odoprojectdecorator class. +1 for implement this. |
src/main/java/org/jboss/tools/intellij/openshift/utils/odo/OdoProjectDecorator.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can confirm that this presents the error in the OpenShift tree view when the tools.json is corrupted. The refactoring looks good as well. Thanks, Andre!
src/main/java/org/jboss/tools/intellij/openshift/utils/odo/OdoProjectDecorator.java
Outdated
Show resolved
Hide resolved
src/main/java/org/jboss/tools/intellij/openshift/actions/binding/DeleteBindingAction.java
Outdated
Show resolved
Hide resolved
src/main/java/org/jboss/tools/intellij/openshift/actions/cluster/AboutAction.java
Outdated
Show resolved
Hide resolved
src/main/java/org/jboss/tools/intellij/openshift/actions/cluster/ListComponentsAction.java
Outdated
Show resolved
Hide resolved
src/main/java/org/jboss/tools/intellij/openshift/tree/application/ApplicationsRootNode.java
Show resolved
Hide resolved
...main/java/org/jboss/tools/intellij/openshift/tree/application/ApplicationsTreeStructure.java
Show resolved
Hide resolved
a4b1186
to
8af4642
Compare
There are none left. Sonar keeps reporting 2 false positives which I need to close manually on each push. |
@sbouchet corrected things according to your comments. Please re-review. |
seems also that test coverage is missing. need to address that in anotherissue |
209ebe1
to
82ff4db
Compare
I agree. Looked through my changes and all what could make sense here imho is to add a test for |
8a53223
to
dd9ae3f
Compare
@sbouchet I added a unit test for |
Signed-off-by: Andre Dietisheim <[email protected]>
Signed-off-by: Andre Dietisheim <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with finals changes.
/override ci/prow/e2e-4.11 |
@sbouchet: Overrode contexts on behalf of sbouchet: ci/prow/e2e-4.11 In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
SonarCloud Quality Gate failed.
|
/check-required-labels |
/approve |
/refresh |
fixes #536