Skip to content

Commit

Permalink
Reset empty byte buffer value and do replacements to avoid NPE quarku…
Browse files Browse the repository at this point in the history
  • Loading branch information
galderz committed Jun 4, 2020
1 parent 5c7b352 commit 7e1c05c
Showing 1 changed file with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.quarkus.netty.runtime.graal;

import java.nio.ByteBuffer;
import java.security.PrivateKey;
import java.security.Provider;
import java.security.cert.X509Certificate;
Expand Down Expand Up @@ -389,6 +390,34 @@ static Class<?> tryToLoadClass(final ClassLoader loader, final Class<?> helper)

}

@TargetClass(className = "io.netty.buffer.EmptyByteBuf")
final class Target_io_netty_buffer_EmptyByteBuf {

@Alias
@RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Reset)
private static ByteBuffer EMPTY_BYTE_BUFFER;

@Alias
@RecomputeFieldValue(kind = RecomputeFieldValue.Kind.FromAlias)
private static long EMPTY_BYTE_BUFFER_ADDRESS = 0;

@Substitute
public ByteBuffer nioBuffer() {
return ByteBuffer.allocateDirect(0);
}

@Substitute
public ByteBuffer[] nioBuffers() {
return new ByteBuffer[] { ByteBuffer.allocateDirect(0) };
}

Substitute
public ByteBuffer internalNioBuffer(int index, int length) {
return ByteBuffer.allocateDirect(0);
}

}

class NettySubstitutions {

}

0 comments on commit 7e1c05c

Please sign in to comment.