Skip to content

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

@russellyou

Description

@russellyou

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions