/**
  * Workaround for a bug in <code>HttpURLConnection.setRequestMethod(String)</code> The
  * implementation of Sun Microsystems is throwing a <code>ProtocolException</code> when the method
  * is other than the HTTP/1.1 default methods. So to use PROPFIND and others, we must apply this
  * workaround.
  *
  * <p>See issue http://java.net/jira/browse/JERSEY-639
  */
 private static final void setRequestMethodUsingWorkaroundForJREBug(
     final HttpURLConnection httpURLConnection, final String method) {
   try {
     httpURLConnection.setRequestMethod(method); // Check whether we are running on a buggy JRE
   } catch (final ProtocolException pe) {
     try {
       final Class<?> httpURLConnectionClass = httpURLConnection.getClass();
       final Field methodField = httpURLConnectionClass.getSuperclass().getDeclaredField("method");
       methodField.setAccessible(true);
       methodField.set(httpURLConnection, method);
     } catch (final Exception e) {
       throw new RuntimeException(e);
     }
   }
 }