Skip to content

Commit 8c8ec92

Browse files
committed
Bump minimum Java version to 17 and remove pre-17 workarounds
1 parent 7be05b4 commit 8c8ec92

7 files changed

Lines changed: 42 additions & 98 deletions

File tree

.github/workflows/ci-hadoop3.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
strategy:
2727
fail-fast: false
2828
matrix:
29-
java: [ { setup: '11', maven: '11' }, { setup: '17', maven: '17' } ]
29+
java: [ { setup: '17', maven: '17' } ]
3030
codes: [ 'uncompressed,brotli', 'gzip,snappy' ]
3131
name: Build Parquet with JDK ${{ matrix.java.setup }} and ${{ matrix.codes }}
3232

@@ -44,14 +44,10 @@ jobs:
4444
bash dev/ci-before_install.sh
4545
- name: install
4646
run: |
47-
EXTRA_JAVA_TEST_ARGS=$(./mvnw help:evaluate -Dexpression=extraJavaTestArgs -q -DforceStdout)
48-
export MAVEN_OPTS="$MAVEN_OPTS $EXTRA_JAVA_TEST_ARGS"
4947
./mvnw install --batch-mode -DskipTests=true -Dmaven.javadoc.skip=true -Dsource.skip=true -Djava.version=${{ matrix.java.maven }}
5048
- name: verify
5149
env:
5250
TEST_CODECS: ${{ matrix.codes }}
5351
JAVA_VERSION: ${{ matrix.java.setup }}
5452
run: |
55-
EXTRA_JAVA_TEST_ARGS=$(./mvnw help:evaluate -Dexpression=extraJavaTestArgs -q -DforceStdout)
56-
export MAVEN_OPTS="$MAVEN_OPTS $EXTRA_JAVA_TEST_ARGS"
5753
./mvnw verify --batch-mode javadoc:javadoc

.github/workflows/vector-plugins.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,10 @@ jobs:
4444
bash dev/ci-before_install.sh
4545
- name: install
4646
run: |
47-
EXTRA_JAVA_TEST_ARGS=$(./mvnw help:evaluate -Dexpression=extraJavaTestArgs -q -DforceStdout)
48-
export MAVEN_OPTS="$MAVEN_OPTS $EXTRA_JAVA_TEST_ARGS"
4947
./mvnw install --batch-mode -Pvector-plugins -DskipTests=true -Dmaven.javadoc.skip=true -Dsource.skip=true -Dmaven.buildNumber.skip=true -Djava.version=${{ matrix.java }} -pl parquet-plugins/parquet-encoding-vector,parquet-plugins/parquet-plugins-benchmarks -am
5048
- name: verify
5149
env:
5250
TEST_CODECS: ${{ matrix.codes }}
5351
JAVA_VERSION: ${{ matrix.java }}
5452
run: |
55-
EXTRA_JAVA_TEST_ARGS=$(./mvnw help:evaluate -Dexpression=extraJavaTestArgs -q -DforceStdout)
56-
export MAVEN_OPTS="$MAVEN_OPTS $EXTRA_JAVA_TEST_ARGS"
5753
./mvnw verify --batch-mode -Pvector-plugins javadoc:javadoc -pl parquet-plugins/parquet-encoding-vector,parquet-plugins/parquet-plugins-benchmarks -am

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,5 @@ mvn_install.log
2222
.DS_Store
2323
.memsearch/
2424

25+
.sdkmanrc
26+

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ You can find additional details about the format and intended use cases in our [
3636

3737
## Building
3838

39-
Parquet-Java uses Maven to build and depends on the thrift compiler (protoc is now managed by maven plugin).
39+
Parquet-Java requires Java 17 or higher and uses Maven to build. It also depends on the thrift compiler (protoc is now managed by maven plugin).
4040

4141
### Install Thrift
4242

parquet-hadoop/src/main/java/org/apache/parquet/hadoop/codec/CleanUtil.java

Lines changed: 20 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -26,68 +26,37 @@
2626
import org.slf4j.LoggerFactory;
2727

2828
/**
29-
* A Helper class which use reflections to clean up DirectBuffer. It's implemented for
30-
* better compatibility with both java8 and java9+, because the Cleaner class is moved to
31-
* another place since java9+.
32-
* <p>
33-
* Strongly inspired by:
34-
* https://github.com/apache/tomcat/blob/master/java/org/apache/tomcat/util/buf/ByteBufferUtils.java
29+
* A helper class which uses {@code sun.misc.Unsafe.invokeCleaner} to explicitly free
30+
* direct ByteBuffers.
3531
*/
3632
public class CleanUtil {
3733
private static final Logger logger = LoggerFactory.getLogger(CleanUtil.class);
3834

3935
private static final Object unsafe;
40-
private static final Method cleanerMethod;
41-
private static final Method cleanMethod;
4236
private static final Method invokeCleanerMethod;
4337

44-
private static final int majorVersion =
45-
Integer.parseInt(System.getProperty("java.version").split("\\D+")[0]);
46-
4738
static {
4839
final ByteBuffer tempBuffer = ByteBuffer.allocateDirect(0);
49-
Method cleanerMethodLocal = null;
50-
Method cleanMethodLocal = null;
5140
Object unsafeLocal = null;
5241
Method invokeCleanerMethodLocal = null;
53-
if (majorVersion >= 9) {
54-
try {
55-
final Class<?> clazz = Class.forName("sun.misc.Unsafe");
56-
final Field theUnsafe = clazz.getDeclaredField("theUnsafe");
57-
theUnsafe.setAccessible(true);
58-
unsafeLocal = theUnsafe.get(null);
59-
invokeCleanerMethodLocal = clazz.getMethod("invokeCleaner", ByteBuffer.class);
60-
invokeCleanerMethodLocal.invoke(unsafeLocal, tempBuffer);
61-
} catch (IllegalAccessException
62-
| IllegalArgumentException
63-
| InvocationTargetException
64-
| NoSuchMethodException
65-
| SecurityException
66-
| ClassNotFoundException
67-
| NoSuchFieldException e) {
68-
logger.warn("Cannot use direct ByteBuffer cleaner, memory leaking may occur", e);
69-
unsafeLocal = null;
70-
invokeCleanerMethodLocal = null;
71-
}
72-
} else {
73-
try {
74-
cleanerMethodLocal = tempBuffer.getClass().getMethod("cleaner");
75-
cleanerMethodLocal.setAccessible(true);
76-
final Object cleanerObject = cleanerMethodLocal.invoke(tempBuffer);
77-
cleanMethodLocal = cleanerObject.getClass().getMethod("clean");
78-
cleanMethodLocal.invoke(cleanerObject);
79-
} catch (NoSuchMethodException
80-
| SecurityException
81-
| IllegalAccessException
82-
| IllegalArgumentException
83-
| InvocationTargetException e) {
84-
logger.warn("Cannot use direct ByteBuffer cleaner, memory leaking may occur", e);
85-
cleanerMethodLocal = null;
86-
cleanMethodLocal = null;
87-
}
42+
try {
43+
final Class<?> clazz = Class.forName("sun.misc.Unsafe");
44+
final Field theUnsafe = clazz.getDeclaredField("theUnsafe");
45+
theUnsafe.setAccessible(true);
46+
unsafeLocal = theUnsafe.get(null);
47+
invokeCleanerMethodLocal = clazz.getMethod("invokeCleaner", ByteBuffer.class);
48+
invokeCleanerMethodLocal.invoke(unsafeLocal, tempBuffer);
49+
} catch (IllegalAccessException
50+
| IllegalArgumentException
51+
| InvocationTargetException
52+
| NoSuchMethodException
53+
| SecurityException
54+
| ClassNotFoundException
55+
| NoSuchFieldException e) {
56+
logger.warn("Cannot use direct ByteBuffer cleaner, memory leaking may occur", e);
57+
unsafeLocal = null;
58+
invokeCleanerMethodLocal = null;
8859
}
89-
cleanerMethod = cleanerMethodLocal;
90-
cleanMethod = cleanMethodLocal;
9160
unsafe = unsafeLocal;
9261
invokeCleanerMethod = invokeCleanerMethodLocal;
9362
}
@@ -97,16 +66,7 @@ private CleanUtil() {
9766
}
9867

9968
public static void cleanDirectBuffer(ByteBuffer buf) {
100-
if (cleanMethod != null) {
101-
try {
102-
cleanMethod.invoke(cleanerMethod.invoke(buf));
103-
} catch (IllegalAccessException
104-
| IllegalArgumentException
105-
| InvocationTargetException
106-
| SecurityException e) {
107-
logger.warn("Error while cleaning up the DirectBuffer", e);
108-
}
109-
} else if (invokeCleanerMethod != null) {
69+
if (invokeCleanerMethod != null) {
11070
try {
11171
invokeCleanerMethod.invoke(unsafe, buf);
11272
} catch (IllegalAccessException

parquet-plugins/parquet-encoding-vector/pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,6 @@
3434
<name>Apache Parquet Encodings Vector</name>
3535
<url>https://parquet.apache.org</url>
3636

37-
<properties>
38-
<!-- Those properties prevent Java 11 to try and compile this code -->
39-
<maven.compiler.release>17</maven.compiler.release>
40-
</properties>
41-
4237
<dependencies>
4338
<dependency>
4439
<groupId>org.apache.parquet</groupId>

pom.xml

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
</mailingLists>
7070

7171
<properties>
72-
<maven.compiler.release>11</maven.compiler.release>
72+
<maven.compiler.release>17</maven.compiler.release>
7373
<github.global.server>github</github.global.server>
7474
<jackson.groupId>com.fasterxml.jackson.core</jackson.groupId>
7575
<jackson.datatype.groupId>com.fasterxml.jackson.datatype</jackson.datatype.groupId>
@@ -119,23 +119,6 @@
119119

120120
<!-- Resource intesive tests are enabled by default but disabled in the CI envrionment -->
121121
<enableResourceIntensiveTests>true</enableResourceIntensiveTests>
122-
123-
<extraJavaTestArgs>
124-
-XX:+IgnoreUnrecognizedVMOptions
125-
--add-opens=java.base/java.lang=ALL-UNNAMED
126-
--add-opens=java.base/java.lang.invoke=ALL-UNNAMED
127-
--add-opens=java.base/java.lang.reflect=ALL-UNNAMED
128-
--add-opens=java.base/java.io=ALL-UNNAMED
129-
--add-opens=java.base/java.net=ALL-UNNAMED
130-
--add-opens=java.base/java.nio=ALL-UNNAMED
131-
--add-opens=java.base/java.util=ALL-UNNAMED
132-
--add-opens=java.base/java.util.concurrent=ALL-UNNAMED
133-
--add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED
134-
--add-opens=java.base/sun.nio.ch=ALL-UNNAMED
135-
--add-opens=java.base/sun.nio.cs=ALL-UNNAMED
136-
--add-opens=java.base/sun.security.action=ALL-UNNAMED
137-
--add-opens=java.base/sun.util.calendar=ALL-UNNAMED
138-
</extraJavaTestArgs>
139122
</properties>
140123

141124
<modules>
@@ -284,6 +267,21 @@
284267
<plugin>
285268
<artifactId>maven-enforcer-plugin</artifactId>
286269
<executions>
270+
<execution>
271+
<id>enforce-java-version</id>
272+
<goals>
273+
<goal>enforce</goal>
274+
</goals>
275+
<configuration>
276+
<rules>
277+
<requireJavaVersion>
278+
<version>[17,)</version>
279+
<message>Java 17 or higher is required to build parquet-java.</message>
280+
</requireJavaVersion>
281+
</rules>
282+
<fail>true</fail>
283+
</configuration>
284+
</execution>
287285
<execution>
288286
<id>enforce-banned-dependencies</id>
289287
<goals>
@@ -432,9 +430,6 @@
432430
<plugin>
433431
<groupId>org.apache.maven.plugins</groupId>
434432
<artifactId>maven-failsafe-plugin</artifactId>
435-
<configuration>
436-
<argLine>${extraJavaTestArgs}</argLine>
437-
</configuration>
438433
<executions>
439434
<execution>
440435
<goals>
@@ -449,7 +444,7 @@
449444
<groupId>org.apache.maven.plugins</groupId>
450445
<artifactId>maven-surefire-plugin</artifactId>
451446
<configuration>
452-
<argLine>${surefire.argLine} ${extraJavaTestArgs}</argLine>
447+
<argLine>${surefire.argLine}</argLine>
453448
<systemPropertyVariables>
454449
<!-- Configure Parquet logging during tests
455450
See http://www.slf4j.org/api/org/slf4j/impl/SimpleLogger.html
@@ -590,7 +585,7 @@
590585
</excludeModules>
591586
<excludes>
592587
<exclude>${shade.prefix}</exclude>
593-
<!-- JDK 11 adds interface methods/bridges on PrimitiveIterator.OfInt; ignore japicmp source incompatibility -->
588+
<!-- JDK adds interface methods/bridges on PrimitiveIterator.OfInt; ignore japicmp source incompatibility -->
594589
<exclude>org.apache.parquet.internal.column.columnindex.IndexIterator</exclude>
595590
<!-- Removal of a protected method in a class that's not supposed to be subclassed by third-party code -->
596591
<exclude>org.apache.parquet.column.values.bytestreamsplit.ByteStreamSplitValuesReader#gatherElementDataFromStreams(byte[])</exclude>

0 commit comments

Comments
 (0)