question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Netty 'spring.netty-leak-detection' default property value is always applied to ResourceLeakDetector

See original GitHub issue

Spring will override the Netty leak detection level set using -Dio.netty.leakDetection.level=advanced

The code below want to set leak detection if property was not null. But the property has default value as SIMPLE. This will get leak detection overridden as SIMPLE always if you set it other value like ‘advanced’ outside of Spring

public class NettyProperties {
	private LeakDetection leakDetection = LeakDetection.SIMPLE;

...
public class NettyAutoConfiguration {
	public NettyAutoConfiguration(NettyProperties properties) {
		if (properties.getLeakDetection() != null) {
			NettyProperties.LeakDetection leakDetection = properties.getLeakDetection();
			ResourceLeakDetector.setLevel(ResourceLeakDetector.Level.valueOf(leakDetection.name()));
		}
	}
}
...

changed to

if (properties.getLeakDetection() != LeakDetection.SIMPLE) {

will solve the problem as LeakDetection will be simple if not set.

Happy to raise a PR if this is

Version: current main branch

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
philwebbcommented, Aug 22, 2022

We’re going to change the default value in NettyProperties to null and update the description to indicate that when not set the Netty default (which is SIMPLE) will be used.

1reaction
bclozelcommented, Aug 19, 2022

I think I’ve changed my mind. Developers can configure this with:

  • a static call ResourceLeakDetector.setLevel(ResourceLeakDetector.Level.PARANOID);
  • -Dio.netty.leakDetection.level=paranoid
  • the Spring Boot configuration property

The configuration property should only apply if a specific value has been set, so setting the default value to null might be a good compromise. With all 3 ways involved, we’re always going to find a combination that leads to strange results. This is why we initially declined #14338.

Even with this solution, if ResourceLeakDetector.setLevel() is called within a bean, the configuration property will be overridden. This could be a breaking change if our configuration property currently shadows an existing system property - upgrading Spring Boot might change the resulting behavior.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Netty 'spring.netty leak detection' default property value is ...
Netty 'spring.netty leak detection' default property value is always applied to resource leak detector #32145.
Read more >
spring default property values always default to second
Properties (first.value and last.value) are being loaded as such: <context:property-placeholder location="classpath:com/test/testing.properties ...
Read more >
Common Application Properties - Spring
Name Description Default... spring.cassandra.config Location of the configuration file to use. spring.cassandra.controlconnection.timeout Timeout to use for control queries. 5s spring.cassandra.keyspace‑name Keyspace name to use.
Read more >
Spring Boot アプリケーションプロパティ設定一覧
生成された git.properties ファイルの場所。 classpath:git.properties. spring.jmx.default-domain. JMX ドメイン名。
Read more >
Spring Boot Reactor Netty Configuration - Baeldung
In this tutorial, we're going to look at different configuration options for a Reactor Netty server in a Spring Boot application.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found