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

Gary Gregory commented on LOG4J2-2001:
--------------------------------------

Thank you for your report.

Please feel free to provide a patch on GitHub 
https://github.com/apache/logging-log4j2

Gary

> StyleConverter.newInstance argument validation is incorrect
> -----------------------------------------------------------
>
>                 Key: LOG4J2-2001
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-2001
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Configurators
>    Affects Versions: 2.8.2
>            Reporter: Paul Burrowes
>            Priority: Minor
>
> There are three bugs in the argument handling of StyleConverter.newInstance.
> Firstly the javadoc says {{options}} may be null. It must not be.
> Secondly the method doesn't validate that it is not null.
> Thirdly it validates that {{options.length <1}} when the subsequent code 
> requires {{options.length >=2}}
> {code}
>     /**
>      * Gets an instance of the class.
>      *
>      * @param config
>      *            The current Configuration.
>      * @param options
>      *            pattern options, may be null. If first element is "short", 
> only the first line of the throwable will
>      *            be formatted.
>      * @return instance of class.
>      */
>     public static StyleConverter newInstance(final Configuration config, 
> final String[] options) {
>         if (options.length < 1) {
>             LOGGER.error("Incorrect number of options on style. Expected at 
> least 1, received " + options.length);
>             return null;
>         }
>         if (options[0] == null) {
>             LOGGER.error("No pattern supplied on style");
>             return null;
>         }
>         if (options[1] == null) {
>             LOGGER.error("No style attributes provided");
>             return null;
>         }
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to