HADOOP-13663 Index out of range in SysInfoWindows. Contributed by Inigo Goiri
This commit is contained in:
parent
47f80922dc
commit
1518cb9532
@ -100,8 +100,9 @@ void refreshIfNeeded() {
|
|||||||
String sysInfoStr = getSystemInfoInfoFromShell();
|
String sysInfoStr = getSystemInfoInfoFromShell();
|
||||||
if (sysInfoStr != null) {
|
if (sysInfoStr != null) {
|
||||||
final int sysInfoSplitCount = 11;
|
final int sysInfoSplitCount = 11;
|
||||||
String[] sysInfo = sysInfoStr.substring(0, sysInfoStr.indexOf("\r\n"))
|
int index = sysInfoStr.indexOf("\r\n");
|
||||||
.split(",");
|
if (index >= 0) {
|
||||||
|
String[] sysInfo = sysInfoStr.substring(0, index).split(",");
|
||||||
if (sysInfo.length == sysInfoSplitCount) {
|
if (sysInfo.length == sysInfoSplitCount) {
|
||||||
try {
|
try {
|
||||||
vmemSize = Long.parseLong(sysInfo[0]);
|
vmemSize = Long.parseLong(sysInfo[0]);
|
||||||
@ -131,6 +132,9 @@ void refreshIfNeeded() {
|
|||||||
LOG.warn("Expected split length of sysInfo to be "
|
LOG.warn("Expected split length of sysInfo to be "
|
||||||
+ sysInfoSplitCount + ". Got " + sysInfo.length);
|
+ sysInfoSplitCount + ". Got " + sysInfo.length);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
LOG.warn("Wrong output from sysInfo: " + sysInfoStr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -141,10 +141,15 @@ public void refreshAndCpuUsageMulticore() throws InterruptedException {
|
|||||||
@Test(timeout = 10000)
|
@Test(timeout = 10000)
|
||||||
public void errorInGetSystemInfo() {
|
public void errorInGetSystemInfo() {
|
||||||
SysInfoWindowsMock tester = new SysInfoWindowsMock();
|
SysInfoWindowsMock tester = new SysInfoWindowsMock();
|
||||||
// info str derived from windows shell command has \r\n termination
|
// info str derived from windows shell command is null
|
||||||
tester.setSysinfoString(null);
|
tester.setSysinfoString(null);
|
||||||
// call a method to refresh values
|
// call a method to refresh values
|
||||||
tester.getAvailablePhysicalMemorySize();
|
tester.getAvailablePhysicalMemorySize();
|
||||||
|
|
||||||
|
// info str derived from windows shell command with no \r\n termination
|
||||||
|
tester.setSysinfoString("");
|
||||||
|
// call a method to refresh values
|
||||||
|
tester.getAvailablePhysicalMemorySize();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user