Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Protect NPE in CMRI connection preferences #2734

Closed
wants to merge 31 commits into from
Closed

Protect NPE in CMRI connection preferences #2734

wants to merge 31 commits into from

Conversation

KenC57
Copy link
Contributor

@KenC57 KenC57 commented Dec 20, 2016

User was tripping on one of the spots, checking for similar, I found 2 other places nulls were showing and causing NPE's.

String value = "";
for (int i = 0; i < node.getLocSearchLightBits().length; i++) {
value = value + Integer.toHexString(node.getLocSearchLightBits()[i] & 0xF);
if (tc != null) {
Copy link
Member

Choose a reason for hiding this comment

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

I think that if this code runs with tc==null, you're going to store without the node definitions, thereby losing the node definitions. Is that really what you want?

@@ -38,7 +38,9 @@ public String name() {

public void loadDetails(JPanel details) {

b.addActionListener(new NodeConfigAction((CMRISystemConnectionMemo)adapter.getSystemConnectionMemo()));
if (adapter != null) {
b.addActionListener(new NodeConfigAction((CMRISystemConnectionMemo)adapter.getSystemConnectionMemo()));
Copy link
Member

Choose a reason for hiding this comment

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

If this runs with adapter==null, it won't crash right away, but it will behave oddly later on (because the listener won't be present). I'm much rather see a Large Amount of information being logged here so we have some chance of tracking down the real problem, which is the null adapter value.

String value = "";
for (int i = 0; i < node.getLocSearchLightBits().length; i++) {
value = value + Integer.toHexString(node.getLocSearchLightBits()[i] & 0xF);
if (tc != null) {
Copy link
Member

Choose a reason for hiding this comment

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

Similar to the other comment on this commit, I think this will write a configuration file that doesn't contain, hence loses for all time, the node information.

@KenC57
Copy link
Contributor Author

KenC57 commented Dec 21, 2016 via email

@KenC57
Copy link
Contributor Author

KenC57 commented Dec 21, 2016 via email

@KenC57
Copy link
Contributor Author

KenC57 commented Dec 21, 2016

I'm thinking that to track down why we end up with the tc or adapter null would be setting a trap in the code where those live and throw exception if something tries to set them to null. That would help find when a 'good' configuration is going bad. But the case of a 'new' configuration not getting setup right in the first place, that's another story.
-ken c

@bobjacobsen
Copy link
Member

bobjacobsen commented Dec 21, 2016 via email

@KenC57
Copy link
Contributor Author

KenC57 commented Dec 21, 2016

Flipping between simulator and serial or network seems to be a good way to get things null. Also things like an invalid port (or no ports) or blank/bad network address. At least flipping these things around generated the nulls I found. Yes, sometimes leaving a blank or 'no ports found' and trying to save anyway.

@bobjacobsen
Copy link
Member

I haven't been able to get this to reproduce, sorry. Maybe I'm not understanding what "Flipping between simulator and serial or network seems to be a good way" means? Happy to try to track down something that's intermittent, just need a recipe that will let me recreate this at least occasionally.

@bobjacobsen bobjacobsen self-assigned this Jan 2, 2017
@KenC57
Copy link
Contributor Author

KenC57 commented Jan 2, 2017 via email

@KenC57
Copy link
Contributor Author

KenC57 commented Jan 2, 2017 via email

@bobjacobsen
Copy link
Member

Replaced by overtaken by PR #3233

@rhwood rhwood removed the WIP label May 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants