#159 Possible NPE bug in URL resolver

This commit is contained in:
Jonathan Shook 2020-06-19 13:02:31 -05:00
parent be5928c827
commit b723924e85
2 changed files with 5 additions and 2 deletions

View File

@ -73,6 +73,9 @@ public class ResolverForClasspath implements ContentResolver {
@Override
public List<Content<?>> resolve(URI uri) {
List<Path> paths = resolvePaths(uri);
if (paths==null) {
return List.of();
}
List<Content<?>> contents = paths.stream().map(PathContent::new).collect(Collectors.toList());
return contents;

View File

@ -64,8 +64,8 @@ public class URLContent implements Content<URL> {
InputStreamReader inputStreamReader = new InputStreamReader(inputStream, StandardCharsets.UTF_8);
BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
Stream<String> lines = bufferedReader.lines();
String buffdata = lines.collect(Collectors.joining());
this.buffer = ByteBuffer.wrap(buffdata.getBytes(StandardCharsets.UTF_8)).asCharBuffer().asReadOnlyBuffer();
String buffdata = lines.map(l -> l+"\n").collect(Collectors.joining());
return CharBuffer.wrap(buffdata);
}
return buffer;