kdebski85 commented on a change in pull request #589:
URL: https://github.com/apache/maven/pull/589#discussion_r817617088



##########
File path: 
maven-compat/src/main/java/org/apache/maven/repository/legacy/DefaultUpdateCheckManager.java
##########
@@ -350,60 +350,29 @@ private Properties read( File touchfile )
 
         synchronized ( touchfile.getAbsolutePath().intern() )
         {
-            FileInputStream in = null;
-            FileLock lock = null;
-
             try
             {
                 Properties props = new Properties();
 
-                in = new FileInputStream( touchfile );
-                lock = in.getChannel().lock( 0, Long.MAX_VALUE, true );
-
-                getLogger().debug( "Reading resolution-state from: " + 
touchfile );
-                props.load( in );
-
-                lock.release();
-                lock = null;
+                try ( FileInputStream in = new FileInputStream( touchfile ) )
+                {
+                    try ( FileLock lock = in.getChannel().lock( 0, 
Long.MAX_VALUE, true ) )
+                    {
+                        getLogger().debug( "Reading resolution-state from: " + 
touchfile );
+                        props.load( in );
 
-                in.close();
-                in = null;
+                        lock.release();

Review comment:
       `lock.release();` is not needed because `FileLock::close` calls 
`FileLock::release`.
   `FileLock::close` will be called automatically when `try-with-resource` 
block ends.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to