Skip to content
This repository was archived by the owner on May 28, 2018. It is now read-only.

Commit 8cf02a9

Browse files
author
Martin Leon
committed
Fixed setRequestMethodViaJreBugWorkaround() to work with HTTPS as well as HTTP
1 parent 307ffda commit 8cf02a9

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

core-client/src/main/java/org/glassfish/jersey/client/HttpUrlConnector.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,18 @@ private static void setRequestMethodViaJreBugWorkaround(final HttpURLConnection
358358
AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
359359
@Override
360360
public Object run() throws NoSuchFieldException, IllegalAccessException {
361-
final Field methodField = httpURLConnectionClass.getSuperclass().getDeclaredField("method");
361+
final Class<?> parentClass = httpURLConnectionClass
362+
.getSuperclass();
363+
final Field methodField;
364+
// If the implementation class is an HTTPS URL Connection, we
365+
// need to go up one level higher in the heirarchy to modify the
366+
// 'method' field.
367+
if (parentClass == HttpsURLConnection.class) {
368+
methodField = parentClass.getSuperclass().getDeclaredField(
369+
"method");
370+
} else {
371+
methodField = parentClass.getDeclaredField("method");
372+
}
362373
methodField.setAccessible(true);
363374
methodField.set(httpURLConnection, method);
364375
return null;

0 commit comments

Comments
 (0)