From 499c74a896b5124b3f0c7714ba77b85764375dca Mon Sep 17 00:00:00 2001 From: Peter Kriens Date: Mon, 9 May 2022 15:08:27 +0200 Subject: [PATCH] [httpclient] Implement log as specified in doc The documentation specified a -connection-log instruction but the code did not implement it. This patch sets the log when the http client's -connection-log when the property is set. Signed-off-by: Peter Kriens --- .../test/aQute/bnd/comm/tests/HttpClientServerTest.java | 1 - .../aQute/bnd/connection/settings/ConnectionSettings.java | 8 ++++++++ biz.aQute.bndlib/src/aQute/bnd/osgi/Constants.java | 2 ++ docs/_instructions/connection-settings.md | 2 +- 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/biz.aQute.bndlib.comm.tests/test/aQute/bnd/comm/tests/HttpClientServerTest.java b/biz.aQute.bndlib.comm.tests/test/aQute/bnd/comm/tests/HttpClientServerTest.java index df9ba57845..b9d8f79a18 100644 --- a/biz.aQute.bndlib.comm.tests/test/aQute/bnd/comm/tests/HttpClientServerTest.java +++ b/biz.aQute.bndlib.comm.tests/test/aQute/bnd/comm/tests/HttpClientServerTest.java @@ -85,7 +85,6 @@ private void assertOk(String username, String password, boolean verify) throws E p.setProperty("-connection-log", log.toURI() .getPath()); p.setProperty("-connection-settings", settings); - hc.setLog(log); ConnectionSettings cs = new ConnectionSettings(p, hc); cs.readSettings(); diff --git a/biz.aQute.bndlib/src/aQute/bnd/connection/settings/ConnectionSettings.java b/biz.aQute.bndlib/src/aQute/bnd/connection/settings/ConnectionSettings.java index d4c1c513cf..0af393419c 100644 --- a/biz.aQute.bndlib/src/aQute/bnd/connection/settings/ConnectionSettings.java +++ b/biz.aQute.bndlib/src/aQute/bnd/connection/settings/ConnectionSettings.java @@ -35,6 +35,7 @@ import aQute.bnd.header.Attrs; import aQute.bnd.header.Parameters; import aQute.bnd.http.HttpClient; +import aQute.bnd.osgi.Constants; import aQute.bnd.osgi.Processor; import aQute.bnd.osgi.Processor.FileLine; import aQute.bnd.service.url.ProxyHandler; @@ -73,6 +74,13 @@ public class ConnectionSettings { public ConnectionSettings(Processor processor, HttpClient client) throws Exception { this.processor = Objects.requireNonNull(processor); this.client = client; + String logfile = processor.getProperty(Constants.CONNECTION_LOG); + if (Strings.nonNullOrEmpty(logfile)) { + File file = IO.getFile(logfile); + file.getParentFile() + .mkdirs(); + this.client.setLog(file); + } mavenMasterPassphrase = new MasterPassphrase(processor); } diff --git a/biz.aQute.bndlib/src/aQute/bnd/osgi/Constants.java b/biz.aQute.bndlib/src/aQute/bnd/osgi/Constants.java index d3759ee8a9..66ea322bfc 100644 --- a/biz.aQute.bndlib/src/aQute/bnd/osgi/Constants.java +++ b/biz.aQute.bndlib/src/aQute/bnd/osgi/Constants.java @@ -116,6 +116,8 @@ public interface Constants { String DEFINE_CONTRACT = "-define-contract"; String CONDITIONALPACKAGE = "-conditionalpackage"; String CONNECTION_SETTINGS = "-connection-settings"; + String CONNECTION_LOG = "-connection-log"; + String COMPRESSION = "-compression"; String DIFFIGNORE = "-diffignore"; String DIFFPACKAGES = "-diffpackages"; diff --git a/docs/_instructions/connection-settings.md b/docs/_instructions/connection-settings.md index b6d998addd..f3a158e60d 100644 --- a/docs/_instructions/connection-settings.md +++ b/docs/_instructions/connection-settings.md @@ -45,7 +45,7 @@ You can create a log file specific for the connections by specifying: -connection-log: somefile.txt -This file will contain the detailed trace output +This file will contain the detailed trace output. The file given is relative to the working directory. ## Syntax