[jira] [Work logged] (CONFIGURATION-756) Allow for custom behavior to handle errors loading included properties files.

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[jira] [Work logged] (CONFIGURATION-756) Allow for custom behavior to handle errors loading included properties files.

ASF GitHub Bot (Jira)

     [ https://issues.apache.org/jira/browse/CONFIGURATION-756?focusedWorklogId=311454&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-311454 ]

ASF GitHub Bot logged work on CONFIGURATION-756:
------------------------------------------------

                Author: ASF GitHub Bot
            Created on: 12/Sep/19 14:52
            Start Date: 12/Sep/19 14:52
    Worklog Time Spent: 10m
      Work Description: garydgregory commented on pull request #34: [CONFIGURATION-756] Allow for custom behavior to handle errors loading included properties files.
URL: https://github.com/apache/commons-configuration/pull/34
 
 
   
 
----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[hidden email]


Issue Time Tracking
-------------------

            Worklog Id:     (was: 311454)
    Remaining Estimate: 0h
            Time Spent: 10m

> Allow for custom behavior to handle errors loading included properties files.
> -----------------------------------------------------------------------------
>
>                 Key: CONFIGURATION-756
>                 URL: https://issues.apache.org/jira/browse/CONFIGURATION-756
>             Project: Commons Configuration
>          Issue Type: New Feature
>            Reporter: Gary Gregory
>            Assignee: Gary Gregory
>            Priority: Major
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> The properties file format in Commons Configuration allows for a properties file to load external properties files through a special key called {{"include"}}. This PR allows for a call site to customize what happens when an included file does not exist or is in error.
>   
>  [https://github.com/apache/commons-configuration/pull/34]
> The main change is to re-implement the current behavior for include error handing through a new consumer used in {{PropertiesConfiguration}} by introducing a functional interface to consume any type and throw {{ConfigurationException}}:
> {code:java}
> /**
>  * A Configuration task that may throw a ConfigurationException.
>  *
>  * @param <T> the type of the input to the operation.
>  * @since 2.6
>  */
> @FunctionalInterface
> public interface ConfigurationConsumer<T>
> {
>     /**
>      * Performs this operation on the given argument.
>      *
>      * @param t the input argument
>      * @throws ConfigurationException TODO
>      */
>     void accept(T t) throws ConfigurationException;
> }
> {code}
> The above is the common pattern when you need a consumer to throw a checked exception.
> The {{PropertiesConfiguration}} default behavior does not change and is implemented as:
> {code:java}
>     /**
>      * Defines default error handling for the special {@code "include"} key by throwing the given exception.
>      *
>      * @since 2.6
>      */
>     public static final ConfigurationConsumer<ConfigurationException> DEFAULT_INCLUDE_LISTENER = e ->
>     {
>         throw e;
>     };
> {code}
> In addition, a noop implementation is provided for simple use cases and tests:
> {code:java}
>     /**
>      * Defines error handling as a noop for the special {@code "include"} key.
>      *
>      * @since 2.6
>      */
>     public static final ConfigurationConsumer<ConfigurationException> NOOP_INCLUDE_LISTENER = e ->
>     {
>         // noop
>     };
> {code}
> You can set an include listener through new methods in {{PropertiesConfiguration}} and through the fluent API as well. See the PR for details.
> Note that this PR does not address detecting cyclical include files but does include a new test method which is decorated with {{@Ignore}}.
>   



--
This message was sent by Atlassian Jira
(v8.3.2#803003)