Skip to content

Commit 26d3e78

Browse files
committed
fix ca1816
1 parent 1ce5a04 commit 26d3e78

File tree

1 file changed

+30
-6
lines changed

1 file changed

+30
-6
lines changed

src/KubernetesClient/ByteBuffer.cs

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public class ByteBuffer : IDisposable
3434
/// more data is available.
3535
/// </summary>
3636
private bool endOfFile;
37+
private bool disposedValue;
3738

3839
/// <summary>
3940
/// Initializes a new instance of the <see cref="ByteBuffer"/> class using the default buffer size and limit.
@@ -145,12 +146,6 @@ public int AvailableWritableBytes
145146
}
146147
}
147148

148-
/// <inheritdoc/>
149-
public void Dispose()
150-
{
151-
ArrayPool<byte>.Shared.Return(this.buffer);
152-
}
153-
154149
/// <summary>
155150
/// Writes bytes to the buffer.
156151
/// </summary>
@@ -307,5 +302,34 @@ private void Grow(int size)
307302
Debug.Assert(this.bytesRead + this.AvailableReadableBytes == this.bytesWritten);
308303
this.OnResize?.Invoke(this, EventArgs.Empty);
309304
}
305+
306+
protected virtual void Dispose(bool disposing)
307+
{
308+
if (!disposedValue)
309+
{
310+
if (disposing)
311+
{
312+
ArrayPool<byte>.Shared.Return(this.buffer);
313+
}
314+
315+
// TODO: free unmanaged resources (unmanaged objects) and override finalizer
316+
// TODO: set large fields to null
317+
disposedValue = true;
318+
}
319+
}
320+
321+
// // TODO: override finalizer only if 'Dispose(bool disposing)' has code to free unmanaged resources
322+
// ~ByteBuffer()
323+
// {
324+
// // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
325+
// Dispose(disposing: false);
326+
// }
327+
328+
public void Dispose()
329+
{
330+
// Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
331+
Dispose(disposing: true);
332+
GC.SuppressFinalize(this);
333+
}
310334
}
311335
}

0 commit comments

Comments
 (0)