Skip to content

Commit f56ebb3

Browse files
Build Warnings: Miscellanous (#7575)
* Warnings: Akka.Cluster.Metrics * `AK1004` and `AK1008` warnings * resolving build warnings inside Akka.Streams.Attributes * more TBD and build warning cleanup * Akka.Cluster.Metrics API approvals
1 parent 15e5d8b commit f56ebb3

File tree

12 files changed

+31
-83
lines changed

12 files changed

+31
-83
lines changed

src/benchmark/Akka.Benchmarks/DData/ORSetBenchmarks.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,6 @@ public class ORSetBenchmarks
3232
private UniqueAddress[] _nodes;
3333
private string[] _elements;
3434

35-
private readonly string _user1 = "{\"username\":\"john\",\"password\":\"coltrane\"}";
36-
private readonly string _user2 = "{\"username\":\"sonny\",\"password\":\"rollins\"}";
37-
private readonly string _user3 = "{\"username\":\"charlie\",\"password\":\"parker\"}";
38-
private readonly string _user4 = "{\"username\":\"charles\",\"password\":\"mingus\"}";
39-
4035
// has data from all nodes
4136
private ORSet<string> _c1 = ORSet<String>.Empty;
4237

src/contrib/cluster/Akka.Cluster.Metrics/Serialization/Metric.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public static Either<long, double> ConvertNumber(AnyNumber number)
169169

170170

171171

172-
public bool Equals(Metric other)
172+
public bool Equals(Metric? other)
173173
{
174174
if (ReferenceEquals(null, other)) return false;
175175
if (ReferenceEquals(this, other)) return true;
@@ -181,6 +181,11 @@ public override int GetHashCode()
181181
{
182182
return Name.GetHashCode();
183183
}
184+
185+
public override bool Equals(object? obj)
186+
{
187+
return Equals(obj as Metric);
188+
}
184189
}
185190
}
186191
}

src/contrib/cluster/Akka.Cluster.Metrics/Serialization/NodeMetrics.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ internal sealed class NodeMetricsComparer: IEqualityComparer<NodeMetrics>
1919
public static readonly NodeMetricsComparer Instance = new();
2020

2121
private NodeMetricsComparer() { }
22-
public bool Equals(NodeMetrics x, NodeMetrics y)
22+
public bool Equals(NodeMetrics? x, NodeMetrics? y)
2323
{
2424
if (ReferenceEquals(x, y)) return true;
2525
if (ReferenceEquals(x, null)) return false;
@@ -114,7 +114,7 @@ public NodeMetrics Update(NodeMetrics that)
114114
* just stip them from generated code and paste here, with adding Address property check
115115
*/
116116

117-
public bool Equals(NodeMetrics other)
117+
public bool Equals(NodeMetrics? other)
118118
{
119119
if (ReferenceEquals(null, other)) return false;
120120
if (ReferenceEquals(this, other)) return true;

src/contrib/cluster/Akka.Cluster.Sharding/ShardRegion.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1416,8 +1416,11 @@ private void HandleTerminated(Terminated terminated)
14161416
// if persist fails it will stop
14171417
_log.Debug("{0}: Shard [{1}] terminated while not being handed off", _typeName, shard);
14181418
if (_settings.RememberEntities)
1419+
#pragma warning disable AK1004
1420+
// we disable AK1004 here because we might have multiple shard failure backoffs inflight at once
14191421
Context.System.Scheduler.ScheduleTellOnce(_settings.TuningParameters.ShardFailureBackoff, Self,
14201422
new RestartShard(shard), Self);
1423+
#pragma warning restore AK1004
14211424
}
14221425

14231426
// did this shard get removed because the ShardRegion is shutting down?

src/contrib/cluster/Akka.Cluster.Tools/Client/ClusterClientDiscovery.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ private Receive Active(ActorPath[] contacts)
361361
// Setup cluster client initial contacts
362362
var currentSettings = _settings.WithInitialContacts(contacts.ToImmutableHashSet());
363363

364-
var clusterClient = Context.System.ActorOf(Props.Create(() => new ClusterClient(currentSettings)).WithDeploy(Deploy.Local));
364+
var clusterClient = Context.ActorOf(Props.Create(() => new ClusterClient(currentSettings)).WithDeploy(Deploy.Local));
365365
Context.Watch(clusterClient);
366366
Stash.UnstashAll();
367367

src/contrib/cluster/Akka.DistributedData.Tests/LocalConcurrencySpec.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@
66
//-----------------------------------------------------------------------
77

88
using System.Collections.Immutable;
9+
using System.Threading.Tasks;
910
using Akka.Actor;
1011
using Akka.Configuration;
12+
using Akka.TestKit;
1113
using Xunit;
1214
using Xunit.Abstractions;
15+
using FluentAssertions;
1316

1417
namespace Akka.DistributedData.Tests
1518
{
@@ -46,13 +49,13 @@ public LocalConcurrencySpec(ITestOutputHelper output)
4649
}
4750

4851
[Fact]
49-
public void Updates_from_same_node_should_be_possible_to_do_from_two_actors()
52+
public async Task Updates_from_same_node_should_be_possible_to_do_from_two_actors()
5053
{
5154
var updater1 = ActorOf(Props.Create<Updater>(), "updater1");
5255
var updater2 = ActorOf(Props.Create<Updater>(), "updater2");
5356

5457
var b = ImmutableHashSet<string>.Empty.ToBuilder();
55-
for (int i = 1; i <= 100; i++)
58+
for (var i = 1; i <= 100; i++)
5659
{
5760
var m1 = "a" + 1;
5861
var m2 = "b" + 1;
@@ -64,12 +67,12 @@ public void Updates_from_same_node_should_be_possible_to_do_from_two_actors()
6467
}
6568

6669
var expected = b.ToImmutable();
67-
AwaitAssert(() =>
70+
await AwaitAssertAsync(async () =>
6871
{
6972
_replicator.Tell(Dsl.Get(Updater.Key, ReadLocal.Instance));
70-
var msg = ExpectMsg<GetSuccess>();
73+
var msg = await ExpectMsgAsync<GetSuccess>();
7174
var elements = msg.Get(Updater.Key).Elements;
72-
Assert.Equal(expected, elements);
75+
elements.Should().BeEquivalentTo(expected);
7376
});
7477
}
7578
}

src/core/Akka.API.Tests/verify/CoreAPISpec.ApproveClusterMetrics.DotNet.verified.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,7 @@ namespace Akka.Cluster.Metrics.Serialization
372372
[Akka.Annotations.InternalApiAttribute()]
373373
public static bool Defined(Akka.Cluster.Metrics.Helpers.AnyNumber value) { }
374374
public bool Equals(Akka.Cluster.Metrics.Serialization.NodeMetrics.Types.Metric other) { }
375+
public override bool Equals(object obj) { }
375376
public override int GetHashCode() { }
376377
public bool SameAs(Akka.Cluster.Metrics.Serialization.NodeMetrics.Types.Metric that) { }
377378
public static Akka.Cluster.Metrics.Serialization.NodeMetrics.Types.Metric +(Akka.Cluster.Metrics.Serialization.NodeMetrics.Types.Metric m1, Akka.Cluster.Metrics.Serialization.NodeMetrics.Types.Metric m2) { }

src/core/Akka.API.Tests/verify/CoreAPISpec.ApproveClusterMetrics.Net.verified.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ namespace Akka.Cluster.Metrics.Serialization
371371
[Akka.Annotations.InternalApiAttribute()]
372372
public static bool Defined(Akka.Cluster.Metrics.Helpers.AnyNumber value) { }
373373
public bool Equals(Akka.Cluster.Metrics.Serialization.NodeMetrics.Types.Metric other) { }
374+
public override bool Equals(object obj) { }
374375
public override int GetHashCode() { }
375376
public bool SameAs(Akka.Cluster.Metrics.Serialization.NodeMetrics.Types.Metric that) { }
376377
public static Akka.Cluster.Metrics.Serialization.NodeMetrics.Types.Metric +(Akka.Cluster.Metrics.Serialization.NodeMetrics.Types.Metric m1, Akka.Cluster.Metrics.Serialization.NodeMetrics.Types.Metric m2) { }

src/core/Akka.Streams/ActorMaterializer.cs

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -356,11 +356,6 @@ public AbruptStageTerminationException(SerializationInfo info, StreamingContext
356356
/// </summary>
357357
public sealed class ActorMaterializerSettings
358358
{
359-
/// <summary>
360-
/// TBD
361-
/// </summary>
362-
/// <param name="system">TBD</param>
363-
/// <returns>TBD</returns>
364359
public static ActorMaterializerSettings Create(ActorSystem system)
365360
{
366361
// need to make sure the default materializer settings are available
@@ -446,22 +441,7 @@ private static ActorMaterializerSettings Create(Config config)
446441
/// INTERNAL API
447442
/// </summary>
448443
public readonly StreamRefSettings StreamRefSettings;
449-
450-
/// <summary>
451-
/// TBD
452-
/// </summary>
453-
/// <param name="initialInputBufferSize">TBD</param>
454-
/// <param name="maxInputBufferSize">TBD</param>
455-
/// <param name="dispatcher">TBD</param>
456-
/// <param name="supervisionDecider">TBD</param>
457-
/// <param name="subscriptionTimeoutSettings">TBD</param>
458-
/// <param name="streamRefSettings">TBD</param>
459-
/// <param name="isDebugLogging">TBD</param>
460-
/// <param name="outputBurstLimit">TBD</param>
461-
/// <param name="isFuzzingMode">TBD</param>
462-
/// <param name="isAutoFusing">TBD</param>
463-
/// <param name="maxFixedBufferSize">TBD</param>
464-
/// <param name="syncProcessingLimit">TBD</param>
444+
465445
public ActorMaterializerSettings(
466446
int initialInputBufferSize,
467447
int maxInputBufferSize,

src/core/Akka.Streams/Attributes.cs

Lines changed: 7 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,6 @@ public override int GetHashCode()
180180
/// </summary>
181181
public sealed class AsyncBoundary : IAttribute, IEquatable<AsyncBoundary>
182182
{
183-
/// <summary>
184-
/// TBD
185-
/// </summary>
186183
public static readonly AsyncBoundary Instance = new();
187184
private AsyncBoundary() { }
188185
public bool Equals(AsyncBoundary other) => other is AsyncBoundary;
@@ -270,21 +267,14 @@ public AfterDelay(TimeSpan delay, IStrategy strategy)
270267
}
271268
}
272269
}
273-
274-
/// <summary>
275-
/// TBD
276-
/// </summary>
270+
277271
public static readonly Attributes None = new();
278272

279273
private readonly IAttribute[] _attributes;
280-
281-
/// <summary>
282-
/// TBD
283-
/// </summary>
284-
/// <param name="attributes">TBD</param>
274+
285275
public Attributes(params IAttribute[] attributes)
286276
{
287-
_attributes = attributes ?? Array.Empty<IAttribute>();
277+
_attributes = attributes ?? [];
288278
}
289279

290280
/// <summary>
@@ -314,18 +304,13 @@ internal bool IsAsync
314304
///
315305
/// The list is ordered with the most specific attribute first, least specific last.
316306
/// </summary>
317-
/// <typeparam name="TAttr">TBD</typeparam>
318-
/// <returns>TBD</returns>
319307
public IEnumerable<TAttr> GetAttributeList<TAttr>() where TAttr : IAttribute
320-
=> _attributes.Length == 0 ? Enumerable.Empty<TAttr>() : _attributes.Where(a => a is TAttr).Cast<TAttr>();
308+
=> _attributes.Length == 0 ? [] : _attributes.Where(a => a is TAttr).Cast<TAttr>();
321309

322310
/// <summary>
323311
/// Get the last (most specific) attribute of a given type or subtype thereof.
324312
/// If no such attribute exists the default value is returned.
325313
/// </summary>
326-
/// <typeparam name="TAttr">TBD</typeparam>
327-
/// <param name="defaultIfNotFound">TBD</param>
328-
/// <returns>TBD</returns>
329314
#nullable enable
330315
[return: NotNullIfNotNull("defaultIfNotFound")]
331316
public TAttr? GetAttribute<TAttr>(TAttr? defaultIfNotFound) where TAttr : class, IAttribute
@@ -336,26 +321,19 @@ public IEnumerable<TAttr> GetAttributeList<TAttr>() where TAttr : IAttribute
336321
/// Get the first (least specific) attribute of a given type or subtype thereof.
337322
/// If no such attribute exists the default value is returned.
338323
/// </summary>
339-
/// <typeparam name="TAttr">TBD</typeparam>
340-
/// <param name="defaultIfNotFound">TBD</param>
341-
/// <returns>TBD</returns>
342324
[Obsolete("Attributes should always be most specific, use GetAttribute<TAttr>()")]
343325
public TAttr GetFirstAttribute<TAttr>(TAttr defaultIfNotFound) where TAttr : class, IAttribute
344326
=> GetFirstAttribute<TAttr>() ?? defaultIfNotFound;
345327

346328
/// <summary>
347329
/// Get the last (most specific) attribute of a given type or subtype thereof.
348330
/// </summary>
349-
/// <typeparam name="TAttr">TBD</typeparam>
350-
/// <returns>TBD</returns>
351331
public TAttr GetAttribute<TAttr>() where TAttr : class, IAttribute
352332
=> _attributes.LastOrDefault(attr => attr is TAttr) as TAttr;
353333

354334
/// <summary>
355335
/// Get the first (least specific) attribute of a given type or subtype thereof.
356336
/// </summary>
357-
/// <typeparam name="TAttr">TBD</typeparam>
358-
/// <returns>TBD</returns>
359337
[Obsolete("Attributes should always be most specific, use GetAttribute<TAttr>()")]
360338
public TAttr GetFirstAttribute<TAttr>() where TAttr : class, IAttribute
361339
=> _attributes.FirstOrDefault(attr => attr is TAttr) as TAttr;
@@ -364,8 +342,6 @@ public TAttr GetFirstAttribute<TAttr>() where TAttr : class, IAttribute
364342
/// Get the most specific of one of the mandatory attributes. Mandatory attributes are guaranteed
365343
/// to always be among the attributes when the attributes are coming from a materialization.
366344
/// </summary>
367-
/// <typeparam name="TAttr"></typeparam>
368-
/// <returns></returns>
369345
public TAttr GetMandatoryAttribute<TAttr>() where TAttr : class, IMandatoryAttribute
370346
{
371347
if (!(_attributes.First(attr => attr is TAttr) is TAttr result))
@@ -376,8 +352,6 @@ public TAttr GetMandatoryAttribute<TAttr>() where TAttr : class, IMandatoryAttri
376352
/// <summary>
377353
/// Adds given attributes to the end of these attributes.
378354
/// </summary>
379-
/// <param name="other">TBD</param>
380-
/// <returns>TBD</returns>
381355
public Attributes And(Attributes other)
382356
{
383357
if (_attributes.Length == 0)
@@ -390,21 +364,13 @@ public Attributes And(Attributes other)
390364
/// <summary>
391365
/// Adds given attribute to the end of these attributes.
392366
/// </summary>
393-
/// <param name="other">TBD</param>
394-
/// <returns>TBD</returns>
395-
public Attributes And(IAttribute other) => new(_attributes.Concat(new[] { other }).ToArray());
367+
public Attributes And(IAttribute other) => new(_attributes.Concat([other]).ToArray());
396368

397369
/// <summary>
398370
/// Extracts Name attributes and concatenates them.
399371
/// </summary>
400-
/// <returns>TBD</returns>
401372
public string GetNameLifted() => GetNameOrDefault(null);
402-
403-
/// <summary>
404-
/// TBD
405-
/// </summary>
406-
/// <param name="defaultIfNotFound">TBD</param>
407-
/// <returns>TBD</returns>
373+
408374
public string GetNameOrDefault(string defaultIfNotFound = "unknown-operation")
409375
{
410376
if (_attributes.Length == 0)
@@ -431,9 +397,6 @@ public string GetNameOrDefault(string defaultIfNotFound = "unknown-operation")
431397
/// Note that operators in general should not inspect the whole hierarchy but instead use
432398
/// `get` to get the most specific attribute value.
433399
/// </summary>
434-
/// <typeparam name="TAttr">TBD</typeparam>
435-
/// <param name="attribute">TBD</param>
436-
/// <returns>TBD</returns>
437400
[Obsolete("Use GetAttribute<TAttr>() instead")]
438401
public bool Contains<TAttr>(TAttr attribute) where TAttr : IAttribute => _attributes.Any(a => a is TAttr);
439402

@@ -447,12 +410,10 @@ public string GetNameOrDefault(string defaultIfNotFound = "unknown-operation")
447410
/// the name is sometimes used as part of actor name. If that is not desired
448411
/// the name can be added in it's raw format using `.And(new Attributes(new Name(name)))`.
449412
/// </summary>
450-
/// <param name="name">TBD</param>
451-
/// <returns>TBD</returns>
452413
public static Attributes CreateName(string name)
453414
=> string.IsNullOrEmpty(name) ?
454415
None :
455-
new Attributes(new Name(Uri.EscapeUriString(name)));
416+
new Attributes(new Name(Uri.EscapeDataString(name)));
456417

457418
/// <summary>
458419
/// Each asynchronous piece of a materialized stream topology is executed by one Actor

0 commit comments

Comments
 (0)