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

java.util.prefs importPreferences() throws InvalidPreferencesFormatException

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 1.4.0
    • 1.4.0
    • core-libs
    • None
    • merlin
    • x86
    • windows_nt
    • Verified

      java.util.prefs importPreferences() throws InvalidPreferencesFormatException

      jdk1.4 build 49

      Test program throws on windows:

      java.util.prefs.InvalidPreferencesFormatException: org.xml.sax.SAXParseException: Element "root" does not allow "node" here.

      On solairs: BackingStoreException thrown

      Test program:
      ---------------------------ExportImportTest.java---------------------

      import java.util.prefs.*;
      import java.util.*;
      import java.io.*;

       
      public class ExportImportTest {
          
          public static void main(String[] args) throws Exception {
         
              try {
                 Preferences userRoot = Preferences.userRoot();
                 
                 Preferences ExportImportTest01 = userRoot.node("ExportImportTest01");
                 ExportImportTest01.put("k11","v11");
                
                 File userFile = new File("user01.pfs");
                 FileOutputStream fos = new FileOutputStream(userFile);
                 ExportImportTest01.exportNode(fos);
                 fos.close();
                 userRoot.flush();
                 
                 File userFile1 = new File("user01.pfs");
                 FileInputStream fis1 = new FileInputStream(userFile1);
                 userRoot.importPreferences(fis1);
           
                 System.out.println("ExportImportTest01() Pass");
             } catch(Exception e) {
                  System.out.println("Exception thrown = " + e);
                 System.out.println("ExportImportTest01() Fail");
                 e.printStackTrace();
             }
           }
       
      }
      -------------------------result on win-------------------------
       
      H:\merlin\bugs\prefs\ExportNode>java ExportImportTest
      Exception thrown = java.util.prefs.InvalidPreferencesFormatException: org.xml.sax.SAXParseException: Element "root" does not allow "node" here.
      ExportImportTest01() Fail
      java.util.prefs.InvalidPreferencesFormatException: org.xml.sax.SAXParseException: Element "root" does not allow "node" here.
              at java.util.prefs.XmlSupport.importPreferences(../../../src/share/classes/java/util/prefs/XmlSupport.java:161)
              at java.util.prefs.Preferences.importPreferences(../../../src/share/classes/java/util/prefs/Preferences.java:1108)
              at ExportImportTest.main(ExportImportTest.java:27)
      Caused by: org.xml.sax.SAXParseException: Element "root" does not allow "node" here.
              at org.apache.crimson.parser.Parser2.error(Parser2.java:3008)
              at org.apache.crimson.parser.ValidatingParser$ChildrenValidator.consume(ValidatingParser.java:349)
              at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1298)
              at org.apache.crimson.parser.Parser2.content(Parser2.java:1695)
              at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1461)
              at org.apache.crimson.parser.Parser2.content(Parser2.java:1695)
              at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1461)
              at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:499)
              at org.apache.crimson.parser.Parser2.parse(Parser2.java:304)
              at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:433)
              at org.apache.crimson.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:173)
              at java.util.prefs.XmlSupport.load(../../../src/share/classes/java/util/prefs/XmlSupport.java:181)
              at java.util.prefs.XmlSupport.importPreferences(../../../src/share/classes/java/util/prefs/XmlSupport.java:152)
              ... 2 more
      ----------------------------------result on solaris-----------------------
      javapro:/home/pande/merlin/bugs/prefs/ExportNode 88 % java ExportImportTest
      Exception thrown = java.util.prefs.BackingStoreException: Couldn't get file lock.
      ExportImportTest01() Fail
      java.util.prefs.BackingStoreException: Couldn't get file lock.
              at java.util.prefs.FileSystemPreferences.sync(FileSystemPreferences.java:409)
              at java.util.prefs.FileSystemPreferences.flush(FileSystemPreferences.java:442)
              at ExportImportTest.main(ExportImportTest.java:23)
      Couldn't flush user prefs: java.util.prefs.BackingStoreException: Couldn't get file lock.

            kkladkosunw Konstantin Kladko (Inactive)
            spandeorcl Shantaram Pande (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: