Fixed NullPointerException when fail to get forge list.

This commit is contained in:
huangyuhui 2017-01-20 12:44:14 +08:00
parent da2f0b234f
commit db4615a2d3
3 changed files with 11 additions and 7 deletions

View File

@ -42,7 +42,7 @@ public class InstallerPanel extends Page {
/** /**
* Creates new form InstallerPanel * Creates new form InstallerPanel
* *
* @param gsp To get the minecraft version * @param gsp To get the minecraft version
* @param installerType load which installer * @param installerType load which installer
*/ */
public InstallerPanel(GameSettingsPanel gsp, InstallerType installerType) { public InstallerPanel(GameSettingsPanel gsp, InstallerType installerType) {
@ -122,7 +122,11 @@ public class InstallerPanel extends Page {
InstallerType id; InstallerType id;
Task refreshVersionsTask() { Task refreshVersionsTask() {
return list.refresh(new String[] { gsp.getMinecraftVersionFormatted() }).after(new TaskRunnable(this::loadVersions)); Task t = list.refresh(new String[] { gsp.getMinecraftVersionFormatted() });
if (t != null)
return t.after(new TaskRunnable(this::loadVersions));
else
return null;
} }
public synchronized InstallerVersionList.InstallerVersion getVersion(int idx) { public synchronized InstallerVersionList.InstallerVersion getVersion(int idx) {

View File

@ -17,9 +17,8 @@
*/ */
package org.jackhuang.hellominecraft.svrmgr.util; package org.jackhuang.hellominecraft.svrmgr.util;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jackhuang.hellominecraft.util.EventHandler; import org.jackhuang.hellominecraft.util.EventHandler;
import org.jackhuang.hellominecraft.util.logging.HMCLog;
/** /**
* *
@ -40,7 +39,7 @@ public class WaitForThread extends Thread {
int exitCode = p.waitFor(); int exitCode = p.waitFor();
event.execute(exitCode); event.execute(exitCode);
} catch (InterruptedException ex) { } catch (InterruptedException ex) {
Logger.getLogger(WaitForThread.class.getName()).log(Level.SEVERE, null, ex); HMCLog.err("Game has been interrupted.", ex);
event.execute(-1); event.execute(-1);
} }
} }

View File

@ -112,9 +112,10 @@ public class TaskList extends Thread {
} }
try { try {
counter.await(); counter.await();
} catch (InterruptedException ignore) { return bool.get();
} catch (InterruptedException ignore) { // this task is canceled, so failed.
return false;
} }
return bool.get();
} }
private boolean executeTask(Task t) { private boolean executeTask(Task t) {