CookieManager stores cookies in the CookieStore after visiting urls, but it does not seem to retrieve cookies from the cookiestore when creating http requests.
It this a bug ?

To test cookies, I made a simple php page that displays and sets cookies:

The Java HTTP client code that I use to test CookieManager:
Java Code:
import java.util.*;
// Retrieves a webpage two times, print it, and print cookies
public class Fetch {
	public static void main(String args[]) throws Exception {
		// Setup the cookiemanager
		CookieManager manager = new CookieManager();
		// Visit the url for the first time
		// (so that cookies will be added to the CookieStore afterward)
		System.out.println("--- First visit ---");
		// Visit the url for second time
		// (So that cookies *SHOULD* be retrieved from the CookieStore
		// when creating the HTTP request.)
		System.out.println("--- Second visit ---");
		// Print the stored cookies
		System.out.println("--- Printing stored cookies ---");
		CookieStore cookieJar = manager.getCookieStore();
		List<HttpCookie> cookies = cookieJar.getCookies();
		for (HttpCookie cookie : cookies) {
			System.out.println("Cookie: " + cookie);
	// Visits a webpage, and prints it
	public static void visitPage() throws Exception {
		String urlString = "";
		// retrieve page
		URL url = new URL(urlString);
		URLConnection connection = url.openConnection();
		Object obj = connection.getContent();
		// Print webpage
		BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
		String line;
		while ((line = reader.readLine()) != null) {
Executing this code, shows that the webpage returns cookies, but that cookies aren't retrieved from the CookieStore of CookieManager when making a second HTTP request.....

Does anybody know what is going wrong?