You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When trying to access an empty repeated field (e.g. to check if it's empty) an error is thrown since v. 0.10.0 (introduction of GeneratedMessage.freeze()).
Problem appears to be that the empty list doesn't get initialized as such but accessing it (even trying to check it against null) is trying to create a mutable list.
I/flutter (13339): Unsupported operation: Attempted to call createRepeatedField on a read-only message (MessageList)
I/flutter (13339):
I/flutter (13339): When the exception was thrown, this was the stack:
I/flutter (13339): #0 defaultFrozenMessageModificationHandler (file:///Users/bla/flutter/.pub-cache/hosted/pub.dartlang.org/protobuf-0.10.0/lib/src/protobuf/field_set.dart:12:5)
I/flutter (13339): #1 __ReadonlyMessageListList&MessageList&ReadonlyMessageMixin._readonly (file:///Users/bla/flutter/.pub-cache/hosted/pub.dartlang.org/protobuf-0.10.0/lib/src/protobuf/readonly_message.dart:57:37)
I/flutter (13339): #2 __ReadonlyMessageList&MessageList&ReadonlyMessageMixin.createRepeatedField (file:///Users/bla/flutter/.pub-cache/hosted/pub.dartlang.org/protobuf-0.10.0/lib/src/protobuf/readonly_message.dart:23:5)
I/flutter (13339): #3 FieldInfo._createRepeatedFieldWithType (file:///Users/bla/flutter/.pub-cache/hosted/pub.dartlang.org/protobuf-0.10.0/lib/src/protobuf/field_info.dart:139:14)
I/flutter (13339): #4 _FieldSet._getDefaultList (file:///Users/bla/flutter/.pub-cache/hosted/pub.dartlang.org/protobuf-0.10.0/lib/src/protobuf/field_set.dart:185:20)
I/flutter (13339): #5FieldSet.$getList (file:///Users/bla/flutter/.pub-cache/hosted/pub.dartlang.org/protobuf-0.10.0/lib/src/protobuf/field_set.dart:324:12)
I/flutter (13339): #6 GeneratedMessage.$_getList (file:///Users/bla/flutter/.pub-cache/hosted/pub.dartlang.org/protobuf-0.10.0/lib/src/protobuf/generated_message.dart:325:48)
I/flutter (13339): #7 MessageList.repeatedField (package:app/protos/message_list.pb.dart:55:41)
Downgrading to 0.9.1 fixes the issue.
The text was updated successfully, but these errors were encountered:
It's a bit difficult to test this without a repro, but I checked the code for 0.10 and I'm surprised that you got this stack trace because _FieldSet._getDefaultList does not call _createRepeatedFieldWithType on a frozen message: (code from 0.10 tag)
if (_isReadOnly) returnnewList.unmodifiable(const []);
So if your message is really read-only then you shouldn't get this stack trace (unless there's a but in freeze and it doesn't set the read-only flag).
In any case, 0.10 is very old and any issues with it are probably fixed so closing this issue. Please feel free to re-open (ideally with a repro) if the issue still exists.
When trying to access an empty repeated field (e.g. to check if it's empty) an error is thrown since v. 0.10.0 (introduction of GeneratedMessage.freeze()).
Problem appears to be that the empty list doesn't get initialized as such but accessing it (even trying to check it against null) is trying to create a mutable list.
I/flutter (13339): Unsupported operation: Attempted to call createRepeatedField on a read-only message (MessageList)
I/flutter (13339):
I/flutter (13339): When the exception was thrown, this was the stack:
I/flutter (13339): #0 defaultFrozenMessageModificationHandler (file:///Users/bla/flutter/.pub-cache/hosted/pub.dartlang.org/protobuf-0.10.0/lib/src/protobuf/field_set.dart:12:5)
I/flutter (13339): #1 __ReadonlyMessageListList&MessageList&ReadonlyMessageMixin._readonly (file:///Users/bla/flutter/.pub-cache/hosted/pub.dartlang.org/protobuf-0.10.0/lib/src/protobuf/readonly_message.dart:57:37)
I/flutter (13339): #2 __ReadonlyMessageList&MessageList&ReadonlyMessageMixin.createRepeatedField (file:///Users/bla/flutter/.pub-cache/hosted/pub.dartlang.org/protobuf-0.10.0/lib/src/protobuf/readonly_message.dart:23:5)
I/flutter (13339): #3 FieldInfo._createRepeatedFieldWithType (file:///Users/bla/flutter/.pub-cache/hosted/pub.dartlang.org/protobuf-0.10.0/lib/src/protobuf/field_info.dart:139:14)
I/flutter (13339): #4 _FieldSet._getDefaultList (file:///Users/bla/flutter/.pub-cache/hosted/pub.dartlang.org/protobuf-0.10.0/lib/src/protobuf/field_set.dart:185:20)
I/flutter (13339): #5 FieldSet.$getList (file:///Users/bla/flutter/.pub-cache/hosted/pub.dartlang.org/protobuf-0.10.0/lib/src/protobuf/field_set.dart:324:12)
I/flutter (13339): #6 GeneratedMessage.$_getList (file:///Users/bla/flutter/.pub-cache/hosted/pub.dartlang.org/protobuf-0.10.0/lib/src/protobuf/generated_message.dart:325:48)
I/flutter (13339): #7 MessageList.repeatedField (package:app/protos/message_list.pb.dart:55:41)
Downgrading to 0.9.1 fixes the issue.
The text was updated successfully, but these errors were encountered: