A redirect on a POST request does not work with Java 8. This work without any problems with Java 6 and Java 7. It is a regression.
Full java version:
java version "1.8.0-ea"
Java(TM) SE Runtime Environment (build 1.8.0-ea-b115)
Java HotSpot(TM) Client VM (build 25.0-b57, mixed mode, sharing)
OS: Windows 8
The follow code sequence:
URL url = new URL( job.getUrl() + "build?delay=0sec" );
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
connection.setConnectTimeout( 20000 );
connection.setReadTimeout( 20000 );
connection.setRequestMethod( "POST" );
inputStream = connection.getInputStream();
produce the follow exception:
java.lang.IllegalStateException: connect in progress
at sun.net.www.protocol.http.HttpURLConnection.setRequestMethod(HttpURLConnection.java:515)
at sun.net.www.protocol.http.HttpURLConnection.followRedirect0(HttpURLConnection.java:2597)
at sun.net.www.protocol.http.HttpURLConnection.followRedirect(HttpURLConnection.java:2529)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1723)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1394)
at com.inet.tests.monitor.gui.GuiController.executeJob(GuiController.java:181)
The wireshark show the follow on the network:
POST /job/DTRAPIDocInternal/build?delay=0sec HTTP/1.1
User-Agent: Java/1.8.0-ea
Host: hudson
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Connection: keep-alive
HTTP/1.1 302 Found
Server: Winstone Servlet Engine v0.9.10
Location: http://hudson/job/DTRAPIDocInternal/
Content-Length: 0
Connection: Keep-Alive
Date: Mon, 25 Nov 2013 13:21:27 GMT
X-Powered-By: Servlet/2.5 (Winstone/0.9.10)