-
Bug
-
Resolution: Fixed
-
P3
-
5.0
-
b17
-
x86
-
linux
FULL PRODUCT VERSION :
java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux unununium 2.4.21-20.EL #1 Wed Aug 18 20:58:25 EDT 2004 i686 i686 i386 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
In java 1.4.x, when an imported preferences file was exported the original formatting (line feeds and indentation) was retained. In java 5.0 all whitespace is eliminated from exported preferences. You end up with two lines of text. The first has the xml header, and document type element. The next line has the preferences element. This makes the file virtually unreadable by humans.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the sample code included below. You also need a nicely formated preferences file named prefs.xml located in your current working directory. Here is an example of one:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE preferences SYSTEM 'http://java.sun.com/dtd/preferences.dtd'>
<preferences EXTERNAL_XML_VERSION="1.0">
<root type="user">
<map>
<entry key="key1" value="value1" />
</map>
<node name="test">
<map>
<entry key="key2" value="value2" />
</map>
<node name="test">
<map>
<entry key="key3" value="value3" />
</map>
</node>
</node>
</root>
</preferences>
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
After running PrefsTest I would expect prefs_after.xml to look pretty much like prefs.xml. In java 1.4.2 there are a couple extra blank lines added, but otherwise the files are identicle:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE preferences SYSTEM 'http://java.sun.com/dtd/preferences.dtd'>
<preferences EXTERNAL_XML_VERSION="1.0">
<root type="user">
<map>
<entry key="key1" value="value1" />
</map>
<node name="test">
<map>
<entry key="key2" value="value2" />
</map>
<node name="test">
<map>
<entry key="key3" value="value3" />
</map>
</node>
</node>
</root>
</preferences>
ACTUAL -
In java 5.0 we lose all formatting, and prefs_after.xml looks like this:
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE preferences SYSTEM "http://java.sun.com/dtd/preferences.dtd">
<preferences EXTERNAL_XML_VERSION="1.0"><root type="user"><map><entry key="key1" value="value1"/></map><node name="test"><map><entry key="key2" value="value2"/></map><node name="test"><map><entry key="key3" value="value3"/></map></node></node></root></preferences>
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.io.*;
import java.util.prefs.*;
public class PrefsTest
{
public static void main(String[] args)
{
try
{
Preferences.importPreferences( new FileInputStream( "prefs.xml" ) );
Preferences.userRoot().exportSubtree( new FileOutputStream( "prefs_after.xml" ) );
}
catch( Exception e )
{
e.printStackTrace();
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
I have exportSubtree() output to a ByteArrayOutputStream, parse the resulting string, and wrote my own code that reformats the xml into something human readable.
Release Regression From : 1.4.2
The above release value was the last known release where this
bug was known to work. Since then there has been a regression.
java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux unununium 2.4.21-20.EL #1 Wed Aug 18 20:58:25 EDT 2004 i686 i686 i386 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
In java 1.4.x, when an imported preferences file was exported the original formatting (line feeds and indentation) was retained. In java 5.0 all whitespace is eliminated from exported preferences. You end up with two lines of text. The first has the xml header, and document type element. The next line has the preferences element. This makes the file virtually unreadable by humans.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the sample code included below. You also need a nicely formated preferences file named prefs.xml located in your current working directory. Here is an example of one:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE preferences SYSTEM 'http://java.sun.com/dtd/preferences.dtd'>
<preferences EXTERNAL_XML_VERSION="1.0">
<root type="user">
<map>
<entry key="key1" value="value1" />
</map>
<node name="test">
<map>
<entry key="key2" value="value2" />
</map>
<node name="test">
<map>
<entry key="key3" value="value3" />
</map>
</node>
</node>
</root>
</preferences>
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
After running PrefsTest I would expect prefs_after.xml to look pretty much like prefs.xml. In java 1.4.2 there are a couple extra blank lines added, but otherwise the files are identicle:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE preferences SYSTEM 'http://java.sun.com/dtd/preferences.dtd'>
<preferences EXTERNAL_XML_VERSION="1.0">
<root type="user">
<map>
<entry key="key1" value="value1" />
</map>
<node name="test">
<map>
<entry key="key2" value="value2" />
</map>
<node name="test">
<map>
<entry key="key3" value="value3" />
</map>
</node>
</node>
</root>
</preferences>
ACTUAL -
In java 5.0 we lose all formatting, and prefs_after.xml looks like this:
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE preferences SYSTEM "http://java.sun.com/dtd/preferences.dtd">
<preferences EXTERNAL_XML_VERSION="1.0"><root type="user"><map><entry key="key1" value="value1"/></map><node name="test"><map><entry key="key2" value="value2"/></map><node name="test"><map><entry key="key3" value="value3"/></map></node></node></root></preferences>
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.io.*;
import java.util.prefs.*;
public class PrefsTest
{
public static void main(String[] args)
{
try
{
Preferences.importPreferences( new FileInputStream( "prefs.xml" ) );
Preferences.userRoot().exportSubtree( new FileOutputStream( "prefs_after.xml" ) );
}
catch( Exception e )
{
e.printStackTrace();
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
I have exportSubtree() output to a ByteArrayOutputStream, parse the resulting string, and wrote my own code that reformats the xml into something human readable.
Release Regression From : 1.4.2
The above release value was the last known release where this
bug was known to work. Since then there has been a regression.