Skip to content

Observe io.netty.allocator.type for custom Netty allocator #10292

@jaredbwasserman

Description

@jaredbwasserman

I modified code that depends on grpc-java to use the unpooled allocator type for netty. In order to accomplish this I had to:

  1. Pass in unpooled for the io.netty.allocator.type property. See https://github.com/netty/netty/blob/4.1/buffer/src/main/java/io/netty/buffer/ByteBufUtil.java#L78
  2. Pass in false for the io.grpc.netty.useCustomAllocator property. I am using v1.32.1 but this also applies to the latest version v1.56.x. See https://github.com/grpc/grpc-java/blob/v1.32.x/netty/src/main/java/io/grpc/netty/Utils.java#L126 and https://github.com/grpc/grpc-java/blob/v1.56.x/netty/src/main/java/io/grpc/netty/Utils.java#L136

Why is the default value for io.grpc.netty.useCustomAllocator true? In order for the code to use the ByteBufAllocator.DEFAULT the io.grpc.netty.useCustomAllocator property must be overridden to false, which seems to contradict the idea of a default. Would it make more sense for io.grpc.netty.useCustomAllocator to default to false so that ByteBufAllocator.DEFAULT is used by default?

I am asking because I had to do some debugging to figure out why only supplying io.netty.allocator.type=unpooled did not change the allocator type as I had expected. Thanks!

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions