Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
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.
-
- sample code
require 'thread'
- sample code
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
-
- 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)
- stack trace