Skip to content

Commit a4f40d8

Browse files
committed
do not use refresh as this can force eviction/disconnection, simply trigger a direct cache read to extend access TTL (or cause a new connection to be opened)
1 parent ced76fc commit a4f40d8

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/main/java/io/cryostat/targets/TargetConnectionManager.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -277,19 +277,19 @@ private <T> Uni<T> executeInternal(Uni<T> uni) {
277277
* its internal cache that the connection is in fact still active and should not be
278278
* expired/closed. This will extend the lifetime of the cache entry by another TTL into the
279279
* future from the time this method is called. This may be done repeatedly as long as the
280-
* connection is required to remain active.
280+
* connection is required to remain active. Calling this method on a Target which does not
281+
* currently have an open connection will cause a new connection to be opened.
281282
*
282-
* @return false if the connection for the specified {@link Target} was already removed from
283-
* cache, true if it is still active and was refreshed
283+
* @return false if the connection for the specified {@link Target} could not be refreshed, true
284+
* if it was
284285
*/
285286
public boolean markConnectionInUse(Target target) {
286-
var key = target.connectUrl;
287-
var connection = connections.getIfPresent(key);
288-
if (connection != null) {
289-
connections.synchronous().refresh(key);
287+
try {
288+
connections.get(target.connectUrl).get();
290289
return true;
290+
} catch (ExecutionException | InterruptedException e) {
291+
return false;
291292
}
292-
return false;
293293
}
294294

295295
private void closeConnection(URI connectUrl, JFRConnection connection, RemovalCause cause) {

0 commit comments

Comments
 (0)