Skip to content

Commit

Permalink
0003971: fix possible null dereference issues (#99)
Browse files Browse the repository at this point in the history
(cherry picked from commit 7a4a6b5)
  • Loading branch information
davecramer authored and jaredfrees committed May 17, 2019
1 parent 68d5dfa commit c9920da
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
Expand Up @@ -341,10 +341,12 @@ public File[] findEnginePropertiesFiles() {
List<File> propFiles = new ArrayList<File>();
File enginesDir = new File(getEnginesDir());
File[] files = enginesDir.listFiles();
for (int i = 0; i < files.length; i++) {
File file = files[i];
if (file.getName().endsWith(".properties")) {
propFiles.add(file);
if (files !=null ) {
for (int i = 0; i < files.length; i++) {
File file = files[i];
if (file.getName().endsWith(".properties")) {
propFiles.add(file);
}
}
}
return propFiles.toArray(new File[propFiles.size()]);
Expand Down
Expand Up @@ -119,8 +119,17 @@ protected void clean(Path path, long ttlInMs, StagingPurgeContext context) throw
clean(entry, ttlInMs, context);
} else {
try {
String parentDirectory ="";
if (entry.getParent() != null){
parentDirectory=entry.getParent().toString();
}
String entryName="";
if ( entry.getFileName() != null){
entryName = entry.getFileName().toString();
}
String stagingPath = StagedResource.toPath(directory,
new File((entry.getParent().toString() + "/" + entry.getFileName().toString())));
new File((parentDirectory + "/" + entryName)));

IStagedResource resource = createStagedResource(stagingPath);
if (stagingPath != null) {
if (shouldCleanPath(resource, ttlInMs, context)) {
Expand Down Expand Up @@ -288,10 +297,14 @@ public StagingFileLock acquireFileLock(String serverInfo, Object... path) {
protected static final DirectoryStream.Filter<Path> STAGING_FILE_FILTER = new DirectoryStream.Filter<Path>() {
@Override
public boolean accept(Path entry) {
boolean accept = Files.isDirectory(entry) ||
entry.getFileName().toString().endsWith(".create")
try {
boolean accept = Files.isDirectory(entry) ||
entry.getFileName().toString().endsWith(".create")
|| entry.getFileName().toString().endsWith(".done");
return accept;
return accept;
} catch (NullPointerException ex ){
return false;
}
}
};

Expand Down

0 comments on commit c9920da

Please sign in to comment.