protobuf 2.4.0-java → 2.4.1-java

Sign up to get free protection for your applications and to get access to all the features.
@@ -160,16 +160,24 @@ module Protobuf
160
160
 
161
161
  def each_field_for_serialization
162
162
  all_fields.each do |field|
163
- next unless has_field_or_required_field?(field)
163
+ next unless has_field?(field.name) || field.required?
164
164
 
165
- value = __send__(field.name)
166
- value.compact! if field.repeated?
165
+ value = @values[field.name]
167
166
 
168
- if value.present? || [true, false].include?(value)
169
- yield(field, value)
170
- else
171
- # Only way you can get here is if you are required and not present
172
- raise ::Protobuf::SerializationError, "#{field.name} is required on #{field.message_class}"
167
+ if field.repeated?
168
+ if !value.nil?
169
+ value.compact!
170
+ @values[field.name] = nil if value.empty?
171
+ end
172
+ end
173
+
174
+ if has_field?(field.name) || field.required?
175
+ if value.present? || [true, false].include?(value)
176
+ yield(field, value)
177
+ else
178
+ # Only way you can get here is if you are required and not present
179
+ raise ::Protobuf::SerializationError, "#{field.name} is required on #{field.message_class}"
180
+ end
173
181
  end
174
182
  end
175
183
  end
@@ -339,10 +347,6 @@ module Protobuf
339
347
  object
340
348
  end
341
349
 
342
- def has_field_or_required_field?(field)
343
- has_field?(field.name) || field.required?
344
- end
345
-
346
350
  # Encode key and value, and write to +stream+.
347
351
  def write_pair(stream, field, value)
348
352
  key = (field.tag << 3) | field.wire_type
@@ -1,4 +1,4 @@
1
1
  module Protobuf
2
- VERSION = '2.4.0'
2
+ VERSION = '2.4.1'
3
3
  PROTOC_VERSION = '2.4.1'
4
4
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: protobuf
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 2.4.0
5
+ version: 2.4.1
6
6
  platform: java
7
7
  authors:
8
8
  - BJ Neilsen