Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-1988

DatePicker is not thread-safe

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 1.3.5
    • Fix Version/s: 1.4-RC2
    • Component/s: wicket-datetime
    • Labels:
      None

      Description

      DatePicker uses 2 SimpleDateFormats as static final fields. That causes random failures under load because SimpleDateFormat is not thread-safe. From its javadocs: "Date formats are not synchronized. It is recommended to create separate format instances for each thread. If multiple threads access a format concurrently, it must be synchronized externally."

      For example:
      18:34:06,214 (TP-Processor3) ERROR [org.apache.wicket.RequestCycle] - Exception in rendering component: [MarkupContainer [Component id = _header_0]]
      org.apache.wicket.WicketRuntimeException: Exception in rendering component: [MarkupContainer [Component id = _header_0]]
      at org.apache.wicket.Component.renderComponent(Component.java:2519)
      at org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1411)
      at org.apache.wicket.Component.render(Component.java:2317)
      at org.apache.wicket.MarkupContainer.autoAdd(MarkupContainer.java:223)
      at org.apache.wicket.markup.resolver.HtmlHeaderResolver.resolve(HtmlHeaderResolver.java:78)
      at org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1324)
      at org.apache.wicket.MarkupContainer.renderAll(MarkupContainer.java:1427)
      at org.apache.wicket.Page.onRender(Page.java:1470)
      at org.apache.wicket.Component.render(Component.java:2317)
      at org.apache.wicket.Page.renderPage(Page.java:904)
      at org.apache.wicket.request.target.component.BookmarkablePageRequestTarget.respond(BookmarkablePageRequestTarget.java:231)
      at org.apache.wicket.request.AbstractRequestCycleProcessor.respond(AbstractRequestCycleProcessor.java:104)
      at org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1181)
      at org.apache.wicket.RequestCycle.step(RequestCycle.java:1252)
      at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1353)
      at org.apache.wicket.RequestCycle.request(RequestCycle.java:493)
      at org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:355)
      at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:200)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at com.huitale.marketplace.security.SessionHijackingFilter.doFilter(SessionHijackingFilter.java:51)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
      at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:190)
      at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:283)
      at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:767)
      at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:697)
      at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:889)
      at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:690)
      at java.lang.Thread.run(Thread.java:619)
      Caused by: java.lang.ArrayIndexOutOfBoundsException: 14
      at sun.util.calendar.BaseCalendar.getCalendarDateFromFixedDate(BaseCalendar.java:436)
      at java.util.GregorianCalendar.computeFields(GregorianCalendar.java:2081)
      at java.util.GregorianCalendar.computeFields(GregorianCalendar.java:1996)
      at java.util.Calendar.setTimeInMillis(Calendar.java:1104)
      at java.util.Calendar.setTime(Calendar.java:1070)
      at java.text.SimpleDateFormat.format(SimpleDateFormat.java:859)
      at java.text.SimpleDateFormat.format(SimpleDateFormat.java:852)
      at java.text.DateFormat.format(DateFormat.java:316)
      at org.apache.wicket.extensions.yui.calendar.DatePicker.configure(DatePicker.java:390)
      at org.apache.wicket.extensions.yui.calendar.DateTimeField$1.configure(DateTimeField.java:128)
      at org.apache.wicket.extensions.yui.calendar.DatePicker.renderHead(DatePicker.java:224)
      at org.apache.wicket.Component.renderHead(Component.java:2568)
      at org.apache.wicket.markup.html.internal.HtmlHeaderContainer$1.component(HtmlHeaderContainer.java:220)
      at org.apache.wicket.MarkupContainer.visitChildren(MarkupContainer.java:829)
      at org.apache.wicket.MarkupContainer.visitChildren(MarkupContainer.java:844)
      at org.apache.wicket.MarkupContainer.visitChildren(MarkupContainer.java:844)
      at org.apache.wicket.MarkupContainer.visitChildren(MarkupContainer.java:869)
      at org.apache.wicket.markup.html.internal.HtmlHeaderContainer.renderHeaderSections(HtmlHeaderContainer.java:211)
      at org.apache.wicket.markup.html.internal.HtmlHeaderContainer.onComponentTagBody(HtmlHeaderContainer.java:136)
      at org.apache.wicket.Component.renderComponent(Component.java:2480)
      ... 35 more

      happens because one internal SimpleDateFormat's field changes while the class is formatting a date.

        Attachments

          Activity

            People

            • Assignee:
              jdonnerstag Juegen Donnerstag
              Reporter:
              robyf Roberto Fasciolo
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: