From f2a4ea5e15e28d14a99c4de4ce2e49a55b1a6592 Mon Sep 17 00:00:00 2001 From: Mattia Bertorello Date: Wed, 3 Jul 2019 18:06:16 +0200 Subject: [PATCH] Code reformat --- .../arduino/utils/network/CacheControl.java | 22 +++++++++++-------- .../utils/network/FileDownloaderCache.java | 16 +++++++------- .../utils/network/HttpConnectionManager.java | 7 +++--- 3 files changed, 25 insertions(+), 20 deletions(-) diff --git a/arduino-core/src/cc/arduino/utils/network/CacheControl.java b/arduino-core/src/cc/arduino/utils/network/CacheControl.java index 4dc679a27..bbaae71b0 100644 --- a/arduino-core/src/cc/arduino/utils/network/CacheControl.java +++ b/arduino-core/src/cc/arduino/utils/network/CacheControl.java @@ -26,15 +26,19 @@ public class CacheControl { Matcher matcher = PATTERN.matcher(value); while (matcher.find()) { switch (matcher.group(1).toLowerCase()) { - case "max-age": - cc.setMaxAge(Integer.parseInt(matcher.group(3))); break; - case "must-revalidate": - cc.setMustRevalidate(true); break; - case "no-cache": - cc.setNoCache(true); break; - case "no-store": - cc.setNoStore(true); break; - default: //ignore + case "max-age": + cc.setMaxAge(Integer.parseInt(matcher.group(3))); + break; + case "must-revalidate": + cc.setMustRevalidate(true); + break; + case "no-cache": + cc.setNoCache(true); + break; + case "no-store": + cc.setNoStore(true); + break; + default: //ignore } } } diff --git a/arduino-core/src/cc/arduino/utils/network/FileDownloaderCache.java b/arduino-core/src/cc/arduino/utils/network/FileDownloaderCache.java index 60ce4ad93..00e931aeb 100644 --- a/arduino-core/src/cc/arduino/utils/network/FileDownloaderCache.java +++ b/arduino-core/src/cc/arduino/utils/network/FileDownloaderCache.java @@ -93,16 +93,16 @@ public class FileDownloaderCache { if (fileCachedOpt.isChange() || !enableCache) { // Update remote etag and cache control header return FileDownloaderCache.updateCacheInfo(remoteURL, (remoteETagClean, cacheControl) -> { - // Check cache control data - if (cacheControl.isNoCache() || cacheControl.isMustRevalidate() || cacheControl.isNoStore()) { - log.warn("The file {} must not be cache due to cache control header {}", - remoteURL, cacheControl); - return Optional.empty(); - } + // Check cache control data + if (cacheControl.isNoCache() || cacheControl.isMustRevalidate() || cacheControl.isNoStore()) { + log.warn("The file {} must not be cache due to cache control header {}", + remoteURL, cacheControl); + return Optional.empty(); + } fileCachedOpt.setLastETag(remoteETagClean); fileCachedOpt.setCacheControl(cacheControl); - return Optional.of(fileCachedOpt); - }); + return Optional.of(fileCachedOpt); + }); } return Optional.of(fileCachedOpt); } diff --git a/arduino-core/src/cc/arduino/utils/network/HttpConnectionManager.java b/arduino-core/src/cc/arduino/utils/network/HttpConnectionManager.java index 850580e15..ed2e79c79 100644 --- a/arduino-core/src/cc/arduino/utils/network/HttpConnectionManager.java +++ b/arduino-core/src/cc/arduino/utils/network/HttpConnectionManager.java @@ -67,7 +67,8 @@ public class HttpConnectionManager { public HttpURLConnection makeConnection() throws IOException, NoSuchMethodException, ScriptException, URISyntaxException { - return makeConnection(this.requestURL, 0, (c) -> {}); + return makeConnection(this.requestURL, 0, (c) -> { + }); } private HttpURLConnection makeConnection(URL requestURL, int movedTimes, @@ -102,7 +103,7 @@ public class HttpConnectionManager { beforeConnection.accept(connection); // Connect - log.info("Connect to {}, method={}, request id={}", requestURL, connection.getRequestMethod(),requestId); + log.info("Connect to {}, method={}, request id={}", requestURL, connection.getRequestMethod(), requestId); connection.connect(); int resp = connection.getResponseCode(); @@ -110,7 +111,7 @@ public class HttpConnectionManager { requestURL, connection.getRequestMethod(), resp, requestId, StringUtils.join(connection.getHeaderFields())); if (resp == HttpURLConnection.HTTP_MOVED_PERM - || resp == HttpURLConnection.HTTP_MOVED_TEMP) { + || resp == HttpURLConnection.HTTP_MOVED_TEMP) { URL newUrl = new URL(connection.getHeaderField("Location")); log.info("The response code was a 301,302 so try again with the new URL " + newUrl);