Skip to content

Commit

Permalink
fix(s3stream/thirdparty): remove unsafe dependencies (#661)
Browse files Browse the repository at this point in the history
Signed-off-by: Ning Yu <[email protected]>
  • Loading branch information
Chillax-0v0 authored Nov 17, 2023
1 parent 1877e8f commit 2310863
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 17 deletions.
12 changes: 0 additions & 12 deletions s3stream/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -167,18 +167,6 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
<compilerArgs>
<arg>--add-exports=java.base/sun.nio.ch=ALL-UNNAMED</arg>
<arg>--add-exports=java.base/jdk.internal.access=ALL-UNNAMED</arg>
</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
import com.sun.jna.Platform;
import com.sun.jna.Pointer;
import com.sun.jna.ptr.PointerByReference;
import io.netty.util.internal.PlatformDependent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sun.nio.ch.DirectBuffer;

import java.io.IOException;
import java.nio.ByteBuffer;
Expand Down Expand Up @@ -256,7 +256,7 @@ public static int lcm(long x, long y) {
*/
public int pread(int fd, ByteBuffer buf, long offset) throws IOException {
buf.clear(); // so that we read an entire buffer
final long address = ((DirectBuffer) buf).address();
final long address = PlatformDependent.directBufferAddress(buf);
Pointer pointer = new Pointer(address);
int n = pread(fd, pointer, new NativeLong(buf.capacity()), new NativeLong(offset)).intValue();
if (n < 0) {
Expand Down Expand Up @@ -285,7 +285,7 @@ public int pwrite(int fd, ByteBuffer buf, long offset) throws IOException {
assert start == blockStart(start);
final int toWrite = blockEnd(buf.limit()) - start;

final long address = ((DirectBuffer) buf).address();
final long address = PlatformDependent.directBufferAddress(buf);
Pointer pointer = new Pointer(address);

int n = pwrite(fd, pointer.share(start), new NativeLong(toWrite), new NativeLong(offset)).intValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import com.sun.jna.NativeLong;
import com.sun.jna.Pointer;
import com.sun.jna.ptr.PointerByReference;
import jdk.internal.access.SharedSecrets;
import io.netty.util.internal.PlatformDependent;

import java.nio.ByteBuffer;
import java.nio.ByteOrder;
Expand Down Expand Up @@ -56,7 +56,7 @@ public static ByteBuffer allocateForDirectIO(DirectIOLib lib, int capacity) {
* @return Byte buffer wrapping the given memory.
*/
public static ByteBuffer wrapPointer(long ptr, int len) {
ByteBuffer buf = SharedSecrets.getJavaNioAccess().newDirectByteBuffer(ptr, len, null, null);
ByteBuffer buf = PlatformDependent.directBuffer(ptr, len);

assert buf.isDirect();
return buf;
Expand Down

0 comments on commit 2310863

Please sign in to comment.