Skip to content

Commit 7f2d4fc

Browse files
committed
Polish "Allow Netty default leak detection to be overidden"
See gh-32144
1 parent 51f2e40 commit 7f2d4fc

File tree

3 files changed

+46
-8
lines changed

3 files changed

+46
-8
lines changed

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/netty/NettyProperties.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2021 the original author or authors.
2+
* Copyright 2012-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -30,9 +30,11 @@
3030
public class NettyProperties {
3131

3232
/**
33-
* Level of leak detection for reference-counted buffers.
33+
* Level of leak detection for reference-counted buffers. If not configured via
34+
* 'ResourceLeakDetector.setLevel' or the 'io.netty.leakDetection.level' system
35+
* property, default to 'simple'.
3436
*/
35-
private LeakDetection leakDetection = null;
37+
private LeakDetection leakDetection;
3638

3739
public LeakDetection getLeakDetection() {
3840
return this.leakDetection;

spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1736,11 +1736,6 @@
17361736
"name": "spring.neo4j.uri",
17371737
"defaultValue": "bolt://localhost:7687"
17381738
},
1739-
{
1740-
"name": "spring.netty.leak-detection",
1741-
"description": "When null, fall back to Netty system default 'simple' or value of -Dio.netty.leakDetection.level. When set, this will overrride value of -Dio.netty.leakDetection.level",
1742-
"defaultValue": "null"
1743-
},
17441739
{
17451740
"name": "spring.quartz.jdbc.comment-prefix",
17461741
"defaultValue": [
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright 2012-2022 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.boot.autoconfigure.netty;
18+
19+
import io.netty.util.ResourceLeakDetector;
20+
import io.netty.util.ResourceLeakDetector.Level;
21+
import org.junit.jupiter.api.Test;
22+
23+
import org.springframework.test.util.ReflectionTestUtils;
24+
25+
import static org.assertj.core.api.Assertions.assertThat;
26+
27+
/**
28+
* Tests for {@link NettyProperties}
29+
*
30+
* @author Brian Clozel
31+
*/
32+
class NettyPropertiesTests {
33+
34+
@Test
35+
void defaultValueShouldBeConsistent() {
36+
ResourceLeakDetector.Level defaultLevel = (Level) ReflectionTestUtils.getField(ResourceLeakDetector.class,
37+
"DEFAULT_LEVEL");
38+
assertThat(defaultLevel).isEqualTo(Level.SIMPLE);
39+
}
40+
41+
}

0 commit comments

Comments
 (0)