File tree Expand file tree Collapse file tree 2 files changed +9
-0
lines changed
Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -79,6 +79,10 @@ class Pool {
7979 /// all pending [request] futures will throw a [TimeoutException] . This is
8080 /// intended to avoid deadlocks.
8181 Pool (this ._maxAllocatedResources, {Duration timeout}) : _timeout = timeout {
82+ if (_maxAllocatedResources <= 0 ) {
83+ throw ArgumentError ('pool limit should be > 0' );
84+ }
85+
8286 if (timeout != null ) {
8387 // Start the timer canceled since we only want to start counting down once
8488 // we've run out of available resources.
Original file line number Diff line number Diff line change @@ -436,6 +436,11 @@ void main() {
436436 completer.completeError ("oh no!" );
437437 });
438438 });
439+
440+ test ("throw error when pool limit <= 0" , () {
441+ expect (() => Pool (- 1 ), throwsArgumentError);
442+ expect (() => Pool (0 ), throwsArgumentError);
443+ });
439444}
440445
441446/// Returns a function that will cause the test to fail if it's called.
You can’t perform that action at this time.
0 commit comments