Skip to content
This repository was archived by the owner on May 10, 2024. It is now read-only.

Commit f4a06fb

Browse files
committed
fix methods from wrong Java version, fix types
1 parent 9b900bd commit f4a06fb

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,9 @@
130130
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
131131
</properties>
132132

133-
<name>OneMTA</name>
133+
<name>SimpleHttpServer</name>
134134
<description>A simple and efficient HTTP server for Java</description>
135-
<url>https://github.com/KatsuteDev/simplehttpser</url>
135+
<url>https://github.com/KatsuteDev/simplehttpserver</url>
136136

137137
<licenses>
138138
<license>

src/main/java/dev/katsute/simplehttpserver/handler/file/DirectoryEntry.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,14 @@ public class DirectoryEntry {
4848

4949
if(loadingOption != FileLoadingOption.LIVE){
5050
if(!isWalkthrough){
51-
final File[] listFiles = Objects.requireNonNullElse(directory.listFiles(File::isFile), new File[0]);
52-
for(final File file : listFiles)
53-
addFile(file);
51+
final File[] listFiles = directory.listFiles(File::isFile);
52+
if(listFiles != null)
53+
for(final File file : listFiles)
54+
addFile(file);
5455
}else{
5556
try{
56-
Files.walkFileTree(directoryPath, new SimpleFileVisitor<>() {
57+
//noinspection Convert2Diamond
58+
Files.walkFileTree(directoryPath, new SimpleFileVisitor<Path>() { // won't compile unless we explicitly set type
5759
@Override
5860
public final FileVisitResult visitFile(final Path path, final BasicFileAttributes attrs){
5961
addDirectoryFile(path.toFile());
@@ -107,9 +109,11 @@ public final File getFile(final String path){
107109
final String fileName = targetFile.getParentFile() == null ? targetFile.getPath() : targetFile.getName();
108110

109111
// for each file in parent directory, run adapter to find file that matches adapted name
110-
for(final File file : Objects.requireNonNullElse(parentFile.listFiles(), new File[0]))
111-
if(fileName.equals(adapter.getName(file)))
112-
return file;
112+
final File[] parentFiles = parentFile.listFiles();
113+
if(parentFiles != null)
114+
for(final File file : parentFiles)
115+
if(fileName.equals(adapter.getName(file)))
116+
return file;
113117
return null;
114118
}
115119

0 commit comments

Comments
 (0)