This is an automated email from the ASF dual-hosted git repository.
cstamas pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-resolver.git
The following commit(s) were added to refs/heads/master by this push:
new 0feb2143e Feat: config to close connection at end of tx (#1978)
0feb2143e is described below
commit 0feb2143e382e9095928f14c465a04f52ed99fd8
Author: Tamas Cservenak <[email protected]>
AuthorDate: Sat Jul 18 12:44:54 2026 +0200
Feat: config to close connection at end of tx (#1978)
New config option to make URL transport close connection at end of each
transaction.
---
.../eclipse/aether/transport/url/UrlTransporter.java | 9 +++++++++
.../transport/url/UrlTransporterConfigurationKeys.java | 17 +++++++++++++++++
2 files changed, 26 insertions(+)
diff --git
a/maven-resolver-transport-url/src/main/java/org/eclipse/aether/transport/url/UrlTransporter.java
b/maven-resolver-transport-url/src/main/java/org/eclipse/aether/transport/url/UrlTransporter.java
index c65b78c48..9f651c690 100644
---
a/maven-resolver-transport-url/src/main/java/org/eclipse/aether/transport/url/UrlTransporter.java
+++
b/maven-resolver-transport-url/src/main/java/org/eclipse/aether/transport/url/UrlTransporter.java
@@ -100,6 +100,7 @@ public class UrlTransporter extends AbstractTransporter
implements HttpTransport
private final RedirectMode redirectMode;
private final boolean redirectAllowDowngrade;
private final int maxRedirects;
+ private final boolean closeConnection;
private final Object authKey;
private final Object proxyAuthKey;
@@ -174,6 +175,11 @@ public class UrlTransporter extends AbstractTransporter
implements HttpTransport
UrlTransporterConfigurationKeys.DEFAULT_MAX_REDIRECT_COUNT,
UrlTransporterConfigurationKeys.CONFIG_PROP_MAX_REDIRECT_COUNT
+ "." + repository.getId(),
UrlTransporterConfigurationKeys.CONFIG_PROP_MAX_REDIRECT_COUNT);
+ this.closeConnection = ConfigUtils.getBoolean(
+ session,
+ UrlTransporterConfigurationKeys.DEFAULT_CLOSE_CONNECTION,
+ UrlTransporterConfigurationKeys.CONFIG_PROP_CLOSE_CONNECTION +
"." + repository.getId(),
+ UrlTransporterConfigurationKeys.CONFIG_PROP_CLOSE_CONNECTION);
this.authKey = Keys.of(UrlTransporter.class, repository, "auth");
this.proxyAuthKey = Keys.of(UrlTransporter.class, repository,
"proxyAuth");
@@ -291,6 +297,9 @@ public class UrlTransporter extends AbstractTransporter
implements HttpTransport
con.setRequestProperty("Pragma", "no-cache");
con.setRequestProperty(HttpConstants.USER_AGENT, userAgent);
headers.forEach(con::setRequestProperty);
+ if (closeConnection) {
+ con.setRequestProperty("Connection", "close");
+ }
if (currAuth != null) {
con.setRequestProperty(HEADER_AUTHORIZATION,
basicAuthorization(currAuth));
}
diff --git
a/maven-resolver-transport-url/src/main/java/org/eclipse/aether/transport/url/UrlTransporterConfigurationKeys.java
b/maven-resolver-transport-url/src/main/java/org/eclipse/aether/transport/url/UrlTransporterConfigurationKeys.java
index cc335c546..d58aed668 100644
---
a/maven-resolver-transport-url/src/main/java/org/eclipse/aether/transport/url/UrlTransporterConfigurationKeys.java
+++
b/maven-resolver-transport-url/src/main/java/org/eclipse/aether/transport/url/UrlTransporterConfigurationKeys.java
@@ -69,4 +69,21 @@ public final class UrlTransporterConfigurationKeys {
public static final String CONFIG_PROP_REDIRECT_ALLOW_DOWNGRADE =
CONFIG_PROPS_PREFIX + "redirectAllowDowngrade";
public static final boolean DEFAULT_REDIRECT_ALLOW_DOWNGRADE = false;
+
+ /**
+ * Whether this transport should close the HTTP connection at the end of
each transaction, effectively
+ * disabling persistent connections (keep-alive). This configuration
affects only this transport.
+ * Important to note, that globally, on JVM-wide level persistent
connections are controlled by
+ * <a
href="https://docs.oracle.com/javase/8/docs/technotes/guides/net/http-keepalive.html">{@code
http.keepAlive}</a>
+ * Java system property, that is {@code true} by default. If this system
property is set to {@code false}, this
+ * transport cannot use persistent connections either.
+ *
+ * @configurationSource {@link
RepositorySystemSession#getConfigProperties()}
+ * @configurationType {@link java.lang.Boolean}
+ * @configurationDefaultValue {@link #DEFAULT_CLOSE_CONNECTION}
+ * @configurationRepoIdSuffix Yes
+ */
+ public static final String CONFIG_PROP_CLOSE_CONNECTION =
CONFIG_PROPS_PREFIX + "closeConnection";
+
+ public static final boolean DEFAULT_CLOSE_CONNECTION = false;
}