Skip to content

Remove 'leaps of faith' from our constructors #119

@pitr-ch

Description

@pitr-ch

As discussed in #102, assigning ivars in #initialize method does not guarantee their visibility. Following synchronization pattern should be used under JRuby.

  require 'jruby'
  def synchronize
    JRuby.reference0(self).synchronized { yield }
  end

  def initialize
    synchronize do
      # body of the constructor ...
    end
  end

  def a_method
    synchronize do
      # body of a_method ...
    end
  end

Metadata

Metadata

Assignees

Labels

bugA bug in the library or documentation.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions