Skip to content

Commit f8f3f2d

Browse files
authored
Merge pull request #121 from Leative/fix/hardwareInfoCausingException
catching exceptions eventually thrown when getting hardware info; not…
2 parents 0084c20 + d3ac513 commit f8f3f2d

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

libraries/core/src/main/java/uk/ac/kcl/inf/mdeoptimiser/libraries/core/optimisation/output/descriptors/SystemInformationDescriptor.java

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,20 @@ public String getJavaVersion() {
7878
* @return string containing hardware information
7979
*/
8080
public String getHardwareInfo() {
81-
var hardwareAbstractionLayer = systemInfo.getHardware();
82-
var centralProcessor = hardwareAbstractionLayer.getProcessor();
83-
return String.join(
84-
"\n",
85-
String.format("Processor: %s", centralProcessor.getName()),
86-
String.format(
87-
"Processor Cores: %s physical %s logical",
88-
centralProcessor.getPhysicalProcessorCount(),
89-
centralProcessor.getLogicalProcessorCount()),
90-
String.format(
91-
"Memory: %s GB", hardwareAbstractionLayer.getMemory().getTotal() / 1073741824d));
81+
try {
82+
var hardwareAbstractionLayer = systemInfo.getHardware();
83+
var centralProcessor = hardwareAbstractionLayer.getProcessor();
84+
return String.join(
85+
"\n",
86+
String.format("Processor: %s", centralProcessor.getName()),
87+
String.format(
88+
"Processor Cores: %s physical %s logical",
89+
centralProcessor.getPhysicalProcessorCount(),
90+
centralProcessor.getLogicalProcessorCount()),
91+
String.format(
92+
"Memory: %s GB", hardwareAbstractionLayer.getMemory().getTotal() / 1073741824d));
93+
} catch (Exception e) {
94+
return "Hardware info not available";
95+
}
9296
}
9397
}

0 commit comments

Comments
 (0)