From ad44154336d3eae150cd8b80b0d9f89bf9ac38f0 Mon Sep 17 00:00:00 2001 From: Julien Viet Date: Mon, 10 Aug 2026 17:22:26 +0200 Subject: [PATCH] Use new resource API. Motivation: Vert.x core has introduced new API for resource cleanup. This project should use it. Changes: Use new resource cleanup API. --- .../java/io/vertx/httpproxy/impl/CacheImpl.java | 8 +++++++- .../java/io/vertx/httpproxy/impl/ReverseProxy.java | 14 ++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/main/java/io/vertx/httpproxy/impl/CacheImpl.java b/src/main/java/io/vertx/httpproxy/impl/CacheImpl.java index c6b2914..d36a581 100644 --- a/src/main/java/io/vertx/httpproxy/impl/CacheImpl.java +++ b/src/main/java/io/vertx/httpproxy/impl/CacheImpl.java @@ -1,16 +1,18 @@ package io.vertx.httpproxy.impl; import io.vertx.core.Future; +import io.vertx.core.internal.Closeable; import io.vertx.httpproxy.cache.CacheOptions; import io.vertx.httpproxy.spi.cache.Cache; import io.vertx.httpproxy.spi.cache.Resource; +import java.time.Duration; import java.util.*; /** * Simplistic implementation. */ -public class CacheImpl implements Cache { +public class CacheImpl implements Cache, Closeable { private final int maxSize; private final Map data; @@ -43,4 +45,8 @@ public Future remove(String key) { return Future.succeededFuture(); } + @Override + public Future shutdown(Duration timeout) { + return Future.succeededFuture(); + } } diff --git a/src/main/java/io/vertx/httpproxy/impl/ReverseProxy.java b/src/main/java/io/vertx/httpproxy/impl/ReverseProxy.java index 27299ce..b60f972 100644 --- a/src/main/java/io/vertx/httpproxy/impl/ReverseProxy.java +++ b/src/main/java/io/vertx/httpproxy/impl/ReverseProxy.java @@ -14,7 +14,7 @@ import io.vertx.core.Vertx; import io.vertx.core.buffer.Buffer; import io.vertx.core.http.*; -import io.vertx.core.internal.CloseFuture; +import io.vertx.core.internal.CloseableResource; import io.vertx.core.internal.VertxInternal; import io.vertx.core.internal.http.HttpClientInternal; import io.vertx.core.internal.logging.Logger; @@ -51,12 +51,14 @@ public ReverseProxy(ProxyOptions options, HttpClient client) { public Cache newCache(CacheOptions options, Vertx vertx) { if (options.isShared()) { - CloseFuture closeFuture = new CloseFuture(); - return ((VertxInternal) vertx).createSharedResource("__vertx.shared.proxyCache", options.getName(), closeFuture, (cf_) -> { - return new CacheImpl(options); - }); + CloseableResource resource = ((VertxInternal) vertx).createSharedResource( + "__vertx.shared.proxyCache", + options.getName(), + () -> new CacheImpl(options)); + return resource.get(); + } else { + return new CacheImpl(options); } - return new CacheImpl(options); } @Override