makerbot/ReplicatorG — Issue #243: containsIgnoreCase throws NPE
Author: larsrc
Created: 2011-11-14 18:36:11+00:00
State: open

The implementation of containsIgnoreCase at https://github.com/makerbot/ReplicatorG/blob/master/src/replicatorg/app/ui/MainWindow.java#L1255 throws a NullPointerException:

14/11/2011 19:22:36	[0x0-0x5a05a].org.replicatorg.app[2587]	Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
14/11/2011 19:22:36	[0x0-0x5a05a].org.replicatorg.app[2587]	at java.util.regex.Matcher.getTextLength(Matcher.java:1140)
14/11/2011 19:22:36	[0x0-0x5a05a].org.replicatorg.app[2587]	at java.util.regex.Matcher.reset(Matcher.java:291)
14/11/2011 19:22:36	[0x0-0x5a05a].org.replicatorg.app[2587]	at java.util.regex.Matcher.(Matcher.java:211)
14/11/2011 19:22:36	[0x0-0x5a05a].org.replicatorg.app[2587]	at java.util.regex.Pattern.matcher(Pattern.java:888)
14/11/2011 19:22:36	[0x0-0x5a05a].org.replicatorg.app[2587]	at replicatorg.app.ui.MainWindow$MachineMenuListener.containsIgnoreCase(MainWindow.java:1256)
14/11/2011 19:22:36	[0x0-0x5a05a].org.replicatorg.app[2587]	at replicatorg.app.ui.MainWindow$MachineMenuListener.actionPerformed(MainWindow.java:1276)

This probably happens when there has been a machine with a null name. It gets stored in the prefs, and all attempts at updating it causes a NPE because of the check at line 1277.

I am also curious to hear why you think making a containsIgnoreCase that compiles a regular expression at every call is quicker than the built-in one.