Fail command if currentMenu becomes null.
This commit is contained in:
parent
142878a22b
commit
780f4901f4
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue