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 184310 - Random wrong encoding in any editor on restoring project (IDE start)
Summary: Random wrong encoding in any editor on restoring project (IDE start)
Status: RESOLVED FIXED
Alias: None
Product: projects
Classification: Unclassified
Component: Generic Infrastructure (show other bugs)
Version: 6.x
Hardware: PC All
: P3 normal (vote)
Assignee: Vladimir Voskresensky
URL:
Keywords:
: 152975 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-04-15 22:19 UTC by HTD
Modified: 2010-04-21 04:32 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description HTD 2010-04-15 22:19:24 UTC
Product Version = NetBeans IDE Dev (Build nbms-and-javadoc-5070-on-100412)
Operating System = Windows 7 version 6.1 running on x86
Java; VM; Vendor = 1.6.0_18
Runtime = Java HotSpot(TM) Client VM 16.0-b13

I start IDE with opened PHP project. Last opened file has UTF-8 encoding. Opened after IDE restart it contains invalid characters, reopening the file helps. Writing the file irreversibly breaks it (all non-ASCII characters are replaced by invalid ones). Problem existed with older versions of NB too.
Comment 1 Vitezslav Stejskal 2010-04-19 06:48:07 UTC
Most likely FileOwnerQuery fails to find the project at the time when the editor is opened. I'm not sure where the problem lies or how exactly it should be fixed. Maybe, opening editors should wait until all projects are opened.
Comment 2 Jesse Glick 2010-04-19 16:57:18 UTC
I need steps to reproduce the problem from scratch in order to have any hope of diagnosing the bug.
Comment 3 Vladimir Voskresensky 2010-04-19 17:01:23 UTC
*** Bug 152975 has been marked as a duplicate of this bug. ***
Comment 4 Vladimir Voskresensky 2010-04-19 17:04:20 UTC
I think you need:
- close IDE with big list of opened projects
- and opened file with non UT
- and Welcome page should be disabled
=> during "Opening Projects..." phase no project yet is loaded, but file is already opened and incorrect encoding is used

I think we shouldn't wait till project is completely opened. It's better to remember encodings of opened files instead
Comment 5 Vladimir Voskresensky 2010-04-19 17:05:06 UTC
Bug 152975 has some details
Comment 6 Jesse Glick 2010-04-19 20:40:32 UTC
There is only one way I can reproduce such a problem: on Linux (UTF-8 default encoding), made a j2seproject, set enc to windows-1250, created an external dir and set it as an extra source root, made a class in that source root containing 'int řehoř;' and saved it (stored on disk as if 'int øehoø;' in ISO-8859-1, as expected), closed project, reopened that file using File > Recent File, restarted IDE with editor window open, and saw it as 'int øehoø;'. (The main window title also failed to show the project name with that editor window focused.)

It seems that SimpleFileOwnerQueryImplementation.serialize works correctly but the preferences are not persisted because the IDE is shut down too soon afterward; that can be corrected by having it also flush preferences: core-main #dcf8db9adf82

(Might be cleaner to have NbPreferences flush itself at shutdown, but I was unable to get this to work using Runtime.addShutdownHook; nothing happened unless I ran in a debugger in which case it was fine.)

If others know of other problems which can be reproduced in the Java IDE, please file them separately with complete steps to reproduce from scratch.
Comment 7 Quality Engineering 2010-04-21 04:32:41 UTC
Integrated into 'main-golden', will be available in build *201004210200* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/dcf8db9adf82
User: Jesse Glick <jglick@netbeans.org>
Log: #184310: flush preferences after serializing external owners.