[ 
https://issues.apache.org/jira/browse/LOG4J2-1553?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15445981#comment-15445981
 ] 

Remko Popma commented on LOG4J2-1553:
-------------------------------------

This is my "template" of points I try to cover in a Jira:

# What is the proposed change
# Why do I want to do this (benefits)
# Potential drawbacks
# How I propose to mitigate the drawbacks (and/or explain why the proposal is a 
good trade-off)

(If any of the above is missing, it just makes the reader do the work of 
figuring out what it could be...)

In the case of this ticket, I would expect something like
{quote}
I propose to let AbstractManager implement AutoCloseable.

This will make our tests cleaner, smaller and hopefully less error-prone. 
Current code:
{code}
FileManager mgr = new FileManager(lots, of, params);
try {
    // test code
} finally {
    mgr.close();
}
{code}

After the proposed change, our test code can look like this:
{code}
try (FileManager mgr = new FileManager(lots, of, params)) {
    // test code
}
{code}

A drawback is that there is some potential for confusing contributors or other 
people reading our code: AutoCloseable is often used with short-lived objects, 
while in "production" usage the Managers in Log4j live for a very long time. 
Implementing AutoCloseable will not be useful for "production" usage of 
Managers, it will only be useful for tests. 

I believe we can reduce the risk of confusing people by documenting (javadoc 
and normal comments where appropriate) in our code where we implement  
AutoCloseable that this is to facilitate testing and not for production usage.
{quote}
This would tick all the four boxes I mention above.


> AbstractManager should implement AutoCloseable
> ----------------------------------------------
>
>                 Key: LOG4J2-1553
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-1553
>             Project: Log4j 2
>          Issue Type: Improvement
>          Components: Appenders
>            Reporter: Gary Gregory
>            Assignee: Gary Gregory
>
> AbstractManager should implement AutoCloseable.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to