Skip to content

pool_connection.zk.reopen not working with JRuby #99

@raphaelhetzel

Description

@raphaelhetzel

Hi,
i'm trying to reopen a connection from a pool in case of a ZK::Exceptions::ConnectionLoss error like described in #92.

I assume that i have to call reopen on connection.zk when using the pool.with_lock { |connection| } method.

However, this does not work with JRuby. Is this an issue with the gem or am i doing something wrong here?

require "bundler/inline"

gemfile true do
  source "https://rubygems.org" do
    gem "zk", "1.9.6"
  end
end
require "zk"

pool = ZK::Pool::Bounded.new(
  "127.0.0.1:2181",
  chroot:      "/test",
  timeout:     1,
  min_clients: 1,
  max_clients: 2
)

opts = { wait: 1 }

pool.with_lock("1234", opts) do |connection|
    puts connection.zk.connected?
    connection.zk.close!
    puts connection.zk.connected?
    puts connection.zk.reopen.inspect
    puts connection.zk.connected?
end

JRuby 9.1.12.0:

true
false
:connecting
false

Waiting longer for the client to be connected yields the same result.

MRI 2.3.3:

true
false
:connected
true

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions