[
https://issues.apache.org/jira/browse/SLING-6482?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15888195#comment-15888195
]
Konrad Windszus edited comment on SLING-6482 at 2/28/17 3:23 PM:
-----------------------------------------------------------------
There is definitely something fishy going on here: In
{{LogConfigManager.updateLogWriter(...)}} an empty filename is converted to the
artificial string {{LogWriter.FILE_NAME_CONSOLE}}. The same logic is missing in
{{LogConfigManager.updateLoggerConfiguration()}}, but the check to turn a
relative file name into an absolute one is still relying on that
(https://github.com/apache/sling/blob/trunk/bundles/commons/log/src/main/java/org/apache/sling/commons/log/logback/internal/LogConfigManager.java#L560).
That leads to the fact that empty filenames are then converted into just the
root directory. Afterwards this fails in {{SlingLogPanel.getPath()}}.
Attached is a patch which fixes the SIOOBE. But the fact, that the filename is
now turned into the artificial String {{LogWriter.FILE_NAME_CONSOLE}} leads to
storing "console" as filename into the OSGi configuration when reediting the
same configuration through the Sling Log Support Web Console (which is then
interpreted as relative file name).
[~chetanm] Could you please have a look, as you are more familiar with that
code?
was (Author: kwin):
There is definitely something fishy going on here: In
{{LogConfigManager.updateLogWriter(...)}} an empty filename is converted to the
artificial string {{LogWriter.FILE_NAME_CONSOLE}}. The same logic is missing in
{{LogConfigManager.updateLoggerConfiguration()}}, but the check to turn a
relative file name into an absolute one is still relying on that
(https://github.com/apache/sling/blob/trunk/bundles/commons/log/src/main/java/org/apache/sling/commons/log/logback/internal/LogConfigManager.java#L560).
That leads to the fact that empty filenames are then converted into just the
root directory. Afterwards this fails in {{SlingLogPanel.getPath()}}.
Attached is a patch which fixes the SIOOBE but the fact, that the filename is
now turned into the artificial String {{LogWriter.FILE_NAME_CONSOLE}} leads to
the fact, that editing the same configuration will store the artificial name
{{console}} as file name (which is then interpreted as relative file name).
[~chetanm] Could you please have a look, as you are more familiar with that
code?
> Commons Log WebConsole: Exception when creating logger without log file
> -----------------------------------------------------------------------
>
> Key: SLING-6482
> URL: https://issues.apache.org/jira/browse/SLING-6482
> Project: Sling
> Issue Type: Bug
> Components: Commons
> Affects Versions: Commons Log 5.0.0
> Reporter: Bjoern Weide
> Priority: Minor
> Fix For: Commons Log 5.0.2
>
> Attachments: SLING-6482-v01.patch
>
>
> When creating a new logger via WebConsole specifying an empty logfile it
> causes an StringIndexOutOfBoundsException when (re-)opening the WebConsole.
> {noformat}
> java.lang.StringIndexOutOfBoundsException: String index out of range: -1
> at java.lang.String.substring(String.java:1931)
> at
> org.apache.sling.commons.log.logback.internal.SlingLogPanel.getPath(SlingLogPanel.java:791)
> ...
> {noformat}
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)