Hi, all.
We've written a couple of WindowLicker unit tests which ran fine from command line locally. However, when we committed them into source repository the Cruise Control wasn't able to run them and was throwing an error:
java.lang.NullPointerException | | at com.objogate.wl.keyboard.KeyboardLayout.defaultKeyboardLayoutName(KeyboardLayout.java:75) | | at com.objogate.wl.keyboard.KeyboardLayout.getDefaultKeyboardLayout(KeyboardLayout.java:71) | | at com.objogate.wl.robot.RoboticAutomaton.<init>(RoboticAutomaton.java:27) | | at com.objogate.wl.swing.gesture.GesturePerformer.<init>(GesturePerformer.java:13) | | ... our code |
|
|
By looking at the source code I found that the place it fails tries to obtain the current country of the current InputContext. I suspect that because Cruise Control runs as a service it has limited ability to obtain Java InputContext due to security or some other reasons.
So I added a few null checks to make sure it doesn't fail:
I suspect it has to do with the fact that Cruise Control runs as a service and thus has limited ability to obtain Java InputContext due to security or some other reasons.
src\core\main\com\objogate\wl\keyboard\Keyboard.java
private static String defaultKeyboardLayoutName() {
String country="US";
InputContext context = InputContext.getInstance();
if(context!=null) {
java.util.Locale locale=context.getLocale();
if(locale!=null)
country=locale.getCountry();
}
return Platform.is(Platform.Mac) ? "Mac-" + country : country;
}
I think it's pretty safe fix. Could somebody add this fix to main repository so it's not lost. I am sure others will run into it sooner or later.
Thanks.
-Yuri