ensure the streams are closed
authorpeter <peter@jetbrains.com>
Tue, 24 Jan 2012 17:31:50 +0000 (18:31 +0100)
committerpeter <peter@jetbrains.com>
Tue, 24 Jan 2012 18:08:03 +0000 (19:08 +0100)
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/LastUnchangedContentTracker.java

index 00294bcdaa6d3b796ffe5224b1ff8cdd16c3c46c..a672b25313fd0375f9a7ed12f3e0b9a294676796 100644 (file)
@@ -84,12 +84,20 @@ public class LastUnchangedContentTracker {
     long stamp = file.getModificationStamp();
     try {
       final DataOutputStream contentStream = ACQUIRED_CONTENT_ATTR.writeAttribute(file);
-      contentStream.writeInt(contentId);
-      contentStream.close();
+      try {
+        contentStream.writeInt(contentId);
+      }
+      finally {
+        contentStream.close();
+      }
 
       final DataOutputStream tsStream = LAST_TS_ATTR.writeAttribute(file);
-      tsStream.writeLong(stamp);
-      tsStream.close();
+      try {
+        tsStream.writeLong(stamp);
+      }
+      finally {
+        tsStream.close();
+      }
 
       file.putUserData(LAST_TS_KEY, stamp);
     }
@@ -112,8 +120,12 @@ public class LastUnchangedContentTracker {
     try {
       final DataInputStream stream = ACQUIRED_CONTENT_ATTR.readAttribute(file);
       if (stream != null) {
-        oldContentId = stream.readInt();
-        stream.close();
+        try {
+          oldContentId = stream.readInt();
+        }
+        finally {
+          stream.close();
+        }
         LOG.assertTrue(oldContentId > 0, oldContentId);
       }
     }
@@ -130,8 +142,12 @@ public class LastUnchangedContentTracker {
       try {
         final DataInputStream stream = LAST_TS_ATTR.readAttribute(file);
         if (stream != null) {
-          l = stream.readLong();
-          stream.close();
+          try {
+            l = stream.readLong();
+          }
+          finally {
+            stream.close();
+          }
         }
       }
       catch (IOException e) {