-
Notifications
You must be signed in to change notification settings - Fork 29.3k
[SPARK-45309][SQL] Remove all SystemUtils.isJavaVersionAtLeast with JDK 9/11/17 #43098
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,7 +22,6 @@ import java.nio.{ByteBuffer, MappedByteBuffer} | |
| import scala.collection.Map | ||
| import scala.collection.mutable | ||
|
|
||
| import org.apache.commons.lang3.{JavaVersion, SystemUtils} | ||
| import sun.misc.Unsafe | ||
| import sun.nio.ch.DirectBuffer | ||
|
|
||
|
|
@@ -198,29 +197,14 @@ private[spark] class StorageStatus( | |
| /** Helper methods for storage-related objects. */ | ||
| private[spark] object StorageUtils extends Logging { | ||
|
|
||
| // In Java 8, the type of DirectBuffer.cleaner() was sun.misc.Cleaner, and it was possible | ||
| // to access the method sun.misc.Cleaner.clean() to invoke it. The type changed to | ||
| // jdk.internal.ref.Cleaner in later JDKs, and the .clean() method is not accessible even with | ||
| // reflection. However sun.misc.Unsafe added a invokeCleaner() method in JDK 9+ and this is | ||
| // still accessible with reflection. | ||
| private val bufferCleaner: DirectBuffer => Unit = | ||
| if (SystemUtils.isJavaVersionAtLeast(JavaVersion.JAVA_9)) { | ||
| val cleanerMethod = | ||
| Utils.classForName("sun.misc.Unsafe").getMethod("invokeCleaner", classOf[ByteBuffer]) | ||
| val unsafeField = classOf[Unsafe].getDeclaredField("theUnsafe") | ||
| unsafeField.setAccessible(true) | ||
| val unsafe = unsafeField.get(null).asInstanceOf[Unsafe] | ||
| buffer: DirectBuffer => cleanerMethod.invoke(unsafe, buffer) | ||
| } else { | ||
| val cleanerMethod = Utils.classForName("sun.misc.Cleaner").getMethod("clean") | ||
| buffer: DirectBuffer => { | ||
| // Careful to avoid the return type of .cleaner(), which changes with JDK | ||
| val cleaner: AnyRef = buffer.cleaner() | ||
| if (cleaner != null) { | ||
| cleanerMethod.invoke(cleaner) | ||
| } | ||
| } | ||
| } | ||
| private val bufferCleaner: DirectBuffer => Unit = { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For this function, it should be possible to further refactor to avoid using un-exported APIs and internal APIs, but the current changes in this pr are ok. |
||
| val cleanerMethod = | ||
| Utils.classForName("sun.misc.Unsafe").getMethod("invokeCleaner", classOf[ByteBuffer]) | ||
| val unsafeField = classOf[Unsafe].getDeclaredField("theUnsafe") | ||
| unsafeField.setAccessible(true) | ||
| val unsafe = unsafeField.get(null).asInstanceOf[Unsafe] | ||
| buffer: DirectBuffer => cleanerMethod.invoke(unsafe, buffer) | ||
| } | ||
|
|
||
| /** | ||
| * Attempt to clean up a ByteBuffer if it is direct or memory-mapped. This uses an *unsafe* Sun | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,7 +21,6 @@ import java.io.{BufferedWriter, File, FileWriter} | |
|
|
||
| import scala.util.Properties | ||
|
|
||
| import org.apache.commons.lang3.{JavaVersion, SystemUtils} | ||
| import org.apache.hadoop.fs.Path | ||
| import org.apache.hadoop.hive.common.FileUtils | ||
| import org.scalatest.Assertions._ | ||
|
|
@@ -141,8 +140,7 @@ class HiveSparkSubmitSuite | |
| runSparkSubmit(args) | ||
| } | ||
|
|
||
| test("SPARK-8020: set sql conf in spark conf") { | ||
| assume(!SystemUtils.isJavaVersionAtLeast(JavaVersion.JAVA_9)) | ||
| ignore("SPARK-8020: set sql conf in spark conf") { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will there be a chance for these ignored cases to be restarted?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's leave it for now. I think this test does not target to test 0.12 (although the metastore version is set like that).
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shall we change the hive version in these tests?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For this and and the last one, we could. But the others don't set the Hive version apparently. I will just take a look separately. |
||
| val unusedJar = TestUtils.createJarWithClasses(Seq.empty) | ||
| val args = Seq( | ||
| "--class", SparkSQLConfTest.getClass.getName.stripSuffix("$"), | ||
|
|
@@ -180,8 +178,7 @@ class HiveSparkSubmitSuite | |
| runSparkSubmit(args) | ||
| } | ||
|
|
||
| test("SPARK-9757 Persist Parquet relation with decimal column") { | ||
| assume(!SystemUtils.isJavaVersionAtLeast(JavaVersion.JAVA_9)) | ||
| ignore("SPARK-9757 Persist Parquet relation with decimal column") { | ||
| val unusedJar = TestUtils.createJarWithClasses(Seq.empty) | ||
| val args = Seq( | ||
| "--class", SPARK_9757.getClass.getName.stripSuffix("$"), | ||
|
|
@@ -277,8 +274,7 @@ class HiveSparkSubmitSuite | |
| runSparkSubmit(args) | ||
| } | ||
|
|
||
| test("SPARK-16901: set javax.jdo.option.ConnectionURL") { | ||
| assume(!SystemUtils.isJavaVersionAtLeast(JavaVersion.JAVA_9)) | ||
| ignore("SPARK-16901: set javax.jdo.option.ConnectionURL") { | ||
| // In this test, we set javax.jdo.option.ConnectionURL and set metastore version to | ||
| // 0.13. This test will make sure that javax.jdo.option.ConnectionURL will not be | ||
| // overridden by hive's default settings when we create a HiveConf object inside | ||
|
|
@@ -359,9 +355,8 @@ class HiveSparkSubmitSuite | |
| runSparkSubmit(argsForShowTables) | ||
| } | ||
|
|
||
| test("SPARK-34772: RebaseDateTime loadRebaseRecords should use Spark classloader " + | ||
| ignore("SPARK-34772: RebaseDateTime loadRebaseRecords should use Spark classloader " + | ||
| "instead of context") { | ||
| assume(!SystemUtils.isJavaVersionAtLeast(JavaVersion.JAVA_9)) | ||
| val unusedJar = TestUtils.createJarWithClasses(Seq.empty) | ||
|
|
||
| // We need to specify the metastore database location in case of conflict with other hive | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.