test/jdk/java/net/httpclient/AuthFilterCacheTest.java
author jboes
Fri, 08 Nov 2019 11:15:16 +0000
changeset 59029 3786a0962570
permissions -rw-r--r--
8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException Summary: Change implementation to use iterator instead of plain LinkedList Reviewed-by: dfuchs, vtewari
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
59029
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
     1
/*
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
     2
 * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
     4
 *
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
     7
 * published by the Free Software Foundation.
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
     8
 *
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    13
 * accompanied this code).
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    14
 *
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    18
 *
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    21
 * questions.
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    22
 */
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    23
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    24
import java.io.IOException;
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    25
import java.net.*;
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    26
import java.net.http.HttpClient;
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    27
import java.net.http.HttpRequest;
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    28
import java.net.http.HttpResponse;
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    29
import java.nio.charset.StandardCharsets;
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    30
import java.util.ArrayList;
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    31
import java.util.List;
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    32
import java.util.concurrent.*;
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    33
import java.util.concurrent.atomic.AtomicLong;
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    34
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    35
import com.sun.net.httpserver.HttpServer;
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    36
import com.sun.net.httpserver.HttpsConfigurator;
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    37
import com.sun.net.httpserver.HttpsServer;
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    38
import org.testng.annotations.AfterClass;
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    39
import org.testng.annotations.BeforeClass;
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    40
import org.testng.annotations.DataProvider;
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    41
import org.testng.annotations.Test;
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    42
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    43
import javax.net.ssl.SSLContext;
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    44
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    45
/**
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    46
 * @test
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    47
 * @bug 8232853
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    48
 * @summary AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    49
 * @library /test/lib http2/server
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    50
 * @build jdk.test.lib.net.SimpleSSLContext HttpServerAdapters DigestEchoServer HttpRedirectTest
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    51
 * @modules java.net.http/jdk.internal.net.http.common
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    52
 * java.net.http/jdk.internal.net.http.frame
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    53
 * java.net.http/jdk.internal.net.http.hpack
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    54
 * java.logging
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    55
 * java.base/sun.net.www.http
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    56
 * java.base/sun.net.www
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    57
 * java.base/sun.net
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    58
 * @run testng/othervm -Dtest.requiresHost=true
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    59
 * -Djdk.httpclient.HttpClient.log=headers
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    60
 * -Djdk.internal.httpclient.debug=false
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    61
 * AuthFilterCacheTest
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    62
 */
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    63
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    64
public class AuthFilterCacheTest implements HttpServerAdapters {
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    65
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    66
    static final String RESPONSE_BODY = "Hello World!";
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    67
    static final int REQUEST_COUNT = 5;
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    68
    static final int URI_COUNT = 6;
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    69
    static final CyclicBarrier barrier = new CyclicBarrier(REQUEST_COUNT * URI_COUNT);
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    70
    static final SSLContext context;
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    71
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    72
    static {
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    73
        try {
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    74
            context = new jdk.test.lib.net.SimpleSSLContext().get();
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    75
            SSLContext.setDefault(context);
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    76
        } catch (Exception x) {
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    77
            throw new ExceptionInInitializerError(x);
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    78
        }
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    79
    }
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    80
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    81
    HttpTestServer http1Server;
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    82
    HttpTestServer http2Server;
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    83
    HttpTestServer https1Server;
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    84
    HttpTestServer https2Server;
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    85
    DigestEchoServer.TunnelingProxy proxy;
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    86
    URI http1URI;
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    87
    URI https1URI;
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    88
    URI http2URI;
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    89
    URI https2URI;
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    90
    InetSocketAddress proxyAddress;
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    91
    ProxySelector proxySelector;
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    92
    MyAuthenticator auth;
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    93
    HttpClient client;
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    94
    Executor executor = Executors.newCachedThreadPool();
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    95
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    96
    @DataProvider(name = "uris")
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    97
    Object[][] testURIs() {
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    98
        Object[][] uris = new Object[][]{
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
    99
                {List.of(http1URI.resolve("direct/orig/"),
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   100
                        https1URI.resolve("direct/orig/"),
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   101
                        https1URI.resolve("proxy/orig/"),
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   102
                        http2URI.resolve("direct/orig/"),
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   103
                        https2URI.resolve("direct/orig/"),
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   104
                        https2URI.resolve("proxy/orig/"))}
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   105
        };
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   106
        return uris;
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   107
    }
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   108
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   109
    public HttpClient newHttpClient(ProxySelector ps, Authenticator auth) {
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   110
        HttpClient.Builder builder = HttpClient
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   111
                .newBuilder()
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   112
                .sslContext(context)
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   113
                .authenticator(auth)
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   114
                .proxy(ps);
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   115
        return builder.build();
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   116
    }
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   117
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   118
    @BeforeClass
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   119
    public void setUp() throws Exception {
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   120
        try {
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   121
            InetSocketAddress sa =
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   122
                    new InetSocketAddress(InetAddress.getLoopbackAddress(), 0);
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   123
            auth = new MyAuthenticator();
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   124
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   125
            // HTTP/1.1
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   126
            HttpServer server1 = HttpServer.create(sa, 0);
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   127
            server1.setExecutor(executor);
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   128
            http1Server = HttpTestServer.of(server1);
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   129
            http1Server.addHandler(new TestHandler(), "/AuthFilterCacheTest/http1/");
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   130
            http1Server.start();
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   131
            http1URI = new URI("http://" + http1Server.serverAuthority()
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   132
                    + "/AuthFilterCacheTest/http1/");
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   133
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   134
            // HTTPS/1.1
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   135
            HttpsServer sserver1 = HttpsServer.create(sa, 100);
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   136
            sserver1.setExecutor(executor);
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   137
            sserver1.setHttpsConfigurator(new HttpsConfigurator(context));
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   138
            https1Server = HttpTestServer.of(sserver1);
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   139
            https1Server.addHandler(new TestHandler(), "/AuthFilterCacheTest/https1/");
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   140
            https1Server.start();
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   141
            https1URI = new URI("https://" + https1Server.serverAuthority()
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   142
                    + "/AuthFilterCacheTest/https1/");
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   143
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   144
            // HTTP/2.0
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   145
            http2Server = HttpTestServer.of(
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   146
                    new Http2TestServer("localhost", false, 0));
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   147
            http2Server.addHandler(new TestHandler(), "/AuthFilterCacheTest/http2/");
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   148
            http2Server.start();
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   149
            http2URI = new URI("http://" + http2Server.serverAuthority()
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   150
                    + "/AuthFilterCacheTest/http2/");
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   151
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   152
            // HTTPS/2.0
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   153
            https2Server = HttpTestServer.of(
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   154
                    new Http2TestServer("localhost", true, 0));
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   155
            https2Server.addHandler(new TestHandler(), "/AuthFilterCacheTest/https2/");
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   156
            https2Server.start();
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   157
            https2URI = new URI("https://" + https2Server.serverAuthority()
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   158
                    + "/AuthFilterCacheTest/https2/");
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   159
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   160
            proxy = DigestEchoServer.createHttpsProxyTunnel(
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   161
                    DigestEchoServer.HttpAuthSchemeType.NONE);
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   162
            proxyAddress = proxy.getProxyAddress();
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   163
            proxySelector = new HttpProxySelector(proxyAddress);
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   164
            client = newHttpClient(proxySelector, auth);
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   165
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   166
            System.out.println("Setup: done");
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   167
        } catch (Exception x) {
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   168
            tearDown();
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   169
            throw x;
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   170
        } catch (Error e) {
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   171
            tearDown();
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   172
            throw e;
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   173
        }
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   174
    }
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   175
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   176
    @AfterClass
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   177
    public void tearDown() {
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   178
        proxy = stop(proxy, DigestEchoServer.TunnelingProxy::stop);
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   179
        http1Server = stop(http1Server, HttpTestServer::stop);
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   180
        https1Server = stop(https1Server, HttpTestServer::stop);
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   181
        http2Server = stop(http2Server, HttpTestServer::stop);
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   182
        https2Server = stop(https2Server, HttpTestServer::stop);
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   183
        client = null;
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   184
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   185
        System.out.println("Teardown: done");
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   186
    }
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   187
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   188
    private interface Stoppable<T> {
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   189
        void stop(T service) throws Exception;
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   190
    }
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   191
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   192
    static <T> T stop(T service, Stoppable<T> stop) {
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   193
        try {
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   194
            if (service != null) stop.stop(service);
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   195
        } catch (Throwable x) {
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   196
        }
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   197
        return null;
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   198
    }
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   199
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   200
    static class HttpProxySelector extends ProxySelector {
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   201
        private static final List<Proxy> NO_PROXY = List.of(Proxy.NO_PROXY);
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   202
        private final List<Proxy> proxyList;
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   203
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   204
        HttpProxySelector(InetSocketAddress proxyAddress) {
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   205
            proxyList = List.of(new Proxy(Proxy.Type.HTTP, proxyAddress));
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   206
        }
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   207
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   208
        @Override
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   209
        public List<Proxy> select(URI uri) {
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   210
            // Our proxy only supports tunneling
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   211
            if (uri.getScheme().equalsIgnoreCase("https")) {
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   212
                if (uri.getPath().contains("/proxy/")) {
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   213
                    return proxyList;
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   214
                }
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   215
            }
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   216
            return NO_PROXY;
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   217
        }
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   218
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   219
        @Override
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   220
        public void connectFailed(URI uri, SocketAddress sa, IOException ioe) {
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   221
            System.err.println("Connection to proxy failed: " + ioe);
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   222
            System.err.println("Proxy: " + sa);
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   223
            System.err.println("\tURI: " + uri);
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   224
            ioe.printStackTrace();
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   225
        }
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   226
    }
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   227
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   228
    public static class TestHandler implements HttpTestHandler {
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   229
        static final AtomicLong respCounter = new AtomicLong();
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   230
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   231
        @Override
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   232
        public void handle(HttpTestExchange t) throws IOException {
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   233
            var count = respCounter.incrementAndGet();
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   234
            System.out.println("Responses handled: " + count);
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   235
            t.getRequestBody().readAllBytes();
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   236
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   237
            if (t.getRequestMethod().equalsIgnoreCase("GET")) {
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   238
                if (!t.getRequestHeaders().containsKey("Authorization")) {
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   239
                    t.getResponseHeaders()
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   240
                            .addHeader("WWW-Authenticate", "Basic realm=\"Earth\"");
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   241
                    t.sendResponseHeaders(401, 0);
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   242
                } else {
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   243
                    byte[] resp = RESPONSE_BODY.getBytes(StandardCharsets.UTF_8);
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   244
                    t.sendResponseHeaders(200, resp.length);
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   245
                    try {
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   246
                        barrier.await();
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   247
                    } catch (Exception e) {
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   248
                        throw new IOException(e);
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   249
                    }
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   250
                    t.getResponseBody().write(resp);
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   251
                }
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   252
            }
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   253
            t.close();
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   254
        }
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   255
    }
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   256
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   257
    void doClient(List<URI> uris) {
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   258
        assert uris.size() == URI_COUNT;
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   259
        barrier.reset();
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   260
        System.out.println("Client opening connection to: " + uris.toString());
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   261
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   262
        List<CompletableFuture<HttpResponse<String>>> cfs = new ArrayList<>();
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   263
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   264
        for (int i = 0; i < REQUEST_COUNT; i++) {
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   265
            for (URI uri : uris) {
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   266
                HttpRequest req = HttpRequest.newBuilder()
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   267
                        .uri(uri)
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   268
                        .build();
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   269
                cfs.add(client.sendAsync(req, HttpResponse.BodyHandlers.ofString()));
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   270
            }
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   271
        }
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   272
        CompletableFuture.allOf(cfs.toArray(new CompletableFuture[0])).join();
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   273
    }
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   274
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   275
    static class MyAuthenticator extends Authenticator {
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   276
        private int count = 0;
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   277
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   278
        MyAuthenticator() {
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   279
            super();
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   280
        }
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   281
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   282
        public PasswordAuthentication getPasswordAuthentication() {
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   283
            System.out.println("Authenticator called: " + ++count);
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   284
            return (new PasswordAuthentication("user" + count,
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   285
                    ("passwordNotCheckedAnyway" + count).toCharArray()));
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   286
        }
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   287
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   288
        public int getCount() {
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   289
            return count;
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   290
        }
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   291
    }
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   292
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   293
    @Test(dataProvider = "uris")
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   294
    public void test(List<URI> uris) throws Exception {
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   295
        System.out.println("Server listening at " + uris.toString());
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   296
        doClient(uris);
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   297
    }
3786a0962570 8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
jboes
parents:
diff changeset
   298
}