mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2025-07-19 11:03:01 +00:00
Handle NumberFormatExceptions from parseInt()
This commit is contained in:
parent
7ae74a6a18
commit
fe907b0271
@ -1,5 +1,7 @@
|
||||
package com.limelight.nvstream.http;
|
||||
|
||||
import com.limelight.LimeLog;
|
||||
|
||||
public class NvApp {
|
||||
private String appName = "";
|
||||
private int appId;
|
||||
@ -11,8 +13,12 @@ public class NvApp {
|
||||
}
|
||||
|
||||
public void setAppId(String appId) {
|
||||
this.appId = Integer.parseInt(appId);
|
||||
this.initialized = true;
|
||||
try {
|
||||
this.appId = Integer.parseInt(appId);
|
||||
this.initialized = true;
|
||||
} catch (NumberFormatException e) {
|
||||
LimeLog.warning("Malformed app ID: "+appId);
|
||||
}
|
||||
}
|
||||
|
||||
public void setIsRunning(String isRunning) {
|
||||
|
@ -6,6 +6,7 @@ import java.net.DatagramSocket;
|
||||
import java.net.InetAddress;
|
||||
import java.util.Scanner;
|
||||
|
||||
import com.limelight.LimeLog;
|
||||
import com.limelight.nvstream.http.ComputerDetails;
|
||||
|
||||
public class WakeOnLanSender {
|
||||
@ -45,7 +46,12 @@ public class WakeOnLanSender {
|
||||
@SuppressWarnings("resource")
|
||||
Scanner scan = new Scanner(macAddress).useDelimiter(":");
|
||||
for (int i = 0; i < macBytes.length && scan.hasNext(); i++) {
|
||||
macBytes[i] = (byte) Integer.parseInt(scan.next(), 16);
|
||||
try {
|
||||
macBytes[i] = (byte) Integer.parseInt(scan.next(), 16);
|
||||
} catch (NumberFormatException e) {
|
||||
LimeLog.warning("Malformed MAC address: "+macAddress+" (index: "+i+")");
|
||||
break;
|
||||
}
|
||||
}
|
||||
scan.close();
|
||||
return macBytes;
|
||||
|
Loading…
x
Reference in New Issue
Block a user