lulianqi commented on code in PR #39:
URL: https://github.com/apache/dubbo-net/pull/39#discussion_r4571659346
##########
DubboNet.csproj:
##########
@@ -33,6 +41,15 @@
<PackageReference Include="DistributedLock.ZooKeeper" Version="1.0.0" />
<PackageReference Include="nacos-sdk-csharp" Version="1.3.10" />
<PackageReference Include="NHessian" Version="0.4.3" />
+ <!-- Directly used APIs: do not depend on Nacos to supply these
transitively. -->
+ <PackageReference Include="Microsoft.Extensions.DependencyInjection"
Version="8.0.1" />
+ <!-- Nacos' Standard dependency group otherwise selects DependencyModel
3.1,
+ whose Framework asset pulls vulnerable Newtonsoft.Json 9.0.1. -->
+ <PackageReference Include="Microsoft.Extensions.DependencyModel"
Version="8.0.2" Condition="'$(TargetFramework)' == 'netstandard2.0'" />
+ <PackageReference Include="System.Text.Json" Version="8.0.6" />
Review Comment:
感谢建议,已在
[07eeabe](https://github.com/apache/dubbo-net/pull/39/commits/07eeabe8d87e32bf5f45034008895c22986081de)
中将 `System.Text.Json 8.0.6` 的显式引用限制到 `netstandard2.0`,现代目标使用共享框架,并补充了原因注释。
分别使用默认配置和 `RestoreEnablePackagePruning=false` 打包核对了 nuspec:Standard 依赖组保留
8.0.6,net8/net10 两组均不再直接声明该包,不依赖 SDK 默认裁剪来表达这个约束。Nacos 自身的传递依赖声明保持原样。实际 NuGet
消费项目在 .NET 6/8/10 上的资产选择及协议往返验证均通过。
##########
Compatibility/StringCompatibility.cs:
##########
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+
+namespace DubboNet.Compatibility
+{
+ internal static class StringCompatibility
+ {
+#if NETSTANDARD2_0
+ internal static bool Contains(this string value, string search,
StringComparison comparison) =>
+ value.IndexOf(search, comparison) >= 0;
+ internal static bool Contains(this string value, char search,
StringComparison comparison) =>
+ value.IndexOf(search.ToString(), comparison) >= 0;
+ internal static string[] Split(this string value, string separator,
StringSplitOptions options = StringSplitOptions.None) =>
+ value.Split(new[] { separator }, options);
+ internal static string[] Split(this string value, char separator,
StringSplitOptions options) =>
+ value.Split(new[] { separator }, options);
+ internal static string[] Split(this string value, char separator, int
count) =>
+ value.Split(new[] { separator }, count);
+#endif
+ internal static string[] SplitTrimmed(string value, string separator,
int count = int.MaxValue)
Review Comment:
感谢指出这个边界,已在
[07eeabe](https://github.com/apache/dubbo-net/pull/39/commits/07eeabe8d87e32bf5f45034008895c22986081de)
中补充空/null 分隔符的处理,按 BCL 的 `string[]` 分隔符重载返回修剪后的整串或空数组,避免进入无法推进的循环;同时保留负数
`count` 校验、`count=0/1` 和 null 接收对象的行为。
新增了 16 个边界用例,并与现代 BCL 的实际结果对照;空分隔符回归测试设有 3 秒上限,防止再次出现此问题时挂住测试。原有非空分隔符及
`count` 用例也保留。原生资产和 Standard 资产分别在 .NET 8/10 上运行完整单元测试,四组均为 622 通过、0 失败、0 跳过。
##########
NetService/Telnet/ExTelnet.cs:
##########
@@ -512,18 +512,11 @@ public async Task<bool> ConnectAsync(int keepAliveTime =
-1,int telnetAlivePerio
//如果设置过连接超时
if(connectTimeOut>0)
{
- CancellationTokenSource tokenSource = new
CancellationTokenSource();
+ using CancellationTokenSource tokenSource = new
CancellationTokenSource(connectTimeOut);
CancellationToken ct = tokenSource.Token;
- Task cancelTask = Task.Delay(connectTimeOut);
- Task connectTask = mySocket.ConnectAsync(iep,ct).AsTask();
// 带CancellationToken的重载返回的是ValueTask,WhenAny需要Task
-
- //double await so if cancelTask throws exception, this
throws it
- await await Task.WhenAny(connectTask, cancelTask);
- if(!connectTask.IsCompleted)
- {
- tokenSource.Cancel();
- throw new Exception($"Connect timed out for specify
time : {connectTimeOut}ms");
- }
+ // Only the new connection attempt is owned here. The
Standard
+ // fallback aborts it on timeout and releases its
timer/registration.
+ await NetworkCompatibility.ConnectOwnedAsync(mySocket,
iep, ct);
Review Comment:
感谢指出诊断信息的退化,已在
[07eeabe](https://github.com/apache/dubbo-net/pull/39/commits/07eeabe8d87e32bf5f45034008895c22986081de)
中修复:仅在 `ExTelnet` 自身的连接期限已到期时,将连接取消转换为带原文案及毫秒数的 `TimeoutException`。现有
`ConnectAsync` 返回 false、`NowErrorMes` 和状态报告会保留 `Connect timed out for specify
time : …ms`;共享 `ConnectOwnedAsync` 的取消语义保持不变。
新增了确定性的 25ms 期限到期、期限未到时的其他取消、普通连接失败,以及实际 loopback 连接成功这四个用例,均随原生/Standard
资产在 .NET 8/10 的完整单元测试通过。公开 API 对照也没有变化。
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]