Skip to content

Commit 425b906

Browse files
authored
Bump JNA version from 5.13.0 to 5.18.1 for Oshi monitor (#18848)
* Follow up to #18839 Newer versions of Oshi requires a bump in JNA dependency too. Without that, running quickstart with oshi sys monitor will fail processes with the following error: Caused by: java.lang.NoClassDefFoundError: com/sun/jna/platform/mac/CoreFoundation$CFLocale at oshi.software.os.mac.MacOperatingSystem.<init>(MacOperatingSystem.java:58) at oshi.software.os.mac.MacOperatingSystemJNA.<init>(MacOperatingSystemJNA.java:54) at oshi.SystemInfo.createOperatingSystem(SystemInfo.java:87) at oshi.util.Memoizer$1.get(Memoizer.java:65) at oshi.SystemInfo.getOperatingSystem(SystemInfo.java:76) at org.apache.druid.java.util.metrics.OshiSysMonitor.<init>(OshiSysMonitor.java:102) at org.apache.druid.java.util.metrics.OshiSysMonitor.<init>(OshiSysMonitor.java:90) Adds a unit test that fails locally with the same error without the jna dependencies bumped up.
1 parent 8e8da48 commit 425b906

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

licenses.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1643,7 +1643,7 @@ name: Java Native Access (JNA)
16431643
license_category: binary
16441644
module: java-core
16451645
license_name: Apache License version 2.0
1646-
version: 5.13.0
1646+
version: 5.18.1
16471647
libraries:
16481648
- net.java.dev.jna: jna
16491649

@@ -4796,7 +4796,7 @@ libraries:
47964796

47974797
name: net.java.dev.jna jna-platform
47984798
license_category: binary
4799-
version: 5.13.0
4799+
version: 5.18.1
48004800
module: druid-ranger-security
48014801
license_name: Apache License version 2.0
48024802
libraries:

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@
117117
<protobuf.version>3.25.8</protobuf.version>
118118
<resilience4j.version>1.3.1</resilience4j.version>
119119
<slf4j.version>2.0.16</slf4j.version>
120-
<jna.version>5.13.0</jna.version>
121-
<jna-platform.version>5.13.0</jna-platform.version>
120+
<jna.version>5.18.1</jna.version>
121+
<jna-platform.version>5.18.1</jna-platform.version>
122122
<hadoop.compile.version>3.3.6</hadoop.compile.version>
123123
<graaljs.version>22.3.5</graaljs.version>
124124
<mockito.version>5.14.2</mockito.version>

processing/src/test/java/org/apache/druid/java/util/metrics/OshiSysMonitorTest.java

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,6 @@ public class OshiSysMonitorTest
5252
private HardwareAbstractionLayer hal;
5353
private OperatingSystem os;
5454

55-
private enum STATS
56-
{
57-
MEM, SWAP, FS, DISK, NET, CPU, SYS, TCP
58-
}
59-
6055
@Before
6156
public void setUp()
6257
{
@@ -137,6 +132,23 @@ public void testMemStatsSkipOthers()
137132
emitter.verifyEmitted("sys/fs/max", 0);
138133
}
139134

135+
@Test
136+
public void testJnaBindingsWithRealSystemInfo()
137+
{
138+
// Use a real SystemInfo instance rather than a mock to ensure all Oshi/JNA bindings are correctly wired
139+
OshiSysMonitor m = createMonitor(new SystemInfo(), List.of("mem"));
140+
StubServiceEmitter emitter = new StubServiceEmitter();
141+
142+
m.start();
143+
m.doMonitor(emitter);
144+
m.stop();
145+
146+
emitter.verifyEmitted("sys/mem/max", 1);
147+
emitter.verifyEmitted("sys/mem/used", 1);
148+
emitter.verifyEmitted("sys/mem/free", 1);
149+
emitter.verifyEmitted("sys/fs/max", 0);
150+
}
151+
140152
@Test
141153
public void testSwapStats()
142154
{

0 commit comments

Comments
 (0)