Skip to content

Commit

Permalink
more fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
eaba committed Dec 20, 2023
1 parent 5973f71 commit ede7994
Show file tree
Hide file tree
Showing 16 changed files with 92 additions and 95 deletions.
40 changes: 21 additions & 19 deletions src/SharpPulsar.Test.API/Schema/AvroSchemaTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ public class AvroSchemaTest
{
private class DefaultStruct
{
public int Field1 { get; set; }
public string Field2 { get; set; }
public int? Field1 { get; set; }
public string? Field2 { get; set; }
public long? Field3 { get; set; }
}

private class StructWithAnnotations
{
public int Field1 { get; set; }
public string Field2 { get; set; }
public int? Field1 { get; set; }
public string? Field2 { get; set; }
public long? Field3 { get; set; }
}

Expand All @@ -53,10 +53,11 @@ private class SchemaLogicalType : IEquatable<SchemaLogicalType>
public long TimeMillis { get; set; }
public long TimestampMicros { get; set; }
public long TimeMicros { get; set; }
public bool Equals(SchemaLogicalType other)
public bool Equals(SchemaLogicalType? other)
{
if (Decimal == other.Decimal && Date == other.Date && TimestampMillis == other.TimestampMillis
&& TimeMillis == other.TimeMillis && TimestampMicros == other.TimestampMicros && TimeMicros == other.TimeMicros)
if (Decimal == other?.Decimal && Date == other?.Date && TimestampMillis == other?.TimestampMillis
&& TimeMillis == other?.TimeMillis && TimestampMicros == other?.TimestampMicros
&& TimeMicros == other?.TimeMicros)
return true;
return false;
}
Expand Down Expand Up @@ -151,9 +152,9 @@ public class Bar : IEquatable<Bar>
{
public bool Field1 { get; set; }

public bool Equals(Bar other)
public bool Equals(Bar? other)
{
if (Field1 == other.Field1)
if (Field1 == other?.Field1)
return true;
return false;
}
Expand All @@ -162,19 +163,20 @@ public bool Equals(Bar other)
public class Foo : IEquatable<Foo>
{
public Color Color { get; set; }
public string Field1 { get; set; }
public string Field2 { get; set; }
public string Field3 { get; set; }
public Bar Field4 { get; set; }
public string Field5 { get; set; }
public string? Field1 { get; set; }
public string? Field2 { get; set; }
public string? Field3 { get; set; }
public Bar? Field4 { get; set; }
public string? Field5 { get; set; }

public bool Equals(Foo other)
public bool Equals(Foo? other)
{
if (Field1 == other.Field1 && Field2 == other.Field2 && Field3 == other.Field3
&& Field4?.Field1 == other.Field4?.Field1 && Field5 == other.Field5)
if (Field1 == other?.Field1 && Field2 == other?.Field2 && Field3 == other?.Field3
&& Field4?.Field1 == other?.Field4?.Field1 && Field5 == other?.Field5)
return true;
return false;
}

}
[Serializable]
public enum Color
Expand All @@ -189,10 +191,10 @@ public class LogicalMessage : ISpecificRecord
public DateTime CreatedTime { get; set; }

public AvroDecimal Size { get; set; }
public string DayOfWeek { get; set; }
public required string DayOfWeek { get; set; }

[Ignore]
public Avro.Schema Schema { get; set; }
public Avro.Schema? Schema { get; set; }

public object Get(int fieldPos)
{
Expand Down
42 changes: 21 additions & 21 deletions src/SharpPulsar.Test.API/SchemaTestUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@ public class SchemaTestUtils
public class Foo : IEquatable<Foo>
{

public string Field1 { get; set; }
public string Field2 { get; set; }
public string? Field1 { get; set; }
public string? Field2 { get; set; }
public int Field3 { get; set; }

public Bar Field4 { get; set; }
public Bar? Field4 { get; set; }

public Color Color { get; set; }

public string FieldUnableNull { get; set; }
public bool Equals(Foo other)
public string? FieldUnableNull { get; set; }
public bool Equals(Foo? other)
{
if (Field1 == other.Field1 && Field2 == other.Field2 && Field3 == other.Field3
&& Field4?.Field1 == other.Field4?.Field1 && Color == other.Color && FieldUnableNull == other.FieldUnableNull)
if (Field1 == other?.Field1 && Field2 == other?.Field2 && Field3 == other?.Field3
&& Field4?.Field1 == other?.Field4?.Field1 && Color == other?.Color && FieldUnableNull == other?.FieldUnableNull)
return true;
return false;
}
Expand All @@ -50,11 +50,11 @@ public bool Equals(Foo other)
[Serializable]
public class FooV2 : IEquatable<FooV2>
{
public string Field1 { get; set; }
public string? Field1 { get; set; }
public int Field3 { get; set; }
public bool Equals(FooV2 other)
public bool Equals(FooV2? other)
{
return Field1 == other.Field1 && Field3 == other.Field3;
return Field1 == other?.Field1 && Field3 == other?.Field3;
}
}

Expand All @@ -64,9 +64,9 @@ public class Bar : IEquatable<Bar>
{
public bool Field1 { get; set; }

public bool Equals(Bar other)
public bool Equals(Bar? other)
{
if (Field1 == other.Field1)
if (Field1 == other?.Field1)
return true;
return false;
}
Expand All @@ -75,25 +75,25 @@ public bool Equals(Bar other)
public class NestedBar
{
public bool Field1 { get; set; }
public Bar Nested { get; set; }
public Bar? Nested { get; set; }
}


public class NestedBarList
{
public bool Field1 { get; set; }
public IList<Bar> List { get; set; }
public IList<Bar>? List { get; set; }
}


public class DerivedFoo : Foo, IEquatable<DerivedFoo>
{
public string Field5 { get; set; }
public string? Field5 { get; set; }
public int Field6 { get; set; }
public Foo Foo { get; set; }
public bool Equals(DerivedFoo other)
public Foo? Foo { get; set; }
public bool Equals(DerivedFoo? other)
{
return Field5 == other.Field5 && Field6 == other.Field6 && Foo == other.Foo;
return Field5 == other?.Field5 && Field6 == other?.Field6 && Foo == other.Foo;
}
}

Expand All @@ -105,10 +105,10 @@ public enum Color

public class DerivedDerivedFoo : DerivedFoo
{
public string Field7 { get; set; }
public string? Field7 { get; set; }
public int Field8 { get; set; }
public DerivedFoo DerivedFoo { get; set; }
public Foo Foo2 { get; set; }
public DerivedFoo? DerivedFoo { get; set; }
public Foo? Foo2 { get; set; }
}

public const string SchemaAvroNotAllowNull = @"{""type"":""record"",""name"":""Foo"",""namespace"":""org.apache.pulsar.client.impl.schema.SchemaTestUtils"",""fields"":[{""name"":""field1"",""type"":[""null"",""string""]," + @"""default"":null},{""name"":""field2"",""type"":[""null"",""string""],""default"":null},{""name"":""field3"",""type"":""int""},{""name"":""field4"",""type"":[""null"",{""type"":" + @"""record"",""name"":""Bar"",""fields"":[{""name"":""field1"",""type"":""boolean""}]}],""default"":null},{""name"":""color"",""type"":[""null"",{""type"":""enum"",""name"":""Color""," + @"""symbols"":[""RED"",""BLUE""]}],""default"":null},{""name"":""fieldUnableNull"",""type"":""string"",""default"":""defaultValue""}]}";
Expand Down
2 changes: 1 addition & 1 deletion src/SharpPulsar.Test.Token/TokenTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class TokenTests
public TokenTests(ITestOutputHelper output, PulsarTokenFixture fixture)
{
_output = output;
_client = fixture.PulsarSystem.NewClient(fixture.ConfigBuilder).AsTask().GetAwaiter().GetResult();
_client = fixture.PulsarSystem?.NewClient(fixture.ConfigBuilder).AsTask().GetAwaiter().GetResult()!;
_topic = $"persistent://public/default/token-{Guid.NewGuid()}";
}

Expand Down
22 changes: 11 additions & 11 deletions src/SharpPulsar.TestContainer/PulsarFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ namespace SharpPulsar.TestContainer
{
public class PulsarFixture //: IAsyncLifetime
{
public PulsarSystem System;
public PulsarSystem? System;
private readonly IConfiguration _configuration;
public PulsarClientConfigBuilder ConfigBuilder;
public ClientConfigurationData ClientConfigurationData;
public PulsarClientConfigBuilder? ConfigBuilder;
public ClientConfigurationData? ClientConfigurationData;
public PulsarFixture()
{
var path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
var path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!;
_configuration = GetIConfigurationRoot(path);
SetupSystem();
}
Expand All @@ -37,13 +37,13 @@ public virtual void SetupSystem(string? service = null, string? web = null)
var authPluginClassName = clienConfigSetting.GetSection("authPluginClassName").Value;
var authParamsString = clienConfigSetting.GetSection("authParamsString").Value;
var authCertPath = clienConfigSetting.GetSection("authCertPath").Value;
var connectionsPerBroker = int.Parse(clienConfigSetting.GetSection("connections-per-broker").Value);
var statsInterval = TimeSpan.Parse(clienConfigSetting.GetSection("stats-interval").Value);
var operationTime = int.Parse(clienConfigSetting.GetSection("operationTime").Value);
var allowTlsInsecureConnection = bool.Parse(clienConfigSetting.GetSection("allowTlsInsecureConnection").Value);
var enableTls = bool.Parse(clienConfigSetting.GetSection("enableTls").Value);
var enableTxn = bool.Parse(clienConfigSetting.GetSection("enableTransaction").Value);
var dedicatedConnection = bool.Parse(clienConfigSetting.GetSection("userDedicatedConnection").Value);
var connectionsPerBroker = int.Parse(clienConfigSetting.GetSection("connections-per-broker").Value!);
var statsInterval = TimeSpan.Parse(clienConfigSetting.GetSection("stats-interval").Value!);
var operationTime = int.Parse(clienConfigSetting.GetSection("operationTime").Value!);
var allowTlsInsecureConnection = bool.Parse(clienConfigSetting.GetSection("allowTlsInsecureConnection").Value!);
var enableTls = bool.Parse(clienConfigSetting.GetSection("enableTls").Value!);
var enableTxn = bool.Parse(clienConfigSetting.GetSection("enableTransaction").Value!);
var dedicatedConnection = bool.Parse(clienConfigSetting.GetSection("userDedicatedConnection").Value!);


client.EnableTransaction(enableTxn);
Expand Down
25 changes: 13 additions & 12 deletions src/SharpPulsar.TestContainer/PulsarOAuthFixture.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Reflection;
using System.Security.Cryptography.X509Certificates;
using Ductus.FluentDocker.Commands;
using Microsoft.Extensions.Configuration;
using SharpPulsar.Auth.OAuth2;
using SharpPulsar.Builder;
Expand All @@ -11,14 +12,14 @@ namespace SharpPulsar.TestContainer
{
public class PulsarOAuthFixture : IAsyncLifetime
{
public PulsarClient Client;
public PulsarSystem PulsarSystem;
public PulsarClient? Client;
public PulsarSystem? PulsarSystem;
private readonly IConfiguration _configuration;

public ClientConfigurationData ClientConfigurationData;
public ClientConfigurationData? ClientConfigurationData;
public PulsarOAuthFixture()
{
var path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
var path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!;
_configuration = GetIConfigurationRoot(path);
Container = BuildContainer();
}
Expand Down Expand Up @@ -62,13 +63,13 @@ public virtual async ValueTask SetupSystem(string? service = null, string? web =
var authPluginClassName = clienConfigSetting.GetSection("authPluginClassName").Value;
var authParamsString = clienConfigSetting.GetSection("authParamsString").Value;
var authCertPath = clienConfigSetting.GetSection("authCertPath").Value;
var connectionsPerBroker = int.Parse(clienConfigSetting.GetSection("connections-per-broker").Value);
var statsInterval = TimeSpan.Parse(clienConfigSetting.GetSection("stats-interval").Value);
var operationTime = int.Parse(clienConfigSetting.GetSection("operationTime").Value);
var allowTlsInsecureConnection = bool.Parse(clienConfigSetting.GetSection("allowTlsInsecureConnection").Value);
var enableTls = bool.Parse(clienConfigSetting.GetSection("enableTls").Value);
var enableTxn = bool.Parse(clienConfigSetting.GetSection("enableTransaction").Value);
var dedicatedConnection = bool.Parse(clienConfigSetting.GetSection("userDedicatedConnection").Value);
var connectionsPerBroker = int.Parse(clienConfigSetting.GetSection("connections-per-broker").Value!);
var statsInterval = TimeSpan.Parse(clienConfigSetting.GetSection("stats-interval").Value!);
var operationTime = int.Parse(clienConfigSetting.GetSection("operationTime").Value!);
var allowTlsInsecureConnection = bool.Parse(clienConfigSetting.GetSection("allowTlsInsecureConnection").Value!);
var enableTls = bool.Parse(clienConfigSetting.GetSection("enableTls").Value!);
var enableTxn = bool.Parse(clienConfigSetting.GetSection("enableTransaction").Value!);
var dedicatedConnection = bool.Parse(clienConfigSetting.GetSection("userDedicatedConnection").Value!);


client.EnableTransaction(enableTxn);
Expand Down Expand Up @@ -137,7 +138,7 @@ private string GetConfigFilePath()
{
var configFolderName = "Oauth2Files";
var privateKeyFileName = "o-r7y4o-eabanonu.json";
var startup = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
var startup = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!;
var indexOfConfigDir = startup.IndexOf(startup, StringComparison.Ordinal);
var examplesFolder = startup.Substring(0, startup.Length - indexOfConfigDir);
var configFolder = Path.Combine(examplesFolder, configFolderName);
Expand Down
24 changes: 12 additions & 12 deletions src/SharpPulsar.TestContainer/PulsarTokenFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ public class PulsarTokenFixture : IAsyncLifetime
private const string SecretKeyPath = "/pulsar/secret.key";
private const string UserName = "test-user";
private const int Port = 6650;
public PulsarSystem PulsarSystem;
public ClientConfigurationData ClientConfigurationData;
public PulsarClientConfigBuilder ConfigBuilder;
public string Token;
public PulsarSystem? PulsarSystem;
public ClientConfigurationData? ClientConfigurationData;
public PulsarClientConfigBuilder? ConfigBuilder;
public string? Token;
private readonly IConfiguration _configuration;
private readonly IMessageSink _messageSink;
private readonly IContainerService _cluster;
public PulsarTokenFixture(IMessageSink messageSink)
{
var path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
var path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!;
_configuration = GetIConfigurationRoot(path);
_messageSink = messageSink;

Expand Down Expand Up @@ -97,13 +97,13 @@ public virtual void SetupSystem()
var authPluginClassName = clienConfigSetting.GetSection("authPluginClassName").Value;
var authParamsString = clienConfigSetting.GetSection("authParamsString").Value;
var authCertPath = clienConfigSetting.GetSection("authCertPath").Value;
var connectionsPerBroker = int.Parse(clienConfigSetting.GetSection("connections-per-broker").Value);
var statsInterval = TimeSpan.Parse(clienConfigSetting.GetSection("stats-interval").Value);
var operationTime = int.Parse(clienConfigSetting.GetSection("operationTime").Value);
var allowTlsInsecureConnection = bool.Parse(clienConfigSetting.GetSection("allowTlsInsecureConnection").Value);
var enableTls = bool.Parse(clienConfigSetting.GetSection("enableTls").Value);
var enableTxn = bool.Parse(clienConfigSetting.GetSection("enableTransaction").Value);
var dedicatedConnection = bool.Parse(clienConfigSetting.GetSection("userDedicatedConnection").Value);
var connectionsPerBroker = int.Parse(clienConfigSetting.GetSection("connections-per-broker").Value!);
var statsInterval = TimeSpan.Parse(clienConfigSetting.GetSection("stats-interval").Value!);
var operationTime = int.Parse(clienConfigSetting.GetSection("operationTime").Value!);
var allowTlsInsecureConnection = bool.Parse(clienConfigSetting.GetSection("allowTlsInsecureConnection").Value!);
var enableTls = bool.Parse(clienConfigSetting.GetSection("enableTls").Value!);
var enableTxn = bool.Parse(clienConfigSetting.GetSection("enableTransaction").Value!);
var dedicatedConnection = bool.Parse(clienConfigSetting.GetSection("userDedicatedConnection").Value!);


client.EnableTransaction(enableTxn);
Expand Down
3 changes: 1 addition & 2 deletions src/SharpPulsar/ClientCnx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,9 @@ internal sealed class ClientCnx : ReceiveActor, IWithUnboundedStash

private ICancelable _timeoutTask;

private readonly ICancelable _sendPing;
private readonly ICancelable _sendPing = default;
private readonly IActorRef _parent;
private readonly IScheduler _scheduler;
private IDisposable _subscriber;

// Added for mutual authentication.
private IAuthenticationDataProvider _authenticationDataProvider;
Expand Down
2 changes: 1 addition & 1 deletion src/SharpPulsar/ConsumerActor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ internal class ConsumerActor<T> : ConsumerActorBase<T>

private readonly bool _readCompacted;
private readonly bool _resetIncludeHead;
private readonly bool _poolMessages = false;
//private readonly bool _poolMessages = false;


private readonly ActorSystem _actorSystem;
Expand Down
3 changes: 0 additions & 3 deletions src/SharpPulsar/Exceptions/PulsarClientException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1266,9 +1266,6 @@ public RuntimeException(string message, Exception innerException) : base(message
{
}

protected RuntimeException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
}
}
}
2 changes: 1 addition & 1 deletion src/SharpPulsar/MessageRouterBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ internal abstract class MessageRouterBase : IMessageRouter
public abstract int ChoosePartition<T>(IMessage<T> msg, TopicMetadata metadata);
public abstract int ChoosePartition<T>(IMessage<T> msg);

protected internal readonly IHash Hash;
protected internal readonly IHash Hash = default;

internal MessageRouterBase(HashingScheme hashingScheme)
{
Expand Down
Loading

0 comments on commit ede7994

Please sign in to comment.