Arsnael commented on a change in pull request #911:
URL: https://github.com/apache/james-project/pull/911#discussion_r825559125
##########
File path:
server/container/lifecycle-api/src/main/java/org/apache/james/lifecycle/api/Disposable.java
##########
@@ -29,4 +41,169 @@
* Dispose the object
*/
void dispose();
+
+ abstract class LeakAware<T extends LeakAware.Resource> implements
Disposable {
+ public static class Resource implements Disposable {
+ private final AtomicBoolean isDisposed = new AtomicBoolean(false);
+ private final Disposable cleanup;
+
+ public Resource(Disposable cleanup) {
+ this.cleanup = cleanup;
+ }
+
+ public boolean isDisposed() {
+ return isDisposed.get();
+ }
+
+ @Override
+ public void dispose() {
+ isDisposed.set(true);
+ cleanup.dispose();
+ }
+ }
+
+ public static class LeakDetectorException extends RuntimeException {
+ public LeakDetectorException() {
+ super();
+ }
+ }
+
+ 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<LeakAware<?>> REFERENCE_QUEUE = new
ReferenceQueue<>();
+ public static final ConcurrentHashMap<LeakAwareFinalizer, Boolean>
REFERENCES_IN_USE = new ConcurrentHashMap<>();
+ public static final Level LEVEL =
Optional.ofNullable(System.getProperty("james.ligecycle.leak.detection.mode"))
Review comment:
```suggestion
public static final Level LEVEL =
Optional.ofNullable(System.getProperty("james.lifecycle.leak.detection.mode"))
```
##########
File path:
server/container/lifecycle-api/src/main/java/org/apache/james/lifecycle/api/Disposable.java
##########
@@ -29,4 +41,169 @@
* Dispose the object
*/
void dispose();
+
+ abstract class LeakAware<T extends LeakAware.Resource> implements
Disposable {
+ public static class Resource implements Disposable {
+ private final AtomicBoolean isDisposed = new AtomicBoolean(false);
+ private final Disposable cleanup;
+
+ public Resource(Disposable cleanup) {
+ this.cleanup = cleanup;
+ }
+
+ public boolean isDisposed() {
+ return isDisposed.get();
+ }
+
+ @Override
+ public void dispose() {
+ isDisposed.set(true);
+ cleanup.dispose();
+ }
+ }
+
+ public static class LeakDetectorException extends RuntimeException {
+ public LeakDetectorException() {
+ super();
+ }
+ }
+
+ 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<LeakAware<?>> REFERENCE_QUEUE = new
ReferenceQueue<>();
+ public static final ConcurrentHashMap<LeakAwareFinalizer, Boolean>
REFERENCES_IN_USE = new ConcurrentHashMap<>();
+ public static final Level LEVEL =
Optional.ofNullable(System.getProperty("james.ligecycle.leak.detection.mode"))
Review comment:
And change the rest of the code accordingly :)
--
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]