dart-archive / observe

Support for marking objects as observable, and getting notifications when those objects are mutated
https://pub.dartlang.org/packages/observe
BSD 3-Clause "New" or "Revised" License
13 stars 6 forks source link

Null exception thrown in changeNotifier after it creates the object which should not make it null #69

Open DartBot opened 9 years ago

DartBot commented 9 years ago

Originally opened as dart-lang/sdk#20536

This issue was originally filed by ir...@google.com


What steps will reproduce the problem?

  1. Execute code that invokes ChangeNotifier.changes
  2. In certain cases, the following exception is produced:

The null object does not have a getter 'stream'.

NoSuchMethodError: method not found: 'stream' Receiver: null Arguments: []

STACKTRACE:

­0 Object.noSuchMethod (dart:core-patch/object_patch.dart:45)

­1 ChangeNotifier.changes (package:observe/src/change_notifier.dart:29:21)

For reference, line 24-30 from change_notifier.dart:

  Stream<List<ChangeRecord>> get changes {     if (_changes == null) {       _changes = new StreamController.broadcast(sync: true,           onListen: observed, onCancel: unobserved);     }     return _changes.stream;   }

What is the expected output? What do you see instead? _changes should never be null, so no exception should be thrown.

What version of the product are you using? Dartium Version 37.0.2062.0 (287872) (64-bit)

On what operating system? Linux

What browser (if applicable)? Dartium Version 37.0.2062.0 (287872) (64-bit)

Please provide any additional information below.

C1

DartBot commented 9 years ago

Comment by floitschG


Added Area-Pkg, Pkg-Observe, Triaged labels.

DartBot commented 9 years ago

Comment by jakemac53


Hmm, this is really weird. Is it possible for you to attach a repro of this?

Technically, StreamController.broadcast is a factory method and as such could return a null I believe (although this would be bad practice imo since factories and constructors appear identical in dart). However in reality it looks like it does not do that...