changeset 16374:66b07872e356

8056205: (fs) Potential for NPE in Files.walkFileTree if closing directory fails Summary: Change incorrect ioe != null to ioe == null Reviewed-by: rriggs
author bpb
date Wed, 21 Dec 2016 11:54:42 -0800
parents bd9dd28d7b4f
children 0e90257ab700
files src/java.base/share/classes/java/nio/file/FileTreeWalker.java
diffstat 1 files changed, 4 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/share/classes/java/nio/file/FileTreeWalker.java	Wed Dec 21 18:45:34 2016 +0000
+++ b/src/java.base/share/classes/java/nio/file/FileTreeWalker.java	Wed Dec 21 11:54:42 2016 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2016, 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
@@ -353,12 +353,13 @@
                 }
             }
 
-            // no next entry so close and pop directory, creating corresponding event
+            // no next entry so close and pop directory,
+            // creating corresponding event
             if (entry == null) {
                 try {
                     top.stream().close();
                 } catch (IOException e) {
-                    if (ioe != null) {
+                    if (ioe == null) {
                         ioe = e;
                     } else {
                         ioe.addSuppressed(e);