Minor Close writer properly
authorValentina Kiryushkina <valentina.kiryushkina@jetbrains.com>
Thu, 4 Aug 2016 12:50:06 +0000 (15:50 +0300)
committerValentina Kiryushkina <valentina.kiryushkina@jetbrains.com>
Fri, 5 Aug 2016 08:19:56 +0000 (11:19 +0300)
python/educational-core/student/src/com/jetbrains/edu/learning/courseGeneration/StudyProjectGenerator.java

index 55f5713b7a465b89c2c7cbcd39491e7ced9b3d64..5bfb99861be0c311ae6b95149ff234ef50033adc 100644 (file)
@@ -346,9 +346,14 @@ public class StudyProjectGenerator {
       }
 
       writer = new PrintWriter(cacheFile, "UTF-8");
-      for (CourseInfo courseInfo : courseInfos) {
-        final String json = gson.toJson(courseInfo);
-        writer.println(json);
+      try {
+        for (CourseInfo courseInfo : courseInfos) {
+          final String json = gson.toJson(courseInfo);
+          writer.println(json);
+        }
+      }
+      finally {
+        StudyUtils.closeSilently(writer);
       }
     }
     catch (IOException e) {