This is an automated email from the ASF dual-hosted git repository. nightowl888 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/lucenenet.git
commit 302a3c65f22090bb1bffea9aadb32a24779d720d Author: Shad Storhaug <[email protected]> AuthorDate: Fri Nov 5 10:20:32 2021 +0700 BREAKING: Lucene.Net.Replicator.Http.HttpClientBase: Increased timeout from 1000 ms to 100 s. Renamed DEFAULT_CONNECTION_TIMEOUT to DEFAULT_TIMEOUT and ConnectionTimeout property to Timeout to match HttpClient. Fixes #363. --- src/Lucene.Net.Replicator/Http/HttpClientBase.cs | 22 ++++++++++++++-------- src/Lucene.Net.Replicator/Http/HttpReplicator.cs | 2 +- .../Http/HttpReplicatorTest.cs | 1 - 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/Lucene.Net.Replicator/Http/HttpClientBase.cs b/src/Lucene.Net.Replicator/Http/HttpClientBase.cs index aea0c97..974f5f4 100644 --- a/src/Lucene.Net.Replicator/Http/HttpClientBase.cs +++ b/src/Lucene.Net.Replicator/Http/HttpClientBase.cs @@ -10,6 +10,7 @@ using System.Net; using System.Net.Http; using System.Runtime.ExceptionServices; using System.Text; +using System.Threading; namespace Lucene.Net.Replicator.Http { @@ -38,11 +39,16 @@ namespace Lucene.Net.Replicator.Http /// </remarks> public abstract class HttpClientBase : IDisposable { + // LUCENENET specific - removed DEFAULT_CONNECTION_TIMEOUT because it is irrelevant in .NET + + [Obsolete("Use DEFAULT_TIMEOUT instead. This extension method will be removed in 4.8.0 release candidate.")] + public const int DEFAULT_CONNECTION_TIMEOUT = 1000; + /// <summary> - /// Default connection timeout for this client, in milliseconds. - /// <see cref="ConnectionTimeout"/> + /// Default request timeout for this client (100 seconds). + /// <see cref="Timeout"/>. /// </summary> - public const int DEFAULT_CONNECTION_TIMEOUT = 1000; + public readonly static TimeSpan DEFAULT_TIMEOUT = TimeSpan.FromSeconds(100); // LUCENENET: This was DEFAULT_SO_TIMEOUT in Lucene, using .NET's default timeout value of 100 instead of 61 seconds // TODO compression? @@ -84,7 +90,7 @@ namespace Lucene.Net.Replicator.Http /// <param name="messageHandler">Optional, The HTTP handler stack to use for sending requests.</param> //Note: LUCENENET Specific protected HttpClientBase(string url, HttpMessageHandler messageHandler = null) - : this(url, new HttpClient(messageHandler ?? new HttpClientHandler()) { Timeout = TimeSpan.FromMilliseconds(DEFAULT_CONNECTION_TIMEOUT) }) + : this(url, new HttpClient(messageHandler ?? new HttpClientHandler()) { Timeout = DEFAULT_TIMEOUT }) { } @@ -102,17 +108,17 @@ namespace Lucene.Net.Replicator.Http { Url = url; httpc = client; - ConnectionTimeout = DEFAULT_CONNECTION_TIMEOUT; + Timeout = DEFAULT_TIMEOUT; } /// <summary> /// Gets or Sets the connection timeout for this client, in milliseconds. This setting /// is used to modify <see cref="HttpClient.Timeout"/>. /// </summary> - public virtual int ConnectionTimeout + public virtual TimeSpan Timeout { - get => (int)httpc.Timeout.TotalMilliseconds; - set => httpc.Timeout = TimeSpan.FromMilliseconds(value); + get => httpc.Timeout; + set => httpc.Timeout = value; } /// <summary> diff --git a/src/Lucene.Net.Replicator/Http/HttpReplicator.cs b/src/Lucene.Net.Replicator/Http/HttpReplicator.cs index 5c4f98c..23a0447 100644 --- a/src/Lucene.Net.Replicator/Http/HttpReplicator.cs +++ b/src/Lucene.Net.Replicator/Http/HttpReplicator.cs @@ -45,7 +45,7 @@ namespace Lucene.Net.Replicator.Http /// </summary> //Note: LUCENENET Specific public HttpReplicator(string url, HttpMessageHandler messageHandler = null) - : this(url, new HttpClient(messageHandler ?? new HttpClientHandler()) { Timeout = TimeSpan.FromMilliseconds(DEFAULT_CONNECTION_TIMEOUT) }) + : this(url, new HttpClient(messageHandler ?? new HttpClientHandler()) { Timeout = DEFAULT_TIMEOUT }) { } diff --git a/src/Lucene.Net.Tests.Replicator/Http/HttpReplicatorTest.cs b/src/Lucene.Net.Tests.Replicator/Http/HttpReplicatorTest.cs index d6a5a74..b3061ad 100644 --- a/src/Lucene.Net.Tests.Replicator/Http/HttpReplicatorTest.cs +++ b/src/Lucene.Net.Tests.Replicator/Http/HttpReplicatorTest.cs @@ -92,7 +92,6 @@ namespace Lucene.Net.Replicator.Http [Test] - [AwaitsFix(BugUrl = "https://github.com/apache/lucenenet/issues/269")] // LUCENENET TODO: this test occasionally fails public void TestBasic() { IReplicator replicator = new HttpReplicator(host, port, ReplicationService.REPLICATION_CONTEXT + "/s1", server.CreateHandler());
