/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 6299712
* @library ../../httptest/
* @build HttpCallback HttpServer ClosedChannelList HttpTransaction
* @summary NullPointerException in sun.net.www.protocol.http.HttpURLConnection.followRedirect
*/
/*
* Test Description:
* - main thread run as a http client
* - another thread runs a http server, which redirect the first call to "/redirect"
* and return '200 OK' for the successive call
* - a global ResponseCache instance is installed, which return DeployCacheResponse
* for url ends with "/redirect", i.e. the url redirected to by our simple http server,
* and null for other url.
* - the whole result is that the first call will be served by our simple
* http server and is redirected to "/redirect". The successive call will be done
* automatically by HttpURLConnection, which will be served by DeployCacheResponse.
* The NPE will be thrown on the second round if the bug is there.
*/
public class B6299712 {
makeHttpCall();
}
public static void startHttpServer() {
try {
httpTrans = new SimpleHttpTransaction();
} catch (IOException e) {
e.printStackTrace();
}
}
public static void makeHttpCall() {
try {
} catch (IOException e) {
e.printStackTrace();
} finally {
}
}
}
/*
* Our http server which simply redirect first call
*/
try {
// the first call, redirect it
} else {
// the second call
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
private boolean inCacheHandler = false;
private boolean _downloading = false;
try {
return null;
}
} catch (Exception e) {
e.printStackTrace();
}
}
throws IOException {
}
}
private boolean _downloading = false;
}
public void abort() {
}
return null;
}
}
}
return is;
}
return headers;
}
}
public EmptyInputStream() {
}
public int read()
throws IOException {
return -1;
}
}