Cleanup (formatting)
authorRoman Shevchenko <roman.shevchenko@jetbrains.com>
Tue, 23 Dec 2014 18:40:52 +0000 (19:40 +0100)
committerRoman Shevchenko <roman.shevchenko@jetbrains.com>
Tue, 23 Dec 2014 18:40:52 +0000 (19:40 +0100)
platform/platform-api/src/com/intellij/util/io/HttpRequests.java
platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/PluginDownloader.java

index 32108310678df00e59897607102dc62cbb3ff546..710a06751587d9c8703d0346d6dcc9d688eddfaf 100644 (file)
@@ -344,33 +344,28 @@ public abstract class HttpRequests {
 
       @NotNull
       public File saveToFile(@NotNull File file, @Nullable ProgressIndicator indicator) throws IOException {
-        OutputStream out = null;
+        FileUtilRt.createParentDirs(file);
+
         boolean deleteFile = true;
         try {
-          if (indicator != null) {
-            indicator.checkCanceled();
-          }
-
-          FileUtilRt.createParentDirs(file);
-          out = new FileOutputStream(file);
-          NetUtils.copyStreamContent(indicator, getInputStream(), out, getConnection().getContentLength());
-          deleteFile = false;
-        }
-        catch (IOException e) {
-          throw new IOException(createErrorMessage(e, this), e);
-        }
-        finally {
+          OutputStream out = new FileOutputStream(file);
           try {
-            if (out != null) {
-              out.close();
-            }
+            NetUtils.copyStreamContent(indicator, getInputStream(), out, getConnection().getContentLength());
+            deleteFile = false;
+          }
+          catch (IOException e) {
+            throw new IOException(createErrorMessage(e, this), e);
           }
           finally {
-            if (deleteFile) {
-              FileUtilRt.delete(file);
-            }
+            out.close();
+          }
+        }
+        finally {
+          if (deleteFile) {
+            FileUtilRt.delete(file);
           }
         }
+
         return file;
       }
     }
@@ -418,9 +413,11 @@ public abstract class HttpRequests {
       if (builder.myGzip) {
         connection.setRequestProperty("Accept-Encoding", "gzip");
       }
+
       if (builder.myAccept != null) {
         connection.setRequestProperty("Accept", builder.myAccept);
       }
+
       connection.setUseCaches(false);
 
       if (connection instanceof HttpURLConnection) {
index f4925c43d71f13c448a3ea47691355bd4c474bb1..a3181e565117fd12f4c44bd70772fded76fb7cb2 100644 (file)
@@ -255,6 +255,7 @@ public class PluginDownloader {
       @Override
       public File process(@NotNull HttpRequests.Request request) throws IOException {
         request.saveToFile(file, indicator);
+
         if (myFileName == null) {
           myFileName = guessFileName(request.getConnection(), file);
         }