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

Rakesh Kumar commented on FELIX-6393:
-------------------------------------

Steps to replicate.
 # Create file install factory config in Felix WebConsole.
 # Create the load directory in current user.dir
 # Place bundle.

Following code is invoked from DirectoryWatcher constructor.

 
{code:java}
try {
    scanner = new WatcherScanner(context, watchedDirectory, filter, 
properties.get(SUBDIR_MODE));
} catch (Throwable t) {
    scanner = new Scanner(watchedDirectory, filter, 
properties.get(SUBDIR_MODE));
}
{code}
When a config is saved without the load directory the exception is thrown from 
WatcherScanner constructor in try block, basically and hence the Scanner is 
initialised in exception block with empty filter.

In Scanner constructor when filter string is null or empty the FileNameFilter 
reference is kept as null.
{code:java}
public Scanner(File directory, final String filterString, String subdirMode)
{
    this.directory = canon(directory);
    if (filterString != null && filterString.length() > 0)
    {
        this.filter = new FilenameFilter()
        {
            Pattern pattern = Pattern.compile(filterString);
            public boolean accept(File dir, String name)
            {
                return pattern.matcher(name).matches();
            }
        };
    }
    else
    {
        this.filter = null;
    }
    this.jarSubdir = subdirMode == null || SUBDIR_MODE_JAR.equals(subdirMode);
    this.skipSubdir = SUBDIR_MODE_SKIP.equals(subdirMode);
    this.recurseSubdir = SUBDIR_MODE_RECURSE.equals(subdirMode);
}
{code}
 

> FileInstall | In main loop, we have serious trouble | 
> java.lang.NullPointerException: null
> ------------------------------------------------------------------------------------------
>
>                 Key: FELIX-6393
>                 URL: https://issues.apache.org/jira/browse/FELIX-6393
>             Project: Felix
>          Issue Type: Bug
>          Components: File Install
>    Affects Versions: fileinstall-3.6.8
>            Reporter: Rakesh Kumar
>            Priority: Major
>
> I was trying to configure the Felix file install and after the configuration 
> in Felix WebConsole is done I placed a bundle in configured load directory 
> and it went into an endless exceptions.
> I had to kill the server to get over it.
> Here is the exception trace.
> {code:java}
> 2021-03-07 06:36:09.942 [FelixLogListener] ERROR 
> com.adeptj.modules.commons.logging.osgi.Logger - In main loop, we have 
> serious trouble
> java.lang.NullPointerException: null
>       at 
> org.apache.felix.fileinstall.internal.Scanner.processFiles(Scanner.java:158)
>       at org.apache.felix.fileinstall.internal.Scanner.scan(Scanner.java:131)
>       at 
> org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:311)
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to