< prev index next >

src/java.net.http/share/classes/jdk/internal/net/http/ConnectionPool.java

Print this page
rev 53931 : Backport JDK-8236859

*** 1,7 **** /* ! * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 140,149 **** --- 140,150 ---- if (stopped) return null; CacheKey key = new CacheKey(addr, proxy); HttpConnection c = secure ? findConnection(key, sslPool) : findConnection(key, plainPool); //System.out.println ("getConnection returning: " + c); + assert c == null || c.isSecure() == secure; return c; } /** * Returns the connection to the pool.
*** 153,162 **** --- 154,167 ---- } // Called also by whitebox tests void returnToPool(HttpConnection conn, Instant now, long keepAlive) { + assert (conn instanceof PlainHttpConnection) || conn.isSecure() + : "Attempting to return unsecure connection to SSL pool: " + + conn.getClass(); + // Don't call registerCleanupTrigger while holding a lock, // but register it before the connection is added to the pool, // since we don't want to trigger the cleanup if the connection // is not in the pool. CleanupTrigger cleanup = registerCleanupTrigger(conn);
*** 448,458 **** private void removeFromPool(HttpConnection c) { assert Thread.holdsLock(this); if (c instanceof PlainHttpConnection) { removeFromPool(c, plainPool); } else { ! assert c.isSecure(); removeFromPool(c, sslPool); } } // Used by tests --- 453,463 ---- private void removeFromPool(HttpConnection c) { assert Thread.holdsLock(this); if (c instanceof PlainHttpConnection) { removeFromPool(c, plainPool); } else { ! assert c.isSecure() : "connection " + c + " is not secure!"; removeFromPool(c, sslPool); } } // Used by tests
< prev index next >