Skip to content

Commit b57b044

Browse files
committed
extract method
1 parent 83638c4 commit b57b044

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

core/src/main/java/net/adoptopenjdk/icedteaweb/resources/downloader/BaseResourceDownloader.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,7 @@ private CompletableFuture<Resource> downloadFrom(final URL url) {
132132
}
133133

134134
private Resource tryDownloading(final URL downloadFrom) throws IOException {
135-
try {
136-
final int httpsRequestInterval = getTimeValue(ConfigurationConstants.KEY_HTTPCONNECTION_REQUEST_INTERVAL);
137-
Thread.sleep(httpsRequestInterval);
138-
} catch (InterruptedException ie) {
139-
}
135+
ensureRequestInterval();
140136
DownloadDetails downloadDetails = null;
141137
try (final CloseableConnection connection = getDownloadConnection(downloadFrom)) {
142138
downloadDetails = getDownloadDetails(connection);
@@ -163,6 +159,16 @@ private Resource tryDownloading(final URL downloadFrom) throws IOException {
163159
}
164160
}
165161

162+
private void ensureRequestInterval() {
163+
final int httpsRequestInterval = getTimeValue(ConfigurationConstants.KEY_HTTPCONNECTION_REQUEST_INTERVAL);
164+
if (httpsRequestInterval > 0) {
165+
try {
166+
Thread.sleep(httpsRequestInterval);
167+
} catch (InterruptedException ignored) {
168+
}
169+
}
170+
}
171+
166172
private CloseableConnection getDownloadConnection(final URL location) throws IOException {
167173
final Map<String, String> requestProperties = new HashMap<>();
168174
requestProperties.put(ACCEPT_ENCODING_HEADER, PACK_200_OR_GZIP);

0 commit comments

Comments
 (0)