Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Ruby] JRuby - type of oneof is always nil after decoding #7831

Closed
TCRuys opened this issue Aug 19, 2020 · 12 comments
Closed

[Ruby] JRuby - type of oneof is always nil after decoding #7831

TCRuys opened this issue Aug 19, 2020 · 12 comments
Assignees
Labels

Comments

@TCRuys
Copy link

TCRuys commented Aug 19, 2020

What version of protobuf and what language are you using?
Version: 3.13.0
Language: Ruby

What operating system (Linux, Windows, ...) and version?
Linux Ubuntu 16.x and 18.x.

What runtime / compiler are you using (e.g., python version or gcc version)
Ruby 2.6.3 and JRuby 9.2.9.0.
But this bug is already in protobuf for JRuby for a long time...

What did you do?
Consider the following Ruby script:

require 'google/protobuf'

def assert(lhs, rhs)
  raise Exception, "#{lhs} != #{rhs}" unless lhs == rhs
end

pool = Google::Protobuf::DescriptorPool.new
pool.build do
  add_message "OneofMessage" do
    oneof :my_oneof do
      optional :a, :string, 1
      optional :b, :int32, 2
      optional :c, :bool, 3
    end
  end
end

OneofMessage = pool.lookup('OneofMessage').msgclass
m1 = OneofMessage.new
m1.b = 666
assert(m1.b, 666)
assert(m1.my_oneof, :b)

bytes = OneofMessage.encode(m1)
m2 = OneofMessage.decode(bytes)

assert(m2.b, 666)
assert(m2.my_oneof, :b)

What did you expect to see
Under Ruby this script does not report any assertion violations, as expected.

What did you see instead?
Under JRuby, the last assert fails as m2.my_oneof is nil instead of :b.
This means that for a receiver of message it is not clear which of the fields of the oneof has been set.

@TCRuys TCRuys changed the title JRuby: type of oneof is always nil after decoding [Ruby] JRuby - type of oneof is always nil after decoding Aug 19, 2020
@TeBoring TeBoring added the ruby label Aug 20, 2020
@TeBoring
Copy link
Contributor

Sorry that we haven't supported JRuby for a long time. The major reason is we don't know how to release it. @haberman shall we set it up again?

@TCRuys
Copy link
Author

TCRuys commented Aug 22, 2020

Thanks. I would really appreciate it if JRuby would get supported again. We normally use plain Ruby for our applications, but when we need to access Java libraries, we have to use JRuby instead. For these cases we also have to use the JRuby version of protobuf.

BTW, I built the google-protobuf-3.13.0-java.gem using the instructions in ./ruby/README.md.

I would not mind helping out in tracking down this bug but I do not have an idea where to start.

@vdbijl
Copy link

vdbijl commented Dec 29, 2020

Awesome work devs that we have JRuby support again!
@headius, @TeBoring is it possible to have a look at this issue again? If there's anyway we can help, just let me know.

@headius
Copy link

headius commented Dec 30, 2020

@vdbijl Are you able to try out the restored JRuby support and see if it still has the issue? I don't think this should be a hard problem to solve, but I want to make sure you have been able to reproduce it in the updated support logic.

@vdbijl
Copy link

vdbijl commented Jan 6, 2021

Hello @headius and @TeBoring, awesome news in the new year. On main the issue is indeed solved, but not yet on the released 3.14.0 gem (also not on the 4.0 release candidates btw). Do you already have an idea about when you want to release another version? We'll make a development gem to use in the mean time.

@headius
Copy link

headius commented Jan 6, 2021

I am willing to help get the JRuby support released again but I do not have any permissions for any of the relevant services. Folks that assisted getting the JRuby support restored like @rdubya might be in a better position since they are familiar with how the gem gets built.

@rdubya
Copy link

rdubya commented Jan 6, 2021

I think it was merged after 3.14 was released, so maybe this is a question for @acozzette or one of the other maintainers.

@acozzette
Copy link
Member

Let's aim for publishing a JRuby gem with the 3.15.0 release. We don't have anyone on the team who has the time and expertise to work on JRuby, so I'm afraid we will not be able to put any official support behind it, but we should at least be able to publish the gem.

@vdbijl
Copy link

vdbijl commented Jan 6, 2021

@acozzette awesome thanks! AFAICT if there's anyone with Ruby knowledge on the team, they can also make the JRuby version of the gem.
And of course, if we can help, just let me know. We built the JRuby version of the gem locally.

And a big thank you to everyone that fixed this bug!

@vdbijl
Copy link

vdbijl commented Jan 6, 2021

@rdubya thanks for your help, I just found your pull request: #7923

@TCRuys
Copy link
Author

TCRuys commented Jan 7, 2021

Yes, it seems that the oneof problem in JRuby has been solved by the JRuby commits by @rdubya in December. Thanks! Unfortunately, the JRuby version of google-protobuf still has some problems. See #8191.

@haberman
Copy link
Member

Closing per the last update from @TCRuys .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants