]> source.dussan.org Git - jgit.git/commitdiff
SubmoduleWalk#forIndex: Suppress resource warning and update Javadoc 13/119313/4
authorDavid Pursehouse <david.pursehouse@gmail.com>
Tue, 13 Mar 2018 11:31:38 +0000 (20:31 +0900)
committerDavid Pursehouse <david.pursehouse@gmail.com>
Wed, 14 Mar 2018 01:44:23 +0000 (10:44 +0900)
SubmoduleWalk is auto-closeable, and Eclipse warns that is is not
managed by try-with-resource. However in this case the resource should
not be closed, because the caller needs to use it. Instead, it is the
responsibility of the caller to close it after use.

Update the Javadoc to clarify this, and suppress the warning.

Change-Id: Ib7ba349353bfd3341bdcbe4bb19abaeb9f3aeba5
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
org.eclipse.jgit/src/org/eclipse/jgit/submodule/SubmoduleWalk.java

index 0fc11f697cd0036c66120b80368e88a90ab44a14..211bbe8e54854cda4755c3501bc3aa37169dcc74 100644 (file)
@@ -115,11 +115,13 @@ public class SubmoduleWalk implements AutoCloseable {
         *
         * @param repository
         *            a {@link org.eclipse.jgit.lib.Repository} object.
-        * @return generator over submodule index entries
+        * @return generator over submodule index entries. The caller is responsible
+        *         for calling {@link #close()}.
         * @throws java.io.IOException
         */
        public static SubmoduleWalk forIndex(Repository repository)
                        throws IOException {
+               @SuppressWarnings("resource") // The caller closes it
                SubmoduleWalk generator = new SubmoduleWalk(repository);
                try {
                        DirCache index = repository.readDirCache();