[jboss-jira] [JBoss JIRA] (JBLOGGING-55) NPE in FileAppender$Helper

David Lloyd (JIRA) jira-events at lists.jboss.org
Fri May 25 13:45:18 EDT 2012


     [ https://issues.jboss.org/browse/JBLOGGING-55?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

David Lloyd resolved JBLOGGING-55.
----------------------------------

    Resolution: Out of Date


These handlers are no longer in the current codebase, so I'm going to close this issue.
                
> NPE in FileAppender$Helper
> --------------------------
>
>                 Key: JBLOGGING-55
>                 URL: https://issues.jboss.org/browse/JBLOGGING-55
>             Project: JBoss Logging
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>            Reporter: Ondrej Zizka
>            Assignee: David Lloyd
>         Attachments: log4j.xml
>
>
> When you set the file="..." to just a file, i.e. file="foobar.log", 
> then you get a NPE at line
>     if (!dir.exists()) {
> probably because 
>     dir = new File(filename.trim()).getParentFile();
> returns null.
> I'd expect the appender to write to a file in new File( new File(System.getProperty("user.dir")), filename.trim() ).
> package org.jboss.logging.appender;
> import java.io.File;
> import java.net.MalformedURLException;
> import java.net.URL;
> import org.apache.log4j.helpers.LogLog;
> public class FileAppender$Helper
> {
>   public static void makePath(String filename)
>   {
>     File dir;
>     try
>     {
>       URL url = new URL(filename.trim());
>       dir = new File(url.getFile()).getParentFile();
>     }
>     catch (MalformedURLException e) {
>       dir = new File(filename.trim()).getParentFile();
>     }
>     if (!dir.exists()) {
>       boolean success = dir.mkdirs();
>       if (!success)
>         LogLog.error("Failed to create directory structure: " + dir);
>     }
>   }
> }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the jboss-jira mailing list