8056205: (fs) Potential for NPE in Files.walkFileTree if closing directory fails
authorbpb
Wed, 21 Dec 2016 11:54:42 -0800
changeset 42925 5ea771a26665
parent 42924 0d68b06248fb
child 42926 8b9cacdadb2d
8056205: (fs) Potential for NPE in Files.walkFileTree if closing directory fails Summary: Change incorrect ioe != null to ioe == null Reviewed-by: rriggs
jdk/src/java.base/share/classes/java/nio/file/FileTreeWalker.java
--- a/jdk/src/java.base/share/classes/java/nio/file/FileTreeWalker.java	Wed Dec 21 18:45:34 2016 +0000
+++ b/jdk/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);