Fail command if currentMenu becomes null.

This commit is contained in:
Johannes Mockenhaupt 2017-11-03 22:03:40 +01:00
parent 142878a22b
commit 780f4901f4
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1

View file

@ -486,18 +486,10 @@ public class RuffyScripter implements RuffyCommands {
public Menu getCurrentMenu() { public Menu getCurrentMenu() {
if (Thread.currentThread().isInterrupted()) if (Thread.currentThread().isInterrupted())
throw new CommandException("Interrupted"); throw new CommandException("Interrupted");
long timeout = System.currentTimeMillis() + 5 * 1000; if (currentMenu == null) {
// TODO this is probably due to a disconnect and rtDisconnect having nulled currentMenu. log.error("currentMenu == null, bailing");
// This here might just work, but needs a more controlled approach when implementing
// something to deal with connection loses
// TODO force reconnect? and retry?
while (currentMenu == null) {
if (System.currentTimeMillis() > timeout) {
throw new CommandException("Unable to read current menu"); throw new CommandException("Unable to read current menu");
} }
log.debug("currentMenu == null, waiting");
waitForMenuUpdate();
}
return currentMenu; return currentMenu;
} }