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