Skip to content

Fix NPE and NumberFormatException in some cases#11114

Merged
garagatyi merged 1 commit intoeclipse-che:masterfrom
garagatyi:fixRamLimits
Sep 10, 2018
Merged

Fix NPE and NumberFormatException in some cases#11114
garagatyi merged 1 commit intoeclipse-che:masterfrom
garagatyi:fixRamLimits

Conversation

@garagatyi
Copy link
Copy Markdown

@garagatyi garagatyi commented Sep 7, 2018

What does this PR do?

Fix NPE on the start of a workspace created from the Theia stack.
Fix NumberFormatException when a machine doesn't have memory
property.

What issues does this PR fix or reference?

Fixes #11134

Release Notes

Docs PR

Fix NPE on start of a workspace created from the Theia stack.
Fix NumberFormatException when machine doesn't have memory
property.
Signed-off-by: Oleksandr Garagatyi <ogaragat@redhat.com>
@benoitf benoitf added kind/bug Outline of a bug - must adhere to the bug report template. status/code-review This issue has a pull request posted for it and is awaiting code review completion by the community. labels Sep 7, 2018
Containers.addRamLimit(container, Long.parseLong(attributes.get(MEMORY_LIMIT_ATTRIBUTE)));
String memoryLimitAttribute = attributes.get(MEMORY_LIMIT_ATTRIBUTE);
if (memoryLimitAttribute != null) {
Containers.addRamLimit(container, Long.parseLong(memoryLimitAttribute));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's like an unusual case since we have configuration properties for configuring default values for machines memory if they are not specified explicitly. Should it be logged as a warning?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that a method shouldn't throw an NPE if it doesn't declare it. And in any case, a logic of a class depending on the logic of some other classes (or system overall) might be treated as an encapsulation violation. One might argue that it is called architecture, but in this particular case, I don't see this situation as an architectural decision.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. Ok to me leave it as it is

Copy link
Copy Markdown
Member

@sleshchenko sleshchenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@garagatyi garagatyi merged commit 028d1a7 into eclipse-che:master Sep 10, 2018
@garagatyi garagatyi deleted the fixRamLimits branch September 10, 2018 08:34
@benoitf benoitf removed the status/code-review This issue has a pull request posted for it and is awaiting code review completion by the community. label Sep 10, 2018
@benoitf benoitf added this to the 6.11.0 milestone Sep 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Outline of a bug - must adhere to the bug report template.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot create workspace from 'Java Theia on OpenShift' stack

3 participants