Skip to content
This repository has been archived by the owner on Apr 30, 2021. It is now read-only.

Commit

Permalink
Merge pull request #139 from bjorg/MTP-557
Browse files Browse the repository at this point in the history
MTP-557 TimedAccumulator<T> calls handler with null on Dispose() when there are no items in the accumulator.
  • Loading branch information
bjorg committed Jul 2, 2015
2 parents d71fcd4 + c364d92 commit 9bf42cf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
4 changes: 0 additions & 4 deletions src/mindtouch.dream/dream/dreammessage.cs
Expand Up @@ -848,10 +848,6 @@ public DreamMessage(DreamStatus status, DreamHeaders headers, MimeType contentTy
_bytes = ((MemoryStream)_stream).ToArray();
_stream = null;
_streamOpen = false;
} else if(_stream is MemoryStream) {
_bytes = ((MemoryStream)_stream).ToArray();
_stream = null;
_streamOpen = false;
} else {

// NOTE: the content-length and body length may differ (e.g. HEAD verb)
Expand Down
11 changes: 5 additions & 6 deletions src/mindtouch.dream/system/Collections/TimedAccumulator.cs
Expand Up @@ -87,9 +87,7 @@ public class TimedAccumulator<T> : IDisposable {
dispatch = ExtractItems(_items, _maxItems);
}
}
if(dispatch != null) {
CallHandler(dispatch);
}
CallHandler(dispatch);
}

public void Dispose() {
Expand All @@ -110,6 +108,9 @@ public class TimedAccumulator<T> : IDisposable {
}

private void CallHandler(IEnumerable<T> items) {
if(items.NullOrEmpty()) {
return;
}
try {
_handler(items);
} catch(Exception e) {
Expand All @@ -127,9 +128,7 @@ public class TimedAccumulator<T> : IDisposable {
lock(_items) {
dispatch = ExtractItems(_items, _items.Count);
}
if(dispatch != null) {
CallHandler(dispatch);
}
CallHandler(dispatch);
}
}
}

0 comments on commit 9bf42cf

Please sign in to comment.