This is an automated email from the ASF dual-hosted git repository.

mgrigorov pushed a commit to branch wicket-9.x
in repository https://gitbox.apache.org/repos/asf/wicket.git


The following commit(s) were added to refs/heads/wicket-9.x by this push:
     new 5ebe281558 WICKET-7091: FilePageStore throws NPE
5ebe281558 is described below

commit 5ebe281558e39a15a412001de83237804e5cbc33
Author: Martin Tzvetanov Grigorov <mgrigo...@apache.org>
AuthorDate: Mon Dec 11 14:25:57 2023 +0200

    WICKET-7091: FilePageStore throws NPE
    
    Signed-off-by: Martin Tzvetanov Grigorov <mgrigo...@apache.org>
    (cherry picked from commit 8a1eb725682e4dc1ac35d636e3ccf5aa1d2dc9ca)
---
 .../src/main/java/org/apache/wicket/pageStore/FilePageStore.java    | 6 +++---
 .../main/java/org/apache/wicket/examples/source/SourcesPage.java    | 4 ++--
 .../java/org/apache/wicket/examples/upload/MultiUploadPage.java     | 2 +-
 .../src/main/java/org/apache/wicket/examples/upload/UploadPage.java | 3 +--
 4 files changed, 7 insertions(+), 8 deletions(-)

diff --git 
a/wicket-core/src/main/java/org/apache/wicket/pageStore/FilePageStore.java 
b/wicket-core/src/main/java/org/apache/wicket/pageStore/FilePageStore.java
index 38a8d0a735..f15d5bdd8b 100644
--- a/wicket-core/src/main/java/org/apache/wicket/pageStore/FilePageStore.java
+++ b/wicket-core/src/main/java/org/apache/wicket/pageStore/FilePageStore.java
@@ -229,7 +229,7 @@ public class FilePageStore extends 
AbstractPersistentPageStore implements IPersi
 
        private void checkMaxSize(String sessionIdentifier)
        {
-               File[] files = folders.get(sessionIdentifier, true).listFiles();
+               File[] files = Files.list(folders.get(sessionIdentifier, true));
                Arrays.sort(files, new LastModifiedComparator());
 
                long total = 0;
@@ -277,7 +277,7 @@ public class FilePageStore extends 
AbstractPersistentPageStore implements IPersi
                File folder = folders.get(sessionIdentifier, false);
                if (folder.exists())
                {
-                       File[] files = folder.listFiles();
+                       File[] files = Files.list(folder);
                        Arrays.sort(files, new LastModifiedComparator());
                        for (File file : files)
                        {
@@ -368,7 +368,7 @@ public class FilePageStore extends 
AbstractPersistentPageStore implements IPersi
 
                for (File folder : folders.getAll())
                {
-                       for (File file : folder.listFiles())
+                       for (File file : Files.list(folder))
                        {
                                String name = file.getName();
                                if (name.endsWith(FILE_SUFFIX))
diff --git 
a/wicket-examples/src/main/java/org/apache/wicket/examples/source/SourcesPage.java
 
b/wicket-examples/src/main/java/org/apache/wicket/examples/source/SourcesPage.java
index a42cb012f3..69f754bc3b 100644
--- 
a/wicket-examples/src/main/java/org/apache/wicket/examples/source/SourcesPage.java
+++ 
b/wicket-examples/src/main/java/org/apache/wicket/examples/source/SourcesPage.java
@@ -43,7 +43,6 @@ import 
org.apache.wicket.ajax.attributes.AjaxRequestAttributes;
 import org.apache.wicket.ajax.markup.html.AjaxFallbackLink;
 import org.apache.wicket.authorization.UnauthorizedInstantiationException;
 import org.apache.wicket.core.util.lang.WicketObjects;
-import org.apache.wicket.examples.WicketExamplePage;
 import org.apache.wicket.markup.head.CssHeaderItem;
 import org.apache.wicket.markup.head.IHeaderResponse;
 import org.apache.wicket.markup.html.WebMarkupContainer;
@@ -56,6 +55,7 @@ import org.apache.wicket.model.LoadableDetachableModel;
 import org.apache.wicket.request.http.handler.ErrorCodeRequestHandler;
 import org.apache.wicket.request.mapper.parameter.PageParameters;
 import org.apache.wicket.request.resource.CssResourceReference;
+import org.apache.wicket.util.file.Files;
 import org.apache.wicket.util.io.IOUtils;
 import org.apache.wicket.util.lang.PackageName;
 import org.apache.wicket.util.string.AppendingStringBuffer;
@@ -157,7 +157,7 @@ public class SourcesPage extends WebPage
                private void addResources(final AppendingStringBuffer 
relativePath, final File dir,
                        List<String> resources)
                {
-                       File[] files = dir.listFiles();
+                       File[] files = Files.list(dir);
                        for (File file : files)
                        {
                                if (file.isDirectory())
diff --git 
a/wicket-examples/src/main/java/org/apache/wicket/examples/upload/MultiUploadPage.java
 
b/wicket-examples/src/main/java/org/apache/wicket/examples/upload/MultiUploadPage.java
index b44ae8ef62..68af7581d8 100644
--- 
a/wicket-examples/src/main/java/org/apache/wicket/examples/upload/MultiUploadPage.java
+++ 
b/wicket-examples/src/main/java/org/apache/wicket/examples/upload/MultiUploadPage.java
@@ -190,7 +190,7 @@ public class MultiUploadPage extends WicketExamplePage
                        @Override
                        protected List<File> load()
                        {
-                               return 
Arrays.asList(getUploadFolder().listFiles());
+                               return 
Arrays.asList(Files.list(getUploadFolder()));
                        }
                });
                add(fileListView);
diff --git 
a/wicket-examples/src/main/java/org/apache/wicket/examples/upload/UploadPage.java
 
b/wicket-examples/src/main/java/org/apache/wicket/examples/upload/UploadPage.java
index 6e98748d2c..2637303032 100644
--- 
a/wicket-examples/src/main/java/org/apache/wicket/examples/upload/UploadPage.java
+++ 
b/wicket-examples/src/main/java/org/apache/wicket/examples/upload/UploadPage.java
@@ -20,7 +20,6 @@ import java.io.File;
 import java.util.Arrays;
 import java.util.List;
 
-import org.apache.wicket.Application;
 import org.apache.wicket.examples.WicketExamplePage;
 import 
org.apache.wicket.extensions.ajax.markup.html.form.upload.UploadProgressBar;
 import org.apache.wicket.markup.html.basic.Label;
@@ -178,7 +177,7 @@ public class UploadPage extends WicketExamplePage
                        @Override
                        protected List<File> load()
                        {
-                               return 
Arrays.asList(getUploadFolder().listFiles());
+                               return 
Arrays.asList(Files.list(getUploadFolder()));
                        }
                });
                add(fileListView);

Reply via email to