Skip to content

Commit bfad443

Browse files
Eh processor fix (Azure#34813)
* Fix nullref in EventProcessorClient * Changelog * PR fb * Fix date * fix
1 parent bb956cf commit bfad443

File tree

6 files changed

+89
-16
lines changed

6 files changed

+89
-16
lines changed

sdk/eventhub/Azure.Messaging.EventHubs.Processor/CHANGELOG.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
# Release History
22

3-
## 5.9.0-beta.1 (Unreleased)
4-
5-
### Features Added
6-
7-
### Breaking Changes
3+
## 5.8.1 (2023-03-09)
84

95
### Bugs Fixed
106

11-
### Other Changes
7+
- Fix null reference exception when using the `EventProcessorClient`.
128

139
## 5.8.0 (2023-03-07)
1410

sdk/eventhub/Azure.Messaging.EventHubs.Processor/src/Azure.Messaging.EventHubs.Processor.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<Description>Azure Event Hubs is a highly scalable publish-subscribe service that can ingest millions of events per second and stream them to multiple consumers. This library extends its Event Processor with durable storage for checkpoint information using Azure Blob storage. For more information about Event Hubs, see https://azure.microsoft.com/en-us/services/event-hubs/</Description>
4-
<Version>5.9.0-beta.1</Version>
4+
<Version>5.8.1</Version>
55
<!--The ApiCompatVersion is managed automatically and should not generally be modified manually.-->
66
<ApiCompatVersion>5.8.0</ApiCompatVersion>
77
<PackageTags>Azure;Event Hubs;EventHubs;.NET;Event Processor;EventProcessor;$(PackageCommonTags)</PackageTags>

sdk/eventhub/Azure.Messaging.EventHubs.Processor/src/EventProcessorClient.cs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ public event Func<ProcessErrorEventArgs, Task> ProcessErrorAsync
345345
/// The client diagnostics for this processor.
346346
/// </summary>
347347
///
348-
private MessagingClientDiagnostics ClientDiagnostics { get; }
348+
internal MessagingClientDiagnostics ClientDiagnostics { get; }
349349

350350
/// <summary>
351351
/// Initializes a new instance of the <see cref="EventProcessorClient" /> class.
@@ -463,6 +463,12 @@ public EventProcessorClient(BlobContainerClient checkpointStore,
463463

464464
_containerClient = checkpointStore;
465465
CheckpointStore = new BlobCheckpointStoreInternal(checkpointStore);
466+
ClientDiagnostics = new MessagingClientDiagnostics(
467+
DiagnosticProperty.DiagnosticNamespace,
468+
DiagnosticProperty.ResourceProviderNamespace,
469+
DiagnosticProperty.EventHubsServiceContext,
470+
FullyQualifiedNamespace,
471+
EventHubName);
466472
}
467473

468474
/// <summary>
@@ -492,6 +498,12 @@ public EventProcessorClient(BlobContainerClient checkpointStore,
492498

493499
_containerClient = checkpointStore;
494500
CheckpointStore = new BlobCheckpointStoreInternal(checkpointStore);
501+
ClientDiagnostics = new MessagingClientDiagnostics(
502+
DiagnosticProperty.DiagnosticNamespace,
503+
DiagnosticProperty.ResourceProviderNamespace,
504+
DiagnosticProperty.EventHubsServiceContext,
505+
FullyQualifiedNamespace,
506+
EventHubName);
495507
}
496508

497509
/// <summary>
@@ -521,6 +533,12 @@ public EventProcessorClient(BlobContainerClient checkpointStore,
521533

522534
_containerClient = checkpointStore;
523535
CheckpointStore = new BlobCheckpointStoreInternal(checkpointStore);
536+
ClientDiagnostics = new MessagingClientDiagnostics(
537+
DiagnosticProperty.DiagnosticNamespace,
538+
DiagnosticProperty.ResourceProviderNamespace,
539+
DiagnosticProperty.EventHubsServiceContext,
540+
FullyQualifiedNamespace,
541+
EventHubName);
524542
}
525543

526544
/// <summary>
@@ -550,6 +568,12 @@ public EventProcessorClient(BlobContainerClient checkpointStore,
550568

551569
_containerClient = checkpointStore;
552570
CheckpointStore = new BlobCheckpointStoreInternal(checkpointStore);
571+
ClientDiagnostics = new MessagingClientDiagnostics(
572+
DiagnosticProperty.DiagnosticNamespace,
573+
DiagnosticProperty.ResourceProviderNamespace,
574+
DiagnosticProperty.EventHubsServiceContext,
575+
FullyQualifiedNamespace,
576+
EventHubName);
553577
}
554578

555579
/// <summary>

sdk/eventhub/Azure.Messaging.EventHubs.Processor/tests/Processor/EventProcessorClientTests.cs

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,20 @@ void assertOptionsMatch(EventProcessorOptions expected,
181181
actualOptions = GetBaseOptions(processorClient);
182182
assertOptionsMatch(expectedOptions, actualOptions, description);
183183

184+
// SAS constructor
185+
186+
description = "{{ SAS constructor }}";
187+
processorClient = new EventProcessorClient(Mock.Of<BlobContainerClient>(), "consumerGroup", "namespace", "theHub", new AzureSasCredential(new SharedAccessSignature("sb://this.is.Fake/blah", "key", "value").Value), clientOptions);
188+
actualOptions = GetBaseOptions(processorClient);
189+
assertOptionsMatch(expectedOptions, actualOptions, description);
190+
191+
// Named Key constructor
192+
193+
description = "{{ Named Key constructor }}";
194+
processorClient = new EventProcessorClient(Mock.Of<BlobContainerClient>(), "consumerGroup", "namespace", "theHub", new AzureNamedKeyCredential("fakeName", "fakeKey"), clientOptions);
195+
actualOptions = GetBaseOptions(processorClient);
196+
assertOptionsMatch(expectedOptions, actualOptions, description);
197+
184198
// Internal testing constructor (Token)
185199

186200
description = "{{ internal testing constructor (Token) }}";
@@ -206,6 +220,49 @@ void assertOptionsMatch(EventProcessorOptions expected,
206220
assertOptionsMatch(expectedOptions, actualOptions, description);
207221
}
208222

223+
[Test]
224+
public void ConstructorsSetClientDiagnostics()
225+
{
226+
// Connection String constructor
227+
228+
EventProcessorClient processorClient = new EventProcessorClient(Mock.Of<BlobContainerClient>(), "consumerGroup", "Endpoint=sb://somehost.com;SharedAccessKeyName=ABC;SharedAccessKey=123;EntityPath=somehub", default(EventProcessorClientOptions));
229+
Assert.IsNotNull(processorClient.ClientDiagnostics, "The diagnostics should have been set.");
230+
231+
// Connection String and Event Hub Name constructor
232+
233+
processorClient = new EventProcessorClient(Mock.Of<BlobContainerClient>(), "consumerGroup", "Endpoint=sb://somehost.com;SharedAccessKeyName=ABC;SharedAccessKey=123", "theHub", default(EventProcessorClientOptions));
234+
Assert.IsNotNull(processorClient.ClientDiagnostics, "The diagnostics should have been set.");
235+
236+
// Namespace constructor
237+
238+
processorClient = new EventProcessorClient(Mock.Of<BlobContainerClient>(), "consumerGroup", "namespace", "theHub", Mock.Of<TokenCredential>(), default(EventProcessorClientOptions));
239+
Assert.IsNotNull(processorClient.ClientDiagnostics, "The diagnostics should have been set.");
240+
241+
// SAS constructor
242+
243+
processorClient = new EventProcessorClient(Mock.Of<BlobContainerClient>(), "consumerGroup", "namespace", "theHub", new AzureSasCredential(new SharedAccessSignature("sb://this.is.Fake/blah", "key", "value").Value), default(EventProcessorClientOptions));
244+
Assert.IsNotNull(processorClient.ClientDiagnostics, "The diagnostics should have been set.");
245+
246+
// Named Key constructor
247+
248+
processorClient = new EventProcessorClient(Mock.Of<BlobContainerClient>(), "consumerGroup", "namespace", "theHub", new AzureNamedKeyCredential("fakeName", "fakeKey"), default(EventProcessorClientOptions));
249+
Assert.IsNotNull(processorClient.ClientDiagnostics, "The diagnostics should have been set.");
250+
251+
// Internal testing constructor (Token)
252+
253+
processorClient = new EventProcessorClient(Mock.Of<CheckpointStore>(), "consumerGroup", "namespace", "theHub", 100, Mock.Of<TokenCredential>(), default(EventProcessorOptions));
254+
Assert.IsNotNull(processorClient.ClientDiagnostics, "The diagnostics should have been set.");
255+
// Internal testing constructor (Shared Key)
256+
257+
processorClient = new EventProcessorClient(Mock.Of<CheckpointStore>(), "consumerGroup", "namespace", "theHub", 100, new AzureNamedKeyCredential("key", "value"), default(EventProcessorOptions));
258+
Assert.IsNotNull(processorClient.ClientDiagnostics, "The diagnostics should have been set.");
259+
260+
// Internal testing constructor (SAS)
261+
262+
processorClient = new EventProcessorClient(Mock.Of<CheckpointStore>(), "consumerGroup", "namespace", "theHub", 100, new AzureSasCredential(new SharedAccessSignature("sb://this.is.Fake/blah", "key", "value").Value), default(EventProcessorOptions));
263+
Assert.IsNotNull(processorClient.ClientDiagnostics, "The diagnostics should have been set.");
264+
}
265+
209266
/// <summary>
210267
/// Verifies functionality of the <see cref="EventProcessorClient.StartProcessingAsync" />
211268
/// and <see cref="EventProcessorClient.StartProcessing" /> methods.

sdk/eventhub/Azure.Messaging.EventHubs/CHANGELOG.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
# Release History
22

3-
## 5.9.0-beta.1 (Unreleased)
4-
5-
### Features Added
6-
7-
### Breaking Changes
8-
9-
### Bugs Fixed
3+
## 5.8.1 (2023-03-09)
104

115
### Other Changes
126

7+
- Upgrading dependency on `Azure.Core` library.
8+
139
## 5.8.0 (2023-03-07)
1410

1511
### Features Added

sdk/eventhub/Azure.Messaging.EventHubs/src/Azure.Messaging.EventHubs.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<Description>Azure Event Hubs is a highly scalable publish-subscribe service that can ingest millions of events per second and stream them to multiple consumers. This client library allows for both publishing and consuming events using Azure Event Hubs. For more information about Event Hubs, see https://azure.microsoft.com/en-us/services/event-hubs/</Description>
4-
<Version>5.9.0-beta.1</Version>
4+
<Version>5.8.1</Version>
55
<!--The ApiCompatVersion is managed automatically and should not generally be modified manually.-->
66
<ApiCompatVersion>5.8.0</ApiCompatVersion>
77
<PackageTags>Azure;Event Hubs;EventHubs;.NET;AMQP;IoT;$(PackageCommonTags)</PackageTags>

0 commit comments

Comments
 (0)