codesaunter opened a new issue, #2351: URL: https://github.com/apache/fluss/issues/2351
### Search before asking - [x] I searched in the [issues](https://github.com/apache/fluss/issues) and found nothing similar. ### Motivation The Java version check depends on the third-party plugin commons-lang3, and conflicts in the commons-lang3 version can easily occur, leading to code bugs. fluss-common/src/main/java/org/apache/fluss/utils/MapUtils.java ``` public class MapUtils { public static <K, V> ConcurrentHashMap<K, V> newConcurrentHashMap() { if (SystemUtils.isJavaVersionAtLeast(JavaVersion.JAVA_9)) { return new ConcurrentHashMap<>(); } else { return new ConcurrentHashMapForJDK8<>(); } } ... ``` The commons-lang3 dependency in upper-layer applications is highly prone to version conflicts. Once a function from an older version of commons-lang3 is loaded, the newer version will not be loaded again. Due to the unpredictable class-loading order at runtime in Java, this can lead to intermittent errors that are difficult to reproduce. Moreover, Maven's dependency conflict detection often fails to identify such issues. ### Solution It's batter to do: ``` private static boolean isJava9OrLater() { try { String version = System.getProperty("java.version"); if (version == null) return false; // Java 9+ versions:9, 10, 11, ..., 17, 21... // Java 8 and before:1.8, 1.7, 1.6... if (version.startsWith("1.")) { return false; } else { return true; } } catch (Exception e) { return false; } } ``` ### Anything else? _No response_ ### Willingness to contribute - [ ] I'm willing to submit a PR! -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
