Skip to content

Commit

Permalink
Port necessary QuietDispose requests on Publications/Subscriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
JPWatson committed Apr 23, 2018
1 parent bd0341a commit 8accb02
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/Adaptive.Aeron/Counter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public virtual long RegistrationId()
/// This method is idempotent.
/// </para>
/// </summary>
public virtual void Close()
public override void Dispose()
{
if (null != clientConductor)
{
Expand Down
4 changes: 1 addition & 3 deletions src/Adaptive.Agrona/CloseHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@

namespace Adaptive.Agrona
{
public class CloseHelper
public static class CloseHelper
{
// Note Olivier: this is not really relevant in .NET since .Dispose should never throw but we want to keep the implementation close to the Java codebase

/// <summary>
/// Quietly close a <seealso cref="IDisposable"/> dealing with nulls and exceptions.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Adaptive.Agrona/Concurrent/Status/AtomicCounter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public long GetWeak()
/// <summary>
/// Free the counter slot for reuse.
/// </summary>
public void Dispose()
public virtual void Dispose()
{
if (!IsClosed)
{
Expand Down
18 changes: 9 additions & 9 deletions src/Adaptive.Archiver/AeronArchive.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ internal AeronArchive(Context ctx)
recordingDescriptorPoller =
new RecordingDescriptorPoller(subscription, FRAGMENT_LIMIT, controlSessionId);
}
catch (Exception ex)
catch (Exception)
{
if (!ctx.OwnsAeronClient())
{
Expand All @@ -89,7 +89,7 @@ internal AeronArchive(Context ctx)

CloseHelper.QuietDispose(ctx);

throw ex;
throw;
}
}

Expand Down Expand Up @@ -198,11 +198,11 @@ public static AsyncConnect ConnectAsync(Context ctx)
{
if (!ctx.OwnsAeronClient())
{
subscription?.Dispose();
publication?.Dispose();
CloseHelper.QuietDispose(subscription);
CloseHelper.QuietDispose(publication);
}

ctx.Dispose();
CloseHelper.QuietDispose(ctx);

throw;
}
Expand Down Expand Up @@ -326,7 +326,7 @@ public Publication AddRecordedPublication(string channel, int streamId)
}
catch (Exception)
{
publication?.Dispose();
CloseHelper.QuietDispose(publication);
throw;
}
finally
Expand Down Expand Up @@ -359,7 +359,7 @@ public ExclusivePublication AddRecordedExclusivePublication(string channel, int
}
catch (Exception)
{
publication?.Dispose();
CloseHelper.QuietDispose(publication);
throw;
}
finally
Expand Down Expand Up @@ -505,7 +505,7 @@ public long StartReplay(long recordingId, long position, long length, string rep
if (!archiveProxy.Replay(recordingId, position, length, replayChannel, replayStreamId, correlationId,
controlSessionId))
{
throw new System.InvalidOperationException("failed to send replay request");
throw new InvalidOperationException("failed to send replay request");
}

return PollForResponse(correlationId);
Expand All @@ -529,7 +529,7 @@ public void StopReplay(long replaySessionId)

if (!archiveProxy.StopReplay(replaySessionId, correlationId, controlSessionId))
{
throw new System.InvalidOperationException("failed to send stop recording request");
throw new InvalidOperationException("failed to send stop recording request");
}

PollForResponse(correlationId);
Expand Down
2 changes: 1 addition & 1 deletion src/Adaptive.Cluster/Service/ClusteredServiceContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1101,7 +1101,7 @@ public void DeleteDirectory()
/// </summary>
public void Dispose()
{
markFile?.Dispose();
CloseHelper.QuietDispose(markFile);

if (ownsAeronClient)
{
Expand Down

0 comments on commit 8accb02

Please sign in to comment.