diff --git a/build.xml b/build.xml
index ef5910f85e..33f5010fc2 100644
--- a/build.xml
+++ b/build.xml
@@ -259,7 +259,6 @@
--add-opens java.base/sun.nio.ch=ALL-UNNAMED
--add-opens java.base/java.io=ALL-UNNAMED
- --add-opens java.base/java.nio=ALL-UNNAMED
--add-opens java.base/java.util.concurrent=ALL-UNNAMED
--add-opens java.base/java.util=ALL-UNNAMED
--add-opens java.base/java.util.concurrent.atomic=ALL-UNNAMED
diff --git a/conf/jvm17-clients.options b/conf/jvm17-clients.options
index e006fee11a..023ca52e81 100644
--- a/conf/jvm17-clients.options
+++ b/conf/jvm17-clients.options
@@ -51,7 +51,6 @@
# to be addressed in CASSANDRA-17850
--add-opens java.base/sun.nio.ch=ALL-UNNAMED
--add-opens java.base/java.io=ALL-UNNAMED
---add-opens java.base/java.nio=ALL-UNNAMED
# to be addressed during jamm maintenance
--add-opens java.base/java.util.concurrent=ALL-UNNAMED
--add-opens java.base/java.util=ALL-UNNAMED
diff --git a/conf/jvm17-server.options b/conf/jvm17-server.options
index 98a70a20f9..f0e7810eb1 100644
--- a/conf/jvm17-server.options
+++ b/conf/jvm17-server.options
@@ -90,7 +90,6 @@
--add-opens java.base/sun.nio.ch=ALL-UNNAMED
# https://chronicle.software/chronicle-support-java-17/
--add-opens java.base/java.io=ALL-UNNAMED
---add-opens java.base/java.nio=ALL-UNNAMED
#to be addressed during jamm maintenance
--add-opens java.base/java.util.concurrent=ALL-UNNAMED
--add-opens java.base/java.util=ALL-UNNAMED
diff --git a/src/java/org/apache/cassandra/utils/SyncUtil.java b/src/java/org/apache/cassandra/utils/SyncUtil.java
index 1adc4fc657..96985cef63 100644
--- a/src/java/org/apache/cassandra/utils/SyncUtil.java
+++ b/src/java/org/apache/cassandra/utils/SyncUtil.java
@@ -21,11 +21,9 @@
package org.apache.cassandra.utils;
import java.io.*;
-import java.lang.reflect.Field;
import java.nio.MappedByteBuffer;
import java.nio.channels.ClosedChannelException;
import java.nio.channels.FileChannel;
-import java.util.concurrent.atomic.AtomicInteger;
import com.google.common.base.Preconditions;
@@ -38,57 +36,17 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/*
- * A wrapper around various mechanisms for syncing files that makes it possible it intercept
+ * A wrapper around various mechanisms for syncing files that makes it possible to intercept
* and skip syncing. Useful for unit tests in certain environments where syncs can have outliers
- * bad enough to causes tests to run 10s of seconds longer.
+ * bad enough to cause tests to run 10s of seconds longer.
*/
public class SyncUtil
{
public static final boolean SKIP_SYNC;
-
- private static final Field mbbFDField;
- private static final Field fdClosedField;
- private static final Field fdUseCountField;
-
private static final Logger logger = LoggerFactory.getLogger(SyncUtil.class);
static
{
- Field mbbFDFieldTemp = null;
- try
- {
- mbbFDFieldTemp = MappedByteBuffer.class.getDeclaredField("fd");
- mbbFDFieldTemp.setAccessible(true);
- }
- catch (NoSuchFieldException e)
- {
- }
- mbbFDField = mbbFDFieldTemp;
-
- //Java 8
- Field fdClosedFieldTemp = null;
- try
- {
- fdClosedFieldTemp = FileDescriptor.class.getDeclaredField("closed");
- fdClosedFieldTemp.setAccessible(true);
- }
- catch (NoSuchFieldException e)
- {
- }
- fdClosedField = fdClosedFieldTemp;
-
- //Java 7
- Field fdUseCountTemp = null;
- try
- {
- fdUseCountTemp = FileDescriptor.class.getDeclaredField("useCount");
- fdUseCountTemp.setAccessible(true);
- }
- catch (NoSuchFieldException e)
- {
- }
- fdUseCountField = fdUseCountTemp;
-
//If skipping syncing is requested by any means then skip them.
boolean skipSyncProperty = CassandraRelevantProperties.TEST_CASSANDRA_SKIP_SYNC.getBoolean();
boolean skipSyncEnv = CassandraRelevantEnv.CASSANDRA_SKIP_SYNC.getBoolean();
@@ -110,21 +68,6 @@ public class SyncUtil
}
if (SKIP_SYNC)
{
- Object fd = null;
- try
- {
- if (mbbFDField != null)
- {
- fd = mbbFDField.get(buf);
- }
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- //This is what MappedByteBuffer.force() throws if a you call force() on an umapped buffer
- if (mbbFDField != null && fd == null)
- throw new UnsupportedOperationException();
return buf;
}
else
@@ -132,40 +75,12 @@ public class SyncUtil
return buf.force();
}
}
-
+
public static void sync(FileDescriptor fd) throws SyncFailedException
{
Preconditions.checkNotNull(fd);
- if (SKIP_SYNC)
- {
- boolean closed = false;
- try
- {
- if (fdClosedField != null)
- closed = fdClosedField.getBoolean(fd);
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
-
- int useCount = 1;
- try
- {
- if (fdUseCountField != null)
- useCount = ((AtomicInteger)fdUseCountField.get(fd)).get();
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- if (closed || !fd.valid() || useCount < 0)
- throw new SyncFailedException("Closed " + closed + " valid " + fd.valid() + " useCount " + useCount);
- }
- else
- {
+ if (!SKIP_SYNC)
fd.sync();
- }
}
public static void force(FileChannel fc, boolean metaData) throws IOException
@@ -192,8 +107,8 @@ public class SyncUtil
{
if (SKIP_SYNC)
return;
- else
- NativeLibrary.trySync(fd);
+
+ NativeLibrary.trySync(fd);
}
public static void trySyncDir(File dir)