Ensure backward compatibility
.. by resurrecting the removed methods and system properties.
This commit is contained in:
parent
65b522a2a7
commit
e88172495a
@ -27,7 +27,7 @@ import java.nio.channels.GatheringByteChannel;
|
||||
import java.nio.channels.ScatteringByteChannel;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
public class WrappedByteBuf extends ByteBuf {
|
||||
class WrappedByteBuf extends ByteBuf {
|
||||
|
||||
protected final ByteBuf buf;
|
||||
|
||||
|
@ -66,7 +66,14 @@ public final class ResourceLeakDetector<T> {
|
||||
private static final InternalLogger logger = InternalLoggerFactory.getInstance(ResourceLeakDetector.class);
|
||||
|
||||
static {
|
||||
String levelStr = SystemPropertyUtil.get(PROP_LEVEL, DEFAULT_LEVEL.name()).trim().toUpperCase();
|
||||
final boolean disabled = SystemPropertyUtil.getBoolean("io.netty.noResourceLeakDetection", false);
|
||||
logger.debug("-Dio.netty.noResourceLeakDetection: {}", disabled);
|
||||
logger.warn(
|
||||
"-Dio.netty.noResourceLeakDetection is deprecated. Use '-D{}={}' instead.",
|
||||
PROP_LEVEL, DEFAULT_LEVEL.name().toLowerCase());
|
||||
|
||||
Level defaultLevel = disabled? Level.DISABLED : DEFAULT_LEVEL;
|
||||
String levelStr = SystemPropertyUtil.get(PROP_LEVEL, defaultLevel.name()).trim().toUpperCase();
|
||||
Level level = DEFAULT_LEVEL;
|
||||
for (Level l: EnumSet.allOf(Level.class)) {
|
||||
if (levelStr.equals(l.name()) || levelStr.equals(String.valueOf(l.ordinal()))) {
|
||||
@ -82,6 +89,21 @@ public final class ResourceLeakDetector<T> {
|
||||
|
||||
private static final int DEFAULT_SAMPLING_INTERVAL = 113;
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #setLevel(ResourceLeakDetector.Level)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public static void setEnabled(boolean enabled) {
|
||||
setLevel(enabled? Level.SIMPLE : Level.DISABLED);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@code true} if resource leak detection is enabled.
|
||||
*/
|
||||
public static boolean isEnabled() {
|
||||
return getLevel().ordinal() > Level.DISABLED.ordinal();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the resource leak detection level.
|
||||
*/
|
||||
|
@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright 2013 The Netty Project
|
||||
*
|
||||
* The Netty Project licenses this file to you 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:
|
||||
*
|
||||
* http://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 io.netty.util;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* @deprecated This class will be removed in the future version.
|
||||
*/
|
||||
@Deprecated
|
||||
public class ResourceLeakException extends RuntimeException {
|
||||
|
||||
private static final long serialVersionUID = 7186453858343358280L;
|
||||
|
||||
private final StackTraceElement[] cachedStackTrace;
|
||||
|
||||
public ResourceLeakException() {
|
||||
cachedStackTrace = getStackTrace();
|
||||
}
|
||||
|
||||
public ResourceLeakException(String message) {
|
||||
super(message);
|
||||
cachedStackTrace = getStackTrace();
|
||||
}
|
||||
|
||||
public ResourceLeakException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
cachedStackTrace = getStackTrace();
|
||||
}
|
||||
|
||||
public ResourceLeakException(Throwable cause) {
|
||||
super(cause);
|
||||
cachedStackTrace = getStackTrace();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
StackTraceElement[] trace = cachedStackTrace;
|
||||
int hashCode = 0;
|
||||
for (StackTraceElement e: trace) {
|
||||
hashCode = hashCode * 31 + e.hashCode();
|
||||
}
|
||||
return hashCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (!(o instanceof ResourceLeakException)) {
|
||||
return false;
|
||||
}
|
||||
if (o == this) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return Arrays.equals(cachedStackTrace, ((ResourceLeakException) o).cachedStackTrace);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user