Skip to content
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

NPE in CompositeByteBuf.forEachByte with ResourceLeakDetector enabled #9873

Closed
dkomanov opened this issue Dec 12, 2019 · 1 comment
Closed

Comments

@dkomanov
Copy link

Expected behavior

No exception.

Actual behavior

Throws NullPointerException:

java.lang.NullPointerException
	at io.netty.buffer.CompositeByteBuf.toComponentIndex0(CompositeByteBuf.java:888)
	at io.netty.buffer.CompositeByteBuf.forEachByteAsc0(CompositeByteBuf.java:637)
	at io.netty.buffer.CompositeByteBuf.forEachByteAsc0(CompositeByteBuf.java:647)
	at io.netty.buffer.AbstractByteBuf.forEachByte(AbstractByteBuf.java:1271)
	at io.netty.buffer.WrappedCompositeByteBuf.forEachByte(WrappedCompositeByteBuf.java:388)
	at io.netty.buffer.AdvancedLeakAwareCompositeByteBuf.forEachByte(AdvancedLeakAwareCompositeByteBuf.java:657)

Minimal yet complete reproducer code

@Test
public void forEachByteUnderLeakDetectionShouldNotThrowException() {
    ResourceLeakDetector.setLevel(ResourceLeakDetector.Level.PARANOID);
    PooledByteBufAllocator alloc = PooledByteBufAllocator.DEFAULT;
    CompositeByteBuf buf = alloc.compositeDirectBuffer();
    CompositeByteBuf comp = alloc.compositeDirectBuffer();
    ByteBuf inner = alloc.directBuffer(1).writeByte(0);
    comp.addComponent(true, inner);
    buf.addComponent(true, comp);

    Assert.assertEquals(-1, buf.forEachByte(b -> true)); // throws NPE
}

Netty version

4.1.35-Final

JVM version

$ java -version
java version "1.8.0_201"
Java(TM) SE Runtime Environment (build 1.8.0_201-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode)

OS version

$ uname -a
Linux dk 4.15.0-66-generic #75-Ubuntu SMP Tue Oct 1 05:24:09 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
@normanmaurer
Copy link
Member

@dkomanov this issue does not exists in latest netty release. I added a unit test as prove as well in #9875

normanmaurer added a commit that referenced this issue Dec 12, 2019
…is no NPE

Motivation:

#9873 reported a NPE in previous version of netty. We should add a unit test to verify there is no more NPE

Modifications:

Add a unit test

Result:

Prove that #9873 is fixed
normanmaurer added a commit that referenced this issue Dec 12, 2019
…is no NPE (#9875)

Motivation:

#9873 reported a NPE in previous version of netty. We should add a unit test to verify there is no more NPE

Modifications:

Add a unit test

Result:

Prove that #9873 is fixed
normanmaurer added a commit that referenced this issue Dec 12, 2019
…is no NPE (#9875)

Motivation:

#9873 reported a NPE in previous version of netty. We should add a unit test to verify there is no more NPE

Modifications:

Add a unit test

Result:

Prove that #9873 is fixed
ihanyong pushed a commit to ihanyong/netty that referenced this issue Jul 31, 2020
…is no NPE (netty#9875)

Motivation:

netty#9873 reported a NPE in previous version of netty. We should add a unit test to verify there is no more NPE

Modifications:

Add a unit test

Result:

Prove that netty#9873 is fixed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants