Reactor-netty: SslProvider causes netty to start a Thread in a static initializer

Created on 3 Jul 2018  Â·  8Comments  Â·  Source: reactor/reactor-netty

SslProvider here causes Netty to start a new Thread. That's probably going to cause issues in other ways, but right now it's a blocker for getting reactor-netty running as a native image in GraalVM.

Here's a stack trace from the IDE debugger:

FastThreadLocalRunnable.wrap(Runnable) line: 37    
FastThreadLocalThread.<init>(Runnable) line: 35    
ObjectCleaner.register(Object, Runnable) line: 103    
ByteBufUtil$1(FastThreadLocal<V>).registerCleaner(InternalThreadLocalMap) line: 158    
ByteBufUtil$1(FastThreadLocal<V>).get() line: 144    
ByteBufUtil.decodeString(ByteBuf, int, int, Charset) line: 759    
UnpooledSlicedByteBuf(AbstractByteBuf).toString(int, int, Charset) line: 1222    
UnpooledSlicedByteBuf(AbstractByteBuf).toString(Charset) line: 1217    
SelfSignedCertificate.newSelfSignedCertificate(String, PrivateKey, X509Certificate) line: 230    
OpenJdkSelfSignedCertGenerator.generate(String, KeyPair, SecureRandom, Date, Date) line: 79    
SelfSignedCertificate.<init>(String, SecureRandom, int, Date, Date) line: 149    
SelfSignedCertificate.<init>(String, Date, Date) line: 110    
SelfSignedCertificate.<init>(Date, Date) line: 88    
SelfSignedCertificate.<init>() line: 79    
SslProvider$Build.<clinit>() line: 228    
SslProvider.builder() line: 61    
SslProvider.<clinit>() line: 610    
...
typbug

Most helpful comment

This was „fixed“ and will be included in the next release of Netty https://github.com/netty/netty/commit/5b1fe611a637c362a60b391079fff73b1a4ef912

All 8 comments

This was „fixed“ and will be included in the next release of Netty https://github.com/netty/netty/commit/5b1fe611a637c362a60b391079fff73b1a4ef912

@dsyer I made changes in Reactor Netty #383. Can you test them?

You didn't change the netty dependency though? So the change from @normanmaurer is not included yet?

No, but I removed the creation of SelfSignedCertificate in a static block.
I tested it on my side (just Reactor Netty, no Spring) and I did not see the issue.

It's still broken for me unless I upgrade netty as well to snapshots. There's a static initializer in HttpServer that triggers the same code path:

PooledByteBufAllocator$PoolThreadLocalCache(FastThreadLocal<V>).<init>() line: 129  
PooledByteBufAllocator$PoolThreadLocalCache.<init>(PooledByteBufAllocator, boolean) line: 429   
PooledByteBufAllocator.<init>(boolean, int, int, int, int, int, int, int, boolean, int) line: 204   
PooledByteBufAllocator.<init>(boolean, int, int, int, int, int, int, int) line: 187 
PooledByteBufAllocator.<init>(boolean, int, int, int, int) line: 176    
PooledByteBufAllocator.<init>(boolean) line: 162    
PooledByteBufAllocator.<clinit>() line: 143 
TcpServer.<clinit>() line: 558  
HttpServer.<clinit>() line: 377 
NettyReactiveWebServerFactory.createHttpServer() line: 111  

hmm
the line number is not the same but I think it should be this one
https://github.com/reactor/reactor-netty/blob/48f1be5d7b9a2760fbabcab5c93df547ae7a1d05/src/main/java/reactor/netty/tcp/TcpServer.java#L575
but for this one I prefer to wait for the Netty fix

I'm also happy to move this to lazy creation, we don't expect a server to be created as many times as clients. I was probably attracted by the symmetric implementation rather than something more pragmatic here.

Netty also is updated to version 4.1.26.Final with e8f4c46518eb62b00f42713cfc5b8a71d94032d8

Was this page helpful?
0 / 5 - 0 ratings

Related issues

flisky picture flisky  Â·  6Comments

nebhale picture nebhale  Â·  4Comments

magx2 picture magx2  Â·  6Comments

violetagg picture violetagg  Â·  4Comments

smaldini picture smaldini  Â·  3Comments