8282617: sun.net.www.protocol.https.HttpsClient#putInKeepAliveCache() doesn't use a lock while dealing with "inCache" field

Reviewed-by: dfuchs, michaelm
This commit is contained in:
Jaikiran Pai 2022-03-06 08:16:39 +00:00
parent bc42e7cbbf
commit 974ef5542f

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -661,12 +661,17 @@ final class HttpsClient extends HttpClient
@Override @Override
protected void putInKeepAliveCache() { protected void putInKeepAliveCache() {
lock();
try {
if (inCache) { if (inCache) {
assert false : "Duplicate put to keep alive cache"; assert false : "Duplicate put to keep alive cache";
return; return;
} }
inCache = true; inCache = true;
kac.put(url, sslSocketFactory, this); kac.put(url, sslSocketFactory, this);
} finally {
unlock();
}
} }
/* /*