Hello,
In class org.apache.felix.fileinstall.internal.DirectoryWatcher in
method run, there is a while loop with a condition checking if the
DirectoryWatcher has been interrupted. If an InterruptedException is
thrown in during the wait Operation the Method returns - as you would
expect from an interruption.
The run Method calls refresh, which in turn calls FileInstall.refresh.
This method swallows the InterruptedException and throws a
RuntimeException. If the thread gets interrupted in the 30 second
waiting period, the InterruptedException is thrown and thus _clearing
the interrupted status of that thread_. In the run method the exception
is logged and since the interrupted status is cleared, the while loop
will return. Is this behavior intendet to be? Shouldn't the
FileInstall.refresh method throw an InterruptedException so callers can
handle it appropriately?
We are experiencing the DirectoryWatcher continuing to work when we
update for bundle folder and then shutting down the Felix framework. The
thread leaves the run method eventually, because context.getBundle()
throws an IllegalStateException, however the interruption will be
ignored. (We are using felix 4.2.1 and fileinstall 3.2.6)
// DirectoryWatcher
public void run()
{
// ...
while (!interrupted())
{
try
{
// Don't access the disk when the framework is still in
a startup phase.
if (FileInstall.getStartLevel().getStartLevel() >=
activeLevel
&& context.getBundle(0).getState() ==
Bundle.ACTIVE)
{
Set/*<File>*/ files = scanner.scan(false);
// Check that there is a result. If not, this means
that the directory can not be listed,
// so it's presumably not a valid directory (it may
have been deleted by someone).
// In such case, just sleep
if (files != null)
{
process(files);
}
}
synchronized (this)
{
wait(poll);
}
}
catch (InterruptedException e)
{
return;
}
catch (Throwable e)
{
try
{
context.getBundle();
}
catch (IllegalStateException t)
{
// FileInstall bundle has been uninstalled, exiting
loop
return;
}
log(Logger.LOG_ERROR, "In main loop, we have serious
trouble", e);
}
}
}
//FileInstall
static void refresh(Bundle[] bundles)
{
PackageAdmin padmin = getPackageAdmin();
if (padmin != null)
{
synchronized (refreshLock) {
padmin.refreshPackages(bundles);
try {
refreshLock.wait(30000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
}
}
Regards,
Benjamin Rogge