jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • JRuby
  • JRUBY-332

Time#strftime should be thread-safe

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: JRuby 0.9.2
  • Component/s: None
  • Labels:
    None

Description

Time#strftime is not thread-safe.

    1. sample code
      require 'thread'

time = Time.new

th1 = Thread.start {
while(true)
time.strftime('%y-%m-%d')
end
}
th2 = Thread.start {
while(true)
time.strftime('%y-%m-%d')
end
}

th1.join
th2.join

    1. stack trace
      org.jruby.util.RubyDateFormat.format(RubyDateFormat.java:247): java.lang.NullPointerException: null (NativeException)
      from java.text.DateFormat.format(Unknown Source)
      from org.jruby.RubyTime.strftime(RubyTime.java:139)
      from sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      from sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      from sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      from java.lang.reflect.Method.invoke(Unknown Source)
      from org.jruby.internal.runtime.methods.ReflectedMethod.internalCall(ReflectedMethod.java:101)
      from org.jruby.internal.runtime.methods.AbstractMethod.call(AbstractMethod.java:58)
      ... 56 levels...
      from org.jruby.internal.runtime.RubyNativeThread.run(RubyNativeThread.java:76)
      from ../../tmp.rb:9
      from :-1:in `start'
      Complete Java stackTrace
      java.lang.NullPointerException
      at org.jruby.util.RubyDateFormat.format(RubyDateFormat.java:247)
      at java.text.DateFormat.format(Unknown Source)
      at org.jruby.RubyTime.strftime(RubyTime.java:139)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.jruby.internal.runtime.methods.ReflectedMethod.internalCall(ReflectedMethod.java:101)
      at org.jruby.internal.runtime.methods.AbstractMethod.call(AbstractMethod.java:58)
      at org.jruby.RubyObject.callMethod(RubyObject.java:379)
      at org.jruby.RubyObject.callMethod(RubyObject.java:331)
      at org.jruby.evaluator.EvaluationState.evalInternal(EvaluationState.java:480)
      at org.jruby.evaluator.EvaluationState.evalInternal(EvaluationState.java:1568)
      at org.jruby.evaluator.EvaluationState.eval(EvaluationState.java:133)
      at org.jruby.internal.runtime.methods.EvaluateCallable.internalCall(EvaluateCallable.java:68)
      at org.jruby.internal.runtime.methods.AbstractCallable.call(AbstractCallable.java:64)
      at org.jruby.runtime.ThreadContext.yieldInternal(ThreadContext.java:660)
      at org.jruby.runtime.ThreadContext.yieldSpecificBlock(ThreadContext.java:635)
      at org.jruby.runtime.Block.call(Block.java:158)
      at org.jruby.RubyProc.call(RubyProc.java:118)
      at org.jruby.RubyProc.call(RubyProc.java:104)
      at org.jruby.internal.runtime.RubyNativeThread.run(RubyNativeThread.java:76)

Activity

  • All
  • Comments
  • Work Log
  • History
  • Activity
There are no comments yet on this issue.

People

  • Assignee:
    Ola Bini
    Reporter:
    TAKAI Naoto
Vote (0)
Watch (1)

Dates

  • Created:
    06/Dec/06 9:05 AM
    Updated:
    30/Apr/07 3:14 AM
    Resolved:
    06/Dec/06 10:37 AM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.