Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(758)

Unified Diff: src/com/google/enterprise/adaptor/fs/WindowsFileDelegate.java

Issue 107710043: FSA Fix b/16139028 Part1: Close DirectoryStreams to avoid leaking resources. (Closed)
Patch Set: Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/com/google/enterprise/adaptor/fs/FsAdaptor.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/com/google/enterprise/adaptor/fs/WindowsFileDelegate.java
diff --git a/src/com/google/enterprise/adaptor/fs/WindowsFileDelegate.java b/src/com/google/enterprise/adaptor/fs/WindowsFileDelegate.java
index 19bedfa01c6331c0221bb0d022ffa5cfd19e70c3..7ce01dba3f55784bed8ffba1bd60ac063fcad00f 100644
--- a/src/com/google/enterprise/adaptor/fs/WindowsFileDelegate.java
+++ b/src/com/google/enterprise/adaptor/fs/WindowsFileDelegate.java
@@ -92,19 +92,21 @@ class WindowsFileDelegate extends NioFileDelegate {
@Override
public FileTime getLastAccessTime(Path doc) throws IOException {
+ WinBase.FILETIME.ByReference accessTime =
+ new WinBase.FILETIME.ByReference();
HANDLE handle = kernel32.CreateFile(doc.toString(), WinNT.GENERIC_READ,
WinNT.FILE_SHARE_READ | WinNT.FILE_SHARE_WRITE,
new WinBase.SECURITY_ATTRIBUTES(), WinNT.OPEN_EXISTING,
WinNT.FILE_ATTRIBUTE_NORMAL, null);
- if (Kernel32.INVALID_HANDLE_VALUE.equals(handle)) {
- throw new IOException("Unable to open " + doc
- + ". GetLastError: " + kernel32.GetLastError());
- }
-
- WinBase.FILETIME.ByReference accessTime =
- new WinBase.FILETIME.ByReference();
- kernel32.GetFileTime(handle, null, accessTime, null);
- kernel32.CloseHandle(handle);
+ if (Kernel32.INVALID_HANDLE_VALUE.equals(handle)) {
+ throw new IOException("Unable to open " + doc
+ + ". GetLastError: " + kernel32.GetLastError());
+ }
+ try {
+ kernel32.GetFileTime(handle, null, accessTime, null);
mifern 2014/07/10 15:55:19 This is not needed. The Win API's don't throw exce
+ } finally {
+ kernel32.CloseHandle(handle);
+ }
return FileTime.fromMillis(accessTime.toDate().getTime());
}
« no previous file with comments | « src/com/google/enterprise/adaptor/fs/FsAdaptor.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b