Fixing ResourceCollection exists() and getInputStream()

Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
This commit is contained in:
Joakim Erdfelt 2020-09-22 14:10:49 -05:00
parent 35305b6a5c
commit c16b8f3a61
No known key found for this signature in database
GPG Key ID: 2D0E1FB8FE4B68B4
1 changed files with 17 additions and 2 deletions

View File

@ -19,6 +19,7 @@
package org.eclipse.jetty.util.resource;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
@ -281,7 +282,15 @@ public class ResourceCollection extends Resource
{
assertResourcesSet();
return true;
for (Resource r : _resources)
{
if (r.exists())
{
return true;
}
}
return false;
}
@Override
@ -307,13 +316,19 @@ public class ResourceCollection extends Resource
for (Resource r : _resources)
{
if (!r.exists())
{
// Skip, cannot open anyway
continue;
}
InputStream is = r.getInputStream();
if (is != null)
{
return is;
}
}
return null;
throw new FileNotFoundException("Resource does not exist");
}
@Override