Bug 429714 - Pre-initialize SSLSocketFactory.getDefault() in Bridge
Servlet init
diff --git a/bundles/org.eclipse.equinox.servletbridge/src/org/eclipse/equinox/servletbridge/BridgeServlet.java b/bundles/org.eclipse.equinox.servletbridge/src/org/eclipse/equinox/servletbridge/BridgeServlet.java
index 43448e2..025ea4a 100644
--- a/bundles/org.eclipse.equinox.servletbridge/src/org/eclipse/equinox/servletbridge/BridgeServlet.java
+++ b/bundles/org.eclipse.equinox.servletbridge/src/org/eclipse/equinox/servletbridge/BridgeServlet.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2013 Cognos Incorporated, IBM Corporation and others.
+ * Copyright (c) 2005, 2014 Cognos Incorporated, IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -12,6 +12,7 @@
package org.eclipse.equinox.servletbridge;
import java.io.IOException;
+import java.lang.reflect.Method;
import java.util.StringTokenizer;
import javax.servlet.ServletException;
import javax.servlet.http.*;
@@ -63,6 +64,19 @@
}
}
+ // Forces load of the SSLSocketFactory on the web-app context class loader
+ String initSSLSocketFactory = getServletConfig().getInitParameter("_initSSLSocketFactory"); //$NON-NLS-1$
+ if (!"false".equals(initSSLSocketFactory)) { //$NON-NLS-1$
+ try {
+ Class clazz = this.getClass().getClassLoader().loadClass("javax.net.ssl.SSLSocketFactory"); //$NON-NLS-1$
+ Method getDefaultMethod = clazz.getMethod("getDefault", null); //$NON-NLS-1$
+ getDefaultMethod.invoke(null, null);
+ } catch (Exception e) {
+ // best effort -- log problems
+ getServletContext().log("Bridge Servlet _initSSLSocketFactory - failed - " + e.getMessage()); //$NON-NLS-1$
+ }
+ }
+
String frameworkLauncherClassParameter = getServletConfig().getInitParameter("frameworkLauncherClass"); //$NON-NLS-1$
if (frameworkLauncherClassParameter != null) {
try {