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

BC: method BeanContextSuport.setLocale(null) works wrong

    • b28
    • generic, sparc
    • generic, solaris_2.5, solaris_2.6
    • Verified



      Name: sdC67446 Date: 10/07/98


      There is an inconsistensy exists in class
      java.beans.beancontext.BeanContextSupport.
      BeanContextSupport.setLocale(Locale locale) and ctor
      BeanContextSupport(BeanContext bc, Locale locale) handle 'locale' ==
      null differently.
      Consequent call of getLocale() after calling ctor
      BeanContextSupport(bc, null) returns Locale.getDefault()
      Consequent call of getLocale() after calling method setLocale(null)
      returns null.

      The doc says:
      -------------------------------------------------------------
      public BeanContextSupport(BeanContext peer,
                                Locale lcle)

            Create an instance using the specified locale
            Parameters:
                  peer - The peer BeanContext we are supplying
                         an implementation for, if null
                         the this object is its own peer
                  lcle - The current Locale for this BeanContext.

      public void setLocale(Locale newLocale)
                     throws PropertyVetoException

            Parameters:
                  newLocale - the new locale

      public Locale getLocale()

            Returns:
                  the current Locale of the BeanContext

      The test demonstrating the bug:
      ------------------------------------------------------------
      import java.beans.beancontext.*;
      import java.beans.*;
      import java.util.Locale;

      public class Test {
        
          public static void main(String[] args) {
              BeanContextSupport dummyBcs = new BeanContextSupport();
              BeanContextSupport bcs = new BeanContextSupport(dummyBcs,null);
              try {
                  System.out.println(bcs.getLocale());
      bcs.setLocale(null);
                  System.out.println(bcs.getLocale());
              } catch (NullPointerException e) {
                  System.out.println(e);
              } catch (PropertyVetoException e) {
                  System.out.println(e);
              }
          }
      }
      Test output:
      ------------------------------------------------------------
      en
      null
      ------------------------------------------------------------
       
      ======================================================================

            mdavidsosunw Mark Davidson (Inactive)
            sdmitriesunw Sergei Dmitriev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: