Skip to content

Commit

Permalink
Polish "Allow Netty default leak detection to be overidden"
Browse files Browse the repository at this point in the history
  • Loading branch information
snicoll committed Aug 23, 2022
1 parent 51f2e40 commit 7f2d4fc
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 8 deletions.
@@ -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");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -30,9 +30,11 @@
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 = null;
private LeakDetection leakDetection;

public LeakDetection getLeakDetection() {
return this.leakDetection;
Expand Down
Expand Up @@ -1736,11 +1736,6 @@
"name": "spring.neo4j.uri",
"defaultValue": "bolt://localhost:7687"
},
{
"name": "spring.netty.leak-detection",
"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",
"defaultValue": "null"
},
{
"name": "spring.quartz.jdbc.comment-prefix",
"defaultValue": [
Expand Down
@@ -0,0 +1,41 @@
/*
* Copyright 2012-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.springframework.boot.autoconfigure.netty;

import io.netty.util.ResourceLeakDetector;
import io.netty.util.ResourceLeakDetector.Level;
import org.junit.jupiter.api.Test;

import org.springframework.test.util.ReflectionTestUtils;

import static org.assertj.core.api.Assertions.assertThat;

/**
* Tests for {@link NettyProperties}
*
* @author Brian Clozel
*/
class NettyPropertiesTests {

@Test
void defaultValueShouldBeConsistent() {
ResourceLeakDetector.Level defaultLevel = (Level) ReflectionTestUtils.getField(ResourceLeakDetector.class,
"DEFAULT_LEVEL");
assertThat(defaultLevel).isEqualTo(Level.SIMPLE);
}

}

0 comments on commit 7f2d4fc

Please sign in to comment.