apache / apache/fluss

JavaVersion.JAVA_9

Open
#2,351 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
2.1k
Forks
625
Avg merge
3d 14h
Merged PRs (30d)
97

Description

### 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 ConcurrentHashMap 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!

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with fluss-common/src/main/java/org/apache/fluss/utils/MapUtils.java and inspect the current Java version check and its commons-lang3 usage. Verify the behavior for Java 8 and Java 9-or-later runtimes, then confirm the dependency is no longer needed for this check.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Refactor
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.