mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 14:24:46 +02:00
8349383: (fs) FileTreeWalker.next() superfluous null check of visit() return value
Reviewed-by: djelinski
This commit is contained in:
parent
379c3f9966
commit
b499c827a5
1 changed files with 31 additions and 37 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2007, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -319,46 +319,40 @@ class FileTreeWalker implements Closeable {
|
||||||
return null; // stack is empty, we are done
|
return null; // stack is empty, we are done
|
||||||
|
|
||||||
// continue iteration of the directory at the top of the stack
|
// continue iteration of the directory at the top of the stack
|
||||||
Event ev;
|
Path entry = null;
|
||||||
do {
|
IOException ioe = null;
|
||||||
Path entry = null;
|
|
||||||
IOException ioe = null;
|
|
||||||
|
|
||||||
// get next entry in the directory
|
// get next entry in the directory
|
||||||
if (!top.skipped()) {
|
if (!top.skipped()) {
|
||||||
Iterator<Path> iterator = top.iterator();
|
Iterator<Path> iterator = top.iterator();
|
||||||
try {
|
try {
|
||||||
if (iterator.hasNext()) {
|
if (iterator.hasNext()) {
|
||||||
entry = iterator.next();
|
entry = iterator.next();
|
||||||
}
|
}
|
||||||
} catch (DirectoryIteratorException x) {
|
} catch (DirectoryIteratorException x) {
|
||||||
ioe = x.getCause();
|
ioe = x.getCause();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// no next entry so close and pop directory,
|
||||||
|
// creating corresponding event
|
||||||
|
if (entry == null) {
|
||||||
|
try {
|
||||||
|
top.stream().close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
if (ioe == null) {
|
||||||
|
ioe = e;
|
||||||
|
} else {
|
||||||
|
ioe.addSuppressed(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
stack.pop();
|
||||||
|
return new Event(EventType.END_DIRECTORY, top.directory(), ioe);
|
||||||
|
}
|
||||||
|
|
||||||
// no next entry so close and pop directory,
|
// visit the entry
|
||||||
// creating corresponding event
|
return visit(entry,
|
||||||
if (entry == null) {
|
true); // canUseCached
|
||||||
try {
|
|
||||||
top.stream().close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
if (ioe == null) {
|
|
||||||
ioe = e;
|
|
||||||
} else {
|
|
||||||
ioe.addSuppressed(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stack.pop();
|
|
||||||
return new Event(EventType.END_DIRECTORY, top.directory(), ioe);
|
|
||||||
}
|
|
||||||
|
|
||||||
// visit the entry
|
|
||||||
ev = visit(entry,
|
|
||||||
true); // canUseCached
|
|
||||||
|
|
||||||
} while (ev == null);
|
|
||||||
|
|
||||||
return ev;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue