Skip to content

Commit

Permalink
7903538: NullPointerException: Cannot read the array length because "…
Browse files Browse the repository at this point in the history
…<local9>" is null

Reviewed-by: cstein, jjg
  • Loading branch information
jaikiran authored and sormuras committed Mar 20, 2024
1 parent c463d9d commit c1ef500
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -208,11 +208,11 @@ private boolean deleteFiles(File dir, Pattern p, boolean match, boolean deleteDi

boolean ok = true;
File[] children = dir.listFiles();
if (children == null) { // should always be not null, but sometimes it is
if (children == null) { // should always be not null, but may be null if an error occurs
log.println("warning: cannot list contents of directory " + dir);
ok = false;
} else {
for (File file: dir.listFiles()) {
for (File file: children) {
if (isDirectory(file)) {
ok &= deleteFiles(file, p, match, true, badFiles, log);
} else {
Expand Down

0 comments on commit c1ef500

Please sign in to comment.