Skip to content

Commit d833d1d

Browse files
authored
Merge pull request #943 from AdoptOpenJDK/http_connection_interval
OWS-627: fix SSLHandshake in some cases
2 parents 5d4a707 + b57b044 commit d833d1d

File tree

3 files changed

+33
-5
lines changed

3 files changed

+33
-5
lines changed

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

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

134134
private Resource tryDownloading(final URL downloadFrom) throws IOException {
135+
ensureRequestInterval();
135136
DownloadDetails downloadDetails = null;
136137
try (final CloseableConnection connection = getDownloadConnection(downloadFrom)) {
137138
downloadDetails = getDownloadDetails(connection);
@@ -158,23 +159,33 @@ private Resource tryDownloading(final URL downloadFrom) throws IOException {
158159
}
159160
}
160161

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+
161172
private CloseableConnection getDownloadConnection(final URL location) throws IOException {
162173
final Map<String, String> requestProperties = new HashMap<>();
163174
requestProperties.put(ACCEPT_ENCODING_HEADER, PACK_200_OR_GZIP);
164-
return ConnectionFactory.openConnection(location, HttpMethod.GET, requestProperties, getTimeoutValue(ConfigurationConstants.KEY_HTTPCONNECTION_CONNECT_TIMEOUT), getTimeoutValue(ConfigurationConstants.KEY_HTTPCONNECTION_READ_TIMEOUT));
175+
return ConnectionFactory.openConnection(location, HttpMethod.GET, requestProperties, getTimeValue(ConfigurationConstants.KEY_HTTPCONNECTION_CONNECT_TIMEOUT), getTimeValue(ConfigurationConstants.KEY_HTTPCONNECTION_READ_TIMEOUT));
165176
}
166177

167-
private int getTimeoutValue(final String key) {
168-
int timeout = 0;
178+
private int getTimeValue(final String key) {
179+
int timeValue = 0;
169180
final String value = JNLPRuntime.getConfiguration().getProperty(key);
170181
if (value != null && value.trim().length() != 0) {
171182
try {
172-
timeout = Integer.valueOf(value);
183+
timeValue = Integer.valueOf(value);
173184
} catch (NumberFormatException e) {
174185
LOG.error("Could not parse {} with value '{}' - reason {}", key, value, e.getMessage());
175186
}
176187
}
177-
return timeout;
188+
return timeValue;
178189
}
179190

180191
private long tryDownloading(final DownloadDetails downloadDetails) throws IOException {

core/src/main/java/net/sourceforge/jnlp/config/ConfigurationConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,4 +305,5 @@ public interface ConfigurationConstants {
305305
*/
306306
String KEY_HTTPCONNECTION_CONNECT_TIMEOUT = "deployment.connection.connectTimeout";
307307
String KEY_HTTPCONNECTION_READ_TIMEOUT = "deployment.connection.readTimeout";
308+
String KEY_HTTPCONNECTION_REQUEST_INTERVAL = "deployment.connection.request.interval";
308309
}

core/src/main/java/net/sourceforge/jnlp/runtime/JNLPRuntime.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,22 @@ public static LaunchHandler getDefaultLaunchHandler() {
673673
return handler;
674674
}
675675

676+
/**
677+
* Returns the Security Dialog Message Handler.
678+
* @return SecurityDialogMessageHandler
679+
*/
680+
public static SecurityDialogMessageHandler getSecurityDialogMessageHandler() {
681+
return securityDialogMessageHandler;
682+
}
683+
684+
/**
685+
* Sets the Security Dialog Message Handler.
686+
* @param securityDialogMessageHandler handler for Security Dialog messages
687+
*/
688+
public static void setSecurityDialogMessageHandler(final SecurityDialogMessageHandler securityDialogMessageHandler) {
689+
JNLPRuntime.securityDialogMessageHandler = securityDialogMessageHandler;
690+
}
691+
676692
/**
677693
* Sets the default download indicator.
678694
*

0 commit comments

Comments
 (0)