From: SourceForge.net <no...@so...> - 2007-02-22 07:38:20
|
Bugs item #1665879, was opened at 2007-02-21 23:29 Message generated for change (Comment added) made by jvaudry You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=115494&aid=1665879&group_id=15494 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: General Group: 1.0.x Status: Open Resolution: None Priority: 5 Private: No Submitted By: James Vaudry (jvaudry) Assigned to: Nobody/Anonymous (nobody) Summary: RegularTimePeriod.WORKING_CALENDAR needs synchronized access Initial Comment: In the class RegularTimePeriod.java, the WORKING_CALENDAR constant (1) should not be a constant, and (2) could also have synchronized access. If a JFreeChart is displaying TimeSeries data then no other thread in the application can create another TimeSeries object without risking random Calendar exceptions. This is quite a severe limitation, namely, that developers must restrict all TimeSeries and RegularTimePeriod object creation and usage to a single thread. It appears the WORKING_CALENDAR was programmed under the assumption that Calendar objects are not mutable. However, calendars are mutable objects and should not be used as constants, and should not carry such threading limitations. For instance, the WORKING_CALENDAR is used by the compareTo() method of the Millisecond.java class. This introduces many threading unsafe methods in the TimeSeries and RegularTimePeriod classes. For example, consider the following stack trace we see quite frequently: java.lang.ArrayIndexOutOfBoundsException: -441 at sun.util.calendar.BaseCalendar.getCalendarDateFromFixedDate(BaseCalendar.java:436) at java.util.GregorianCalendar.computeFields(GregorianCalendar.java:2080) at java.util.GregorianCalendar.computeTime(GregorianCalendar.java:2471) at java.util.Calendar.updateTime(Calendar.java:2260) at java.util.Calendar.getTimeInMillis(Calendar.java:1044) at java.util.Calendar.getTime(Calendar.java:1017) at org.jfree.data.time.Minute.getFirstMillisecond(Minute.java:253) at org.jfree.data.time.Second.getFirstMillisecond(Second.java:221) at org.jfree.data.time.RegularTimePeriod.getFirstMillisecond(RegularTimePeriod.java:204) at org.jfree.data.time.RegularTimePeriod.getFirstMillisecond(RegularTimePeriod.java:191) at org.jfree.data.time.Millisecond.getFirstMillisecond(Millisecond.java:307) at org.jfree.data.time.Millisecond.compareTo(Millisecond.java:269) at org.jfree.data.time.TimeSeriesDataItem.compareTo(TimeSeriesDataItem.java:207) at java.util.Collections.indexedBinarySearch(Collections.java:217) at java.util.Collections.binarySearch(Collections.java:203) at org.jfree.data.time.TimeSeries.addOrUpdate(TimeSeries.java:701) This stack trace is typical when one thread is adding items to TimeSeries A, while another thread is adding item to TimeSeries B. The WORKING_CALENDAR introduces a subtle bug that two different TimeSeries objects cannot be used simultaneously because they both might try to modify the same shared WORKING_CALENDAR at the same time, resulting in the above exception. ---------------------------------------------------------------------- >Comment By: James Vaudry (jvaudry) Date: 2007-02-21 23:38 Message: Logged In: YES user_id=1651919 Originator: YES Here is another similar exception, this one happens from using Millisecond and without even creating a TimeSeries object. java.lang.ArrayIndexOutOfBoundsException: -440 at sun.util.calendar.BaseCalendar.getCalendarDateFromFixedDate(Unknown Source) at java.util.GregorianCalendar.computeFields(Unknown Source) at java.util.GregorianCalendar.computeTime(Unknown Source) at java.util.Calendar.updateTime(Unknown Source) at java.util.Calendar.getTimeInMillis(Unknown Source) at java.util.Calendar.getTime(Unknown Source) at org.jfree.data.time.Minute.getFirstMillisecond(Minute.java:253) at org.jfree.data.time.Second.getFirstMillisecond(Second.java:221) at org.jfree.data.time.RegularTimePeriod.getFirstMillisecond(RegularTimePeriod.java:204) at org.jfree.data.time.RegularTimePeriod.getFirstMillisecond(RegularTimePeriod.java:191) at org.jfree.data.time.Millisecond.getFirstMillisecond(Millisecond.java:307) ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=115494&aid=1665879&group_id=15494 |