vttranlina commented on a change in pull request #911:
URL: https://github.com/apache/james-project/pull/911#discussion_r822768610
##########
File path:
server/container/lifecycle-api/src/main/java/org/apache/james/lifecycle/api/Disposable.java
##########
@@ -29,4 +39,111 @@
* Dispose the object
*/
void dispose();
+
+ abstract class LeakAware implements Disposable {
+ public static class LeakDetectorException extends RuntimeException {
+ public LeakDetectorException() {
+ super();
+ }
+
+ public LeakDetectorException(String message) {
+ super(message);
+ }
+
+ public LeakDetectorException(String message, Throwable cause) {
+ super(message, cause);
+ }
+ }
+
+ public enum Level {
+ NONE,
+ SIMPLE,
+ ADVANCED,
+ TESTING;
+
+ static Level parse(String input) {
+ for (Level level : values()) {
+ if (level.name().equalsIgnoreCase(input)) {
+ return level;
+ }
+ }
+ throw new IllegalArgumentException(String.format("Unknown
level `%s`", input));
+ }
+ }
+
+ public static final ReferenceQueue<Object> REFERENCE_QUEUE = new
ReferenceQueue<>();
+ public static final List<LeakAwareFinalizer> LEAK_REFERENCES = new
ArrayList<>();
Review comment:
> BTW array list is not thread safe and should not be used in a threaded
environment (which we have)
We can use `Collections.synchronizedSet` to replace it.
> What is that list used for?
> My feeling is that it is useless.
Yes, I'm confused here too, but it is necessary. It needs a collection to
add `LeakAwareFinalizer`, if NOT, phantomReference mechanism will not work. (I
learn this code from some samples)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]