Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6967684

httpserver using a non thread-safe SimpleDateFormat

    Details

    • Subcomponent:
    • Resolved In Build:
      b102
    • CPU:
      generic
    • OS:
      generic
    • Verification:
      Not verified

      Description

      sun.net.httpserver.ExchangeImpl uses a static SimpleDateFormat to format dates for the 'Date:' header. SimpleDateFormat is not thread-safe and using it in this manner can cause problems in the date generated.

      This issue causes some (many) of the httpserver regression tests to fail when run with system assertions enabled. The assertion failure is in the GregorianCalendar code. Example:

      TEST: com/sun/net/httpserver/Test12.java
      JDK under test: (/java/re/jdk/1.7.0/promoted/ea/b98/binaries/linux-amd64)
      java version "1.7.0-ea"
      Java(TM) SE Runtime Environment (build 1.7.0-ea-b98)
      Java HotSpot(TM) 64-Bit Server VM (build 19.0-b02, mixed mode)

      ACTION: build -- Passed. All files up to date
      REASON: Named class compiled on demand
      TIME: 0.004 seconds
      messages:
      command: build Test12
      reason: Named class compiled on demand
      elapsed time (seconds): 0.004

      ACTION: main -- Failed. Execution failed: `main' threw exception: java.lang.AssertionError: cache control: not normalized
      REASON: User specified action: run main/othervm Test12
      TIME: 1.241 seconds
      messages:
      command: main Test12
      reason: User specified action: run main/othervm Test12
      elapsed time (seconds): 1.241
      STDOUT:
      Test12:
      STDERR:
      java.lang.AssertionError: cache control: not normalized
      at java.util.GregorianCalendar.computeFields(GregorianCalendar.java:2081)
      at java.util.GregorianCalendar.computeFields(GregorianCalendar.java:2013)
      at java.util.Calendar.setTimeInMillis(Calendar.java:1126)
      at java.util.Calendar.setTime(Calendar.java:1092)
      at java.text.SimpleDateFormat.format(SimpleDateFormat.java:893)
      at java.text.SimpleDateFormat.format(SimpleDateFormat.java:886)
      at java.text.DateFormat.format(DateFormat.java:336)
      at sun.net.httpserver.ExchangeImpl.sendResponseHeaders(ExchangeImpl.java:209)
      at sun.net.httpserver.HttpExchangeImpl.sendResponseHeaders(HttpExchangeImpl.java:86)
      at FileServerHandler.handle(FileServerHandler.java:125)
      at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:83)
      at sun.net.httpserver.AuthFilter.doFilter(AuthFilter.java:83)
      at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:86)
      at sun.net.httpserver.ServerImpl$Exchange$LinkHandler.handle(ServerImpl.java:586)
      at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:83)
      at sun.net.httpserver.ServerImpl$Exchange.run(ServerImpl.java:558)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
      at java.lang.Thread.run(Thread.java:717)
      STATUS:Failed.`main' threw exception: java.lang.AssertionError: cache control: not normalized

      TEST RESULT: Failed. Execution failed: `main' threw exception: java.lang.AssertionError: cache control: not normalized

        Attachments

          Activity

            People

            • Assignee:
              chegar Chris Hegarty
              Reporter:
              chegar Chris Hegarty
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: