You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by mg...@apache.org on 2015/06/20 16:07:44 UTC
[2/9] wicket git commit: FindBugs: Check for non-null result from
file related operations before using the result
FindBugs: Check for non-null result from file related operations before using the result
Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/13ae30a4
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/13ae30a4
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/13ae30a4
Branch: refs/heads/master
Commit: 13ae30a42b4ac77436333105877fef93c8bd0a28
Parents: 869ea87
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Sat Jun 20 16:07:51 2015 +0300
Committer: Martin Tzvetanov Grigorov <mg...@apache.org>
Committed: Sat Jun 20 16:07:51 2015 +0300
----------------------------------------------------------------------
.../apache/wicket/pageStore/DiskDataStore.java | 4 +--
.../protocol/http/mock/MockServletContext.java | 30 ++++++++++++--------
2 files changed, 20 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/wicket/blob/13ae30a4/wicket-core/src/main/java/org/apache/wicket/pageStore/DiskDataStore.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/pageStore/DiskDataStore.java b/wicket-core/src/main/java/org/apache/wicket/pageStore/DiskDataStore.java
index 887fc09..83be97d 100644
--- a/wicket-core/src/main/java/org/apache/wicket/pageStore/DiskDataStore.java
+++ b/wicket-core/src/main/java/org/apache/wicket/pageStore/DiskDataStore.java
@@ -486,12 +486,12 @@ public class DiskDataStore implements IDataStore
private void cleanup(final File sessionFolder)
{
File high = sessionFolder.getParentFile();
- if (high.list().length == 0)
+ if (high != null && high.list().length == 0)
{
if (Files.removeFolder(high))
{
File low = high.getParentFile();
- if (low.list().length == 0)
+ if (low != null && low.list().length == 0)
{
Files.removeFolder(low);
}
http://git-wip-us.apache.org/repos/asf/wicket/blob/13ae30a4/wicket-core/src/main/java/org/apache/wicket/protocol/http/mock/MockServletContext.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/protocol/http/mock/MockServletContext.java b/wicket-core/src/main/java/org/apache/wicket/protocol/http/mock/MockServletContext.java
index c3982cb..c9304e9 100755
--- a/wicket-core/src/main/java/org/apache/wicket/protocol/http/mock/MockServletContext.java
+++ b/wicket-core/src/main/java/org/apache/wicket/protocol/http/mock/MockServletContext.java
@@ -475,13 +475,16 @@ public class MockServletContext implements ServletContext
{
File[] files = current.listFiles();
boolean match = false;
- for (File file : files)
+ if (files != null)
{
- if (file.getName().equals(element) && file.isDirectory())
+ for (File file : files)
{
- current = file;
- match = true;
- break;
+ if (file.getName().equals(element) && file.isDirectory())
+ {
+ current = file;
+ match = true;
+ break;
+ }
}
}
if (!match)
@@ -491,16 +494,19 @@ public class MockServletContext implements ServletContext
}
File[] files = current.listFiles();
- Set<String> result = new HashSet<String>();
- int stripLength = webappRoot.getPath().length();
- for (File file : files)
+ Set<String> result = new HashSet<>();
+ if (files != null)
{
- String s = file.getPath().substring(stripLength).replace('\\', '/');
- if (file.isDirectory())
+ int stripLength = webappRoot.getPath().length();
+ for (File file : files)
{
- s = s + "/";
+ String s = file.getPath().substring(stripLength).replace('\\', '/');
+ if (file.isDirectory())
+ {
+ s = s + "/";
+ }
+ result.add(s);
}
- result.add(s);
}
return result;
}