Skip to content

Commit 83638c4

Browse files
committed
OWS-627: fix SSLHandshake in some cases
1 parent 5d4a707 commit 83638c4

File tree

3 files changed

+27
-5
lines changed

3 files changed

+27
-5
lines changed

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,11 @@ 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+
}
135140
DownloadDetails downloadDetails = null;
136141
try (final CloseableConnection connection = getDownloadConnection(downloadFrom)) {
137142
downloadDetails = getDownloadDetails(connection);
@@ -161,20 +166,20 @@ private Resource tryDownloading(final URL downloadFrom) throws IOException {
161166
private CloseableConnection getDownloadConnection(final URL location) throws IOException {
162167
final Map<String, String> requestProperties = new HashMap<>();
163168
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));
169+
return ConnectionFactory.openConnection(location, HttpMethod.GET, requestProperties, getTimeValue(ConfigurationConstants.KEY_HTTPCONNECTION_CONNECT_TIMEOUT), getTimeValue(ConfigurationConstants.KEY_HTTPCONNECTION_READ_TIMEOUT));
165170
}
166171

167-
private int getTimeoutValue(final String key) {
168-
int timeout = 0;
172+
private int getTimeValue(final String key) {
173+
int timeValue = 0;
169174
final String value = JNLPRuntime.getConfiguration().getProperty(key);
170175
if (value != null && value.trim().length() != 0) {
171176
try {
172-
timeout = Integer.valueOf(value);
177+
timeValue = Integer.valueOf(value);
173178
} catch (NumberFormatException e) {
174179
LOG.error("Could not parse {} with value '{}' - reason {}", key, value, e.getMessage());
175180
}
176181
}
177-
return timeout;
182+
return timeValue;
178183
}
179184

180185
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)