[NO ISSUE] Don't attempt to log FDs on Windows
Hyracks collects FD info from the UnixOperatingSystemMXBean; this is not
available on Windows. Avoid trying to use these methods and logging a
NoSuchMethodError when running on Windows.
Change-Id: I7613af4599639d4a5337bb2a45e359660a3faeec
Reviewed-on: https://asterix-gerrit.ics.uci.edu/2692
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: abdullah alamoudi <bamousaa@gmail.com>
diff --git a/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/MXHelper.java b/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/MXHelper.java
index ce20d37..4c6ff57 100644
--- a/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/MXHelper.java
+++ b/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/MXHelper.java
@@ -28,6 +28,7 @@
import java.util.Collections;
import java.util.List;
+import org.apache.commons.lang3.SystemUtils;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -44,16 +45,21 @@
private static Method getMaxFileDescriptorCount;
static {
- try {
- getOpenFileDescriptorCount = osMXBean.getClass().getMethod("getOpenFileDescriptorCount");
- getMaxFileDescriptorCount = osMXBean.getClass().getDeclaredMethod("getMaxFileDescriptorCount");
- getOpenFileDescriptorCount.setAccessible(true);
- getMaxFileDescriptorCount.setAccessible(true);
- } catch (Throwable th) { // NOSONAR: diagnostic code shouldn't cause server failure
- getOpenFileDescriptorCount = null;
- getMaxFileDescriptorCount = null;
- LOGGER.log(Level.WARN, "Failed setting up the methods to get the number of file descriptors through {}",
- osMXBean.getClass().getName(), th);
+ if (SystemUtils.IS_OS_WINDOWS) {
+ LOGGER.info("Access to file descriptors (FDs) is not available on Windows; FD info will not be logged");
+ } else {
+ Class<? extends OperatingSystemMXBean> osMXBeanClass = osMXBean.getClass();
+ try {
+ getOpenFileDescriptorCount = osMXBeanClass.getMethod("getOpenFileDescriptorCount");
+ getMaxFileDescriptorCount = osMXBeanClass.getDeclaredMethod("getMaxFileDescriptorCount");
+ getOpenFileDescriptorCount.setAccessible(true);
+ getMaxFileDescriptorCount.setAccessible(true);
+ } catch (Throwable th) { // NOSONAR: diagnostic code shouldn't cause server failure
+ getOpenFileDescriptorCount = null;
+ getMaxFileDescriptorCount = null;
+ LOGGER.warn("Failed setting up the methods to get the number of file descriptors through {}",
+ osMXBeanClass.getName(), th);
+ }
}
}