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

Bug 429895

Summary: File is mangled on save
Product: [ECD] Orion Reporter: Boris Kozorovitzky <majorzbzzn>
Component: EditorAssignee: Silenio Quarti <Silenio_Quarti>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P3 CC: gheorghe, john.arthorne, ken_walker, mamacdon, meloandroid0, xinyij
Version: 5.0Keywords: triaged
Target Milestone: ---Flags: Silenio_Quarti: review? (john.arthorne)
Hardware: PC   
OS: Linux   
See Also: https://git.eclipse.org/r/76023
https://git.eclipse.org/r/76025
https://git.eclipse.org/c/orion/org.eclipse.orion.server.git/commit/?id=5b18711889d728b737d3b1200d8f16fd3c906693
https://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=894a9de9da5ffd62b701e17f6af7201e614da3c0
Whiteboard:
Attachments:
Description Flags
The problematic file and the animated gif of the issue
none
possible patch
none
Possible patch for node side none

Description Boris Kozorovitzky CLA 2014-03-07 12:02:50 EST
Created attachment 240661 [details]
The problematic file and the animated gif of the issue

When saving a specific file, some of the characters don't get saved properly.
I asked Mark and he suggested to switch off the Diff Save from the settings, it fixed the issue.

I attach the affected file and a reproduction of the bug (animated gif)
Comment 1 Boris Kozorovitzky CLA 2014-03-07 12:11:01 EST
Sorry, incorrect severity
Comment 2 Boris Kozorovitzky CLA 2014-03-07 12:11:53 EST
Updated Importance
Comment 3 Silenio Quarti CLA 2014-03-07 13:37:08 EST
Bogdan, this is happening on the node fileClient. It works fine for me in the orion fileClient.
Comment 4 Mark Macdonald CLA 2014-03-07 13:56:05 EST
Boris originally reported this issue on IRC. I was able to reproduce it by accessing his server, which was running Orion Node.

But I can reproduce this against orion.eclipse.org as well:
* Import game.js using drag & drop in Orion navigator
* Ensure auto save: ON, auto load: ON, save as diff: ON
* Open game.js
* Make some changes, save
* Reload file. File is mangled.

One possibly important thing to note is that game.js is UTF-8 encoded and begins with a BOM.
Comment 5 Silenio Quarti CLA 2014-03-07 14:30:21 EST
The BOM is not included in the string on the client side, but it is on the server side awhile applying the diffs.
Comment 6 Silenio Quarti CLA 2014-03-11 12:34:36 EDT
Created attachment 240763 [details]
possible patch

This patch removes the BOM character before applying the changes to the file.  It also changes the encoding used to read the file into memory to UTF-8.
Comment 7 Silenio Quarti CLA 2014-03-11 12:41:35 EDT
John, please could you review this patch?  There might be other places where we need to handle the BOM character.  IOUtilities.toString(InputStream) for example.

Another solution would be to use the wrapper BOMInputStream from Apache Common IO.
Comment 8 Bogdan Gheorghe CLA 2014-03-11 16:01:37 EDT
I have a corresponding patch for Orion Node which I'll put in if John is OK with the approach taken.
Comment 9 Bogdan Gheorghe CLA 2014-03-21 10:50:09 EDT
Created attachment 241101 [details]
Possible patch for node side
Comment 10 Melo .. CLA 2015-11-26 04:02:44 EST
Hi,

¿This issue is not solved yet? I have Orion version 9.0 installed and have the same problem when save twig files (the template engine) of my project.

If I switch off the Diff Save from the settings as suggested works well.

Thanks
Comment 11 John Arthorne CLA 2015-11-26 11:28:42 EST
I tried to reproduce this with Mark's steps in comment #4 and the game.js from Boris, and I cannot reproduce. It looks like this is already fixed. Please reopen or enter a new bug if there is still a problem.
Comment 12 Eclipse Genie CLA 2016-06-27 12:31:19 EDT
New Gerrit change created: https://git.eclipse.org/r/76023
Comment 13 Eclipse Genie CLA 2016-06-27 12:37:25 EDT
New Gerrit change created: https://git.eclipse.org/r/76025
Comment 14 Silenio Quarti CLA 2016-06-27 12:52:31 EDT
This is still happening.
Comment 17 Silenio Quarti CLA 2016-06-27 13:21:11 EDT
fixed
Comment 18 Silenio Quarti CLA 2016-06-27 22:13:31 EDT
*** Bug 496353 has been marked as a duplicate of this bug. ***