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

BufferedWriter.lineSeparator member should be private static

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Duplicate
    • Icon: P5 P5
    • None
    • 1.4.2
    • core-libs
    • x86
    • windows_2000



      Name: jl125535 Date: 03/23/2004


      A DESCRIPTION OF THE REQUEST :
      Class: java.net.URLEncoder

      uses

      Class: java.io.BufferedWriter

      which has the following line in the constructor.

      lineSeparator = (String) java.security.AccessController.doPrivileged(
                     new sun.security.action.GetPropertyAction("line.separator"));

      I am thinking that the lineSeparator should be defined as STATIC variable in the class and it should be initialized once to avoid subsequenct security check and duplicate read on a hashtable (which has synchronized get() method).

      JUSTIFICATION :
      We are having significant performance issue when trying to use URLEncoder and we found that multiple threads are trying to System.getProperty("line.separator") from BufferedWriter (System.getProperty() is reading from a Hashtable and it has a synchronized get(), thus causing huge performance issue for us).

      Is it possible for you to get the line.separator as a private static variable and gets it value only once instead of getting it during every object creation.
      (Incident Review ID: 192587)
      ======================================================================

            jccollet Jean-Christophe Collet (Inactive)
            jleesunw Jon Lee (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: