View Javadoc

1   /*
2    * Copyright 2013 The Netty Project
3    *
4    * The Netty Project licenses this file to you under the Apache License,
5    * version 2.0 (the "License"); you may not use this file except in compliance
6    * with the License. You may obtain a copy of the License at:
7    *
8    *   http://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, WITHOUT
12   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13   * License for the specific language governing permissions and limitations
14   * under the License.
15   */
16  
17  package io.netty.util;
18  
19  import java.util.Arrays;
20  
21  /**
22   * @deprecated This class will be removed in the future version.
23   */
24  @Deprecated
25  public class ResourceLeakException extends RuntimeException {
26  
27      private static final long serialVersionUID = 7186453858343358280L;
28  
29      private final StackTraceElement[] cachedStackTrace;
30  
31      public ResourceLeakException() {
32          cachedStackTrace = getStackTrace();
33      }
34  
35      public ResourceLeakException(String message) {
36          super(message);
37          cachedStackTrace = getStackTrace();
38      }
39  
40      public ResourceLeakException(String message, Throwable cause) {
41          super(message, cause);
42          cachedStackTrace = getStackTrace();
43      }
44  
45      public ResourceLeakException(Throwable cause) {
46          super(cause);
47          cachedStackTrace = getStackTrace();
48      }
49  
50      @Override
51      public int hashCode() {
52          StackTraceElement[] trace  = cachedStackTrace;
53          int hashCode = 0;
54          for (StackTraceElement e: trace) {
55              hashCode = hashCode * 31 + e.hashCode();
56          }
57          return hashCode;
58      }
59  
60      @Override
61      public boolean equals(Object o) {
62          if (!(o instanceof ResourceLeakException)) {
63              return false;
64          }
65          if (o == this) {
66              return true;
67          }
68  
69          return Arrays.equals(cachedStackTrace, ((ResourceLeakException) o).cachedStackTrace);
70      }
71  }