Skip to content

Commit

Permalink
fix used/max file descriptor counts in oracle java 8
Browse files Browse the repository at this point in the history
  • Loading branch information
Colin Ingarfield committed Jul 27, 2015
1 parent 31b920e commit c04ef79
Showing 1 changed file with 11 additions and 6 deletions.
Expand Up @@ -235,9 +235,7 @@ private static long buildProcessCpuTimeMillis() {

private static long buildOpenFileDescriptorCount() {
final OperatingSystemMXBean operatingSystem = ManagementFactory.getOperatingSystemMXBean();
if (isSunOsMBean(operatingSystem)
&& "com.sun.management.UnixOperatingSystem".equals(operatingSystem.getClass()
.getName())) {
if (isSunOsMBean(operatingSystem) && isSunUnixMBean(operatingSystem)) {
try {
return MemoryInformations.getLongFromOperatingSystem(operatingSystem,
"getOpenFileDescriptorCount");
Expand All @@ -251,9 +249,7 @@ private static long buildOpenFileDescriptorCount() {

private static long buildMaxFileDescriptorCount() {
final OperatingSystemMXBean operatingSystem = ManagementFactory.getOperatingSystemMXBean();
if (isSunOsMBean(operatingSystem)
&& "com.sun.management.UnixOperatingSystem".equals(operatingSystem.getClass()
.getName())) {
if (isSunOsMBean(operatingSystem) && isSunUnixMBean(operatingSystem)) {
try {
return MemoryInformations.getLongFromOperatingSystem(operatingSystem,
"getMaxFileDescriptorCount");
Expand Down Expand Up @@ -477,6 +473,15 @@ private static boolean isSunOsMBean(OperatingSystemMXBean operatingSystem) {
|| "sun.management.OperatingSystemImpl".equals(className);
}

private static boolean isSunUnixMBean(OperatingSystemMXBean operatingSystem) {
for (Class<?> inter : operatingSystem.getClass().getInterfaces()) {
if ("com.sun.management.UnixOperatingSystemMXBean".equals(inter.getName())) {
return true;
}
}
return false;
}

MemoryInformations getMemoryInformations() {
return memoryInformations;
}
Expand Down

0 comments on commit c04ef79

Please sign in to comment.