Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 505990

Summary: Oomph fails to save preference for JDT UI (Java - Editor - Content-Assist - Advanced)
Product: [Tools] Oomph Reporter: Silvestre Martins <sraul.martins>
Component: Preferences ManagementAssignee: Ed Merks <Ed.Merks>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P3    
Version: 1.6.0   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
error screenshot none

Description Silvestre Martins CLA 2016-10-14 10:12:01 EDT
When we have Preference Recording enabled, if we edit any of the following preferences, Oomph will fail to save them:
content_assist_category_order
content_assist_disabled_computers

I'm using Eclipse Neon with JDT 3.12.1.v20160907-1200

The problem seems to be related with invalid characters that are written into XML format.

I did some further investigation, and I found that the preference is saved with this format:
content_assist_category_order=org.eclipse.jdt.ui.templateProposalCategory\:0\u0000org.eclipse.jdt.ui.swtProposalCategory\:65536

Then in the JDT UI plugin the preference is read and parsed using the StringTokenizer with "\0" delimiter.
See http://grepcode.com/file/repository.grepcode.com/java/eclipse.org/4.2/org.eclipse.jdt/ui/3.8.0/org/eclipse/jdt/internal/ui/text/java/CompletionProposalComputerRegistry.java#CompletionProposalComputerRegistry.getCategories%28java.util.List%29

I think the problem happens when Oomph tries to write this in XML format, since the "\0" symbol is an invalid XML character.

IMO Oomph should be able to escape such characters in order so support these preferences, or JDT UI plugin should change the delimiter to an XML supported character. 
In fact, I really don't understand why it's using the null character "\0" as a delimiter, when it could use any other regular character, such as ";"
Comment 1 Silvestre Martins CLA 2016-10-14 10:22:35 EDT
Created attachment 264863 [details]
error screenshot
Comment 2 Ed Merks CLA 2016-10-14 11:35:33 EDT
The fix is committed to master:

http://git.eclipse.org/c/oomph/org.eclipse.oomph.git/commit/?id=14117af743facf98a9d6dc2b6dcd9017849cb915

We didn't properly convert control characters to escape them.  In the end, even with XML 1.1, which can save control characters as entities, the 0x0 character cannot be saved in any XML version.   These values should be getting saved as something like this:
  
  org.eclipse.jdt.ui.javaNoTypeProposalCategory${0x0}org.eclipse.jdt.ui.textProposalCategory${0x0}

These will be variable expanded to the appropriate underlying control character before the preference task applies the value to the preference.