This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 117778 - Wrong implementation of FileEncodingQuery
Summary: Wrong implementation of FileEncodingQuery
Status: RESOLVED FIXED
Alias: None
Product: xml
Classification: Unclassified
Component: Code (show other bugs)
Version: 6.x
Hardware: All All
: P2 blocker (vote)
Assignee: Samaresh Panda
URL:
Keywords:
: 117767 (view as bug list)
Depends on:
Blocks: 115278 117333
  Show dependency tree
 
Reported: 2007-10-04 13:46 UTC by Tomas Zezula
Modified: 2007-10-19 17:22 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Patch (9.93 KB, patch)
2007-10-04 13:55 UTC, Tomas Zezula
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tomas Zezula 2007-10-04 13:46:46 UTC
Wrong implementation of FileEncodingQuery for XML data object. The current implementation does not work for saving when
the encoding shouldn't be read from a file but rather from a document (the encoding may be changed in the saved xml
document).
Comment 1 Tomas Zezula 2007-10-04 13:54:18 UTC
Here is the patch which should solve the problem and also should avoid double open of file, which is expensive.
Unfortunately I didn't find a test for XML file encoding query, I wasn't able to test it.
Comment 2 Tomas Zezula 2007-10-04 13:55:52 UTC
Created attachment 50179 [details]
Patch
Comment 3 Tomas Zezula 2007-10-04 14:00:34 UTC
Most of the code of the patch comes from FileEncodingQueryTest (project/queries), but I didn't test it much, I only
tried to open and save xml files containing Czech letters in different encodings. The patch should be well tested on
both JDK 5 and JDK6 before commit (stream encoder has changed in JDK 6).
Comment 4 Petr Pisl 2007-10-04 14:11:14 UTC
Please, fix this issue ASAP. Unfortunately it blocks some issue, which has to be solved. 
Comment 5 Tomas Zezula 2007-10-04 14:25:10 UTC
The patch also fixes the issue #117767
Comment 6 Samaresh Panda 2007-10-05 21:04:18 UTC
*** Issue 117767 has been marked as a duplicate of this issue. ***
Comment 7 Tomas Zezula 2007-10-08 18:09:53 UTC
Checking in nbproject/project.xml;
/cvs/xml/core/nbproject/project.xml,v  <--  project.xml
new revision: 1.16; previous revision: 1.15
done
Checking in src/org/netbeans/modules/xml/api/XmlFileEncodingQueryImpl.java;
/cvs/xml/core/src/org/netbeans/modules/xml/api/XmlFileEncodingQueryImpl.java,v  <--  XmlFileEncodingQueryImpl.java
new revision: 1.7; previous revision: 1.6
done
RCS file: /cvs/xml/core/test/unit/src/org/netbeans/modules/xml/api/XmlFileEncodingQueryImplTest.java,v
done
Checking in test/unit/src/org/netbeans/modules/xml/api/XmlFileEncodingQueryImplTest.java;
/cvs/xml/core/test/unit/src/org/netbeans/modules/xml/api/XmlFileEncodingQueryImplTest.java,v  <-- 
XmlFileEncodingQueryImplTest.java
initial revision: 1.1
done
RCS file: /cvs/xml/core/test/unit/src/org/netbeans/modules/xml/api/data/data.properties,v
done
Checking in test/unit/src/org/netbeans/modules/xml/api/data/data.properties;
/cvs/xml/core/test/unit/src/org/netbeans/modules/xml/api/data/data.properties,v  <--  data.properties
initial revision: 1.1
done
RCS file: /cvs/xml/core/test/unit/src/org/netbeans/modules/xml/api/data/long_encoding.xml,v
done
Checking in test/unit/src/org/netbeans/modules/xml/api/data/long_encoding.xml;
/cvs/xml/core/test/unit/src/org/netbeans/modules/xml/api/data/long_encoding.xml,v  <--  long_encoding.xml
initial revision: 1.1
done
RCS file: /cvs/xml/core/test/unit/src/org/netbeans/modules/xml/api/data/long_no_encoding.xml,v
done
Checking in test/unit/src/org/netbeans/modules/xml/api/data/long_no_encoding.xml;
/cvs/xml/core/test/unit/src/org/netbeans/modules/xml/api/data/long_no_encoding.xml,v  <--  long_no_encoding.xml
initial revision: 1.1
done
RCS file: /cvs/xml/core/test/unit/src/org/netbeans/modules/xml/api/data/short_encoding.xml,v
done
Checking in test/unit/src/org/netbeans/modules/xml/api/data/short_encoding.xml;
/cvs/xml/core/test/unit/src/org/netbeans/modules/xml/api/data/short_encoding.xml,v  <--  short_encoding.xml
initial revision: 1.1
done
RCS file: /cvs/xml/core/test/unit/src/org/netbeans/modules/xml/api/data/short_no_encoding.xml,v
done
Checking in test/unit/src/org/netbeans/modules/xml/api/data/short_no_encoding.xml;
/cvs/xml/core/test/unit/src/org/netbeans/modules/xml/api/data/short_no_encoding.xml,v  <--  short_no_encoding.xml
initial revision: 1.1
done
Comment 8 Ken Frank 2007-10-19 16:59:10 UTC
whats a scenario that can be used for verifying this issue ?

ken.frank@sun.com
Comment 9 Tomas Zezula 2007-10-19 17:22:04 UTC
I think the scenario was following:
 Project has one encoding (ISO-8859-1)
 XML file has other encoding (UTF-8) defined by encoding attribute
 In the NetBeans editor open the XML file and in the editor change the encoding to UTF-16 and save it.
The file was saved in UTF-8 or ISO-8859 depending on the OS.
Erno, Am I right?