Merge pull request #32144 from russellyou

* pr/32144:
  Polish "Allow Netty default leak detection to be overidden"
  Allow Netty default leak detection to be overidden

Closes gh-32144
This commit is contained in:
Stephane Nicoll 2022-08-23 07:25:39 +02:00
commit 463766fd44
3 changed files with 8 additions and 11 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2021 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -30,9 +30,11 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
public class NettyProperties { public class NettyProperties {
/** /**
* Level of leak detection for reference-counted buffers. * Level of leak detection for reference-counted buffers. If not configured via
* 'ResourceLeakDetector.setLevel' or the 'io.netty.leakDetection.level' system
* property, default to 'simple'.
*/ */
private LeakDetection leakDetection = LeakDetection.SIMPLE; private LeakDetection leakDetection;
public LeakDetection getLeakDetection() { public LeakDetection getLeakDetection() {
return this.leakDetection; return this.leakDetection;

View File

@ -1736,10 +1736,6 @@
"name": "spring.neo4j.uri", "name": "spring.neo4j.uri",
"defaultValue": "bolt://localhost:7687" "defaultValue": "bolt://localhost:7687"
}, },
{
"name": "spring.netty.leak-detection",
"defaultValue": "simple"
},
{ {
"name": "spring.quartz.jdbc.comment-prefix", "name": "spring.quartz.jdbc.comment-prefix",
"defaultValue": [ "defaultValue": [

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2021 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -32,11 +32,10 @@ import static org.assertj.core.api.Assertions.assertThat;
class NettyPropertiesTests { class NettyPropertiesTests {
@Test @Test
void defaultValueShouldMatchNettys() { void defaultValueShouldBeConsistent() {
NettyProperties properties = new NettyProperties();
ResourceLeakDetector.Level defaultLevel = (Level) ReflectionTestUtils.getField(ResourceLeakDetector.class, ResourceLeakDetector.Level defaultLevel = (Level) ReflectionTestUtils.getField(ResourceLeakDetector.class,
"DEFAULT_LEVEL"); "DEFAULT_LEVEL");
assertThat(ResourceLeakDetector.Level.valueOf(properties.getLeakDetection().name())).isEqualTo(defaultLevel); assertThat(defaultLevel).isEqualTo(Level.SIMPLE);
} }
} }