diff --git a/ext/java/org/jruby/ext/stringio/StringIO.java b/ext/java/org/jruby/ext/stringio/StringIO.java index 532f771..9d2a20a 100644 --- a/ext/java/org/jruby/ext/stringio/StringIO.java +++ b/ext/java/org/jruby/ext/stringio/StringIO.java @@ -1356,8 +1356,6 @@ public IRubyObject seek(ThreadContext context, IRubyObject arg0, IRubyObject arg } private RubyFixnum seekCommon(ThreadContext context, int argc, IRubyObject arg0, IRubyObject arg1) { - checkModifiable(); - Ruby runtime = context.runtime; IRubyObject whence = context.nil; @@ -1367,10 +1365,10 @@ private RubyFixnum seekCommon(ThreadContext context, int argc, IRubyObject arg0, whence = arg1; } - checkOpen(); - StringIOData ptr = this.getPtr(); + checkOpen(); + boolean locked = lock(context, ptr); try { switch (whence.isNil() ? 0 : RubyNumeric.num2int(whence)) { diff --git a/test/stringio/test_stringio.rb b/test/stringio/test_stringio.rb index 8d236e5..a00e7b8 100644 --- a/test/stringio/test_stringio.rb +++ b/test/stringio/test_stringio.rb @@ -483,6 +483,11 @@ def test_seek f.close unless f.closed? end + def test_seek_frozen_string + f = StringIO.new(-"1234") + assert_equal(0, f.seek(1)) + end + def test_each_byte f = StringIO.new("1234") a = []