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 214092 - Unable to save JSP with characters incompatible with undeclared default encoding
Summary: Unable to save JSP with characters incompatible with undeclared default encoding
Status: VERIFIED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Data Systems (show other bugs)
Version: 7.2.1
Hardware: PC Windows 7
: P2 normal (vote)
Assignee: Svata Dedic
URL:
Keywords: REGRESSION
Depends on:
Blocks:
 
Reported: 2012-06-13 08:21 UTC by Vladimir Riha
Modified: 2012-09-26 08:00 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
sample file (741 bytes, application/octet-stream)
2012-06-13 08:21 UTC, Vladimir Riha
Details
IDE log (483.67 KB, text/plain)
2012-06-13 08:21 UTC, Vladimir Riha
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Vladimir Riha 2012-06-13 08:21:01 UTC
Created attachment 120761 [details]
sample file

When a JSP file is missing pageEncoding or contentType and it contains some for instance czech characters (diacritics), it cannot be saved. 

- To reproduce, try to save the attached sample file
- NetBeans shows warning that suggested encoding (e.g. ISO-8859-1) may break some characters, confirm it to continue saving
=> the error is shown

Sometimes a dialog window saying that the file was modified externally and asking if I want to overwrite it, is opened after the first dialog (the one with encoding warning).

Also after I add the pageEncoding or/and contentType to the "<%page", it doesn't help and the file still cannot be saved. I have to remove the diacritic characters  and then save it.



Product Version: NetBeans IDE Dev (Build 201206110001)
Java: 1.7.0_04; Java HotSpot(TM) Client VM 23.0-b21
System: Windows 7 version 6.1 running on x86; Cp1252; en_US (nb)
Comment 1 Vladimir Riha 2012-06-13 08:21:45 UTC
Created attachment 120762 [details]
IDE log
Comment 2 Vladimir Riha 2012-06-13 08:25:22 UTC
Sorry, I forgot to mention text in the error dialog:
"There were some problems while saving newjsp1.jsp. Cause: Input length=1"
Comment 3 Vladimir Riha 2012-06-26 11:27:26 UTC
Happens even if the JSP contains contentType:

<%@page contentType="text/html" contentType="text/html;charset=ISO-8859-2" info="šěšě+šáýí"%>

This file can't be saved.

Personally I think it should be fixed for 7.2
Comment 4 Vladimir Riha 2012-06-26 12:06:14 UTC
Another observation:
If you try to save the file and confirm both dialogs (first standard warning and 2nd with the "...Cause: Input length=1"), the file is unsaved. Now if you close the file (discard changes) and reopen, the file is empty!


Product Version: NetBeans IDE 7.2 RC1 (Build 201206252201)
Java: 1.7.0_06-ea; Java HotSpot(TM) Client VM 23.2-b05
System: Linux version 3.0.0-21-generic-pae running on i386; UTF-8; en_US (nb)
Comment 5 Petr Hejl 2012-06-26 20:30:40 UTC
This has been introduced by this changeset: http://hg.netbeans.org/main-silver/rev/88c8987cbaa0
Comment 6 Svata Dedic 2012-06-27 07:59:13 UTC
The trouble is that if an error happens during saveFromKitToStream (i.e. disk error, ...), the file will be truncated as well. Before the mentioned change, the file was saved, but unmappable characters were garbled: all characters not representable by the file|project character set were written as "?".

I agree that not handling the situation gracefully is even worse.
Comment 7 Petr Hejl 2012-06-27 09:27:07 UTC
(In reply to comment #6)
> The trouble is that if an error happens during saveFromKitToStream (i.e. disk
> error, ...), the file will be truncated as well. Before the mentioned change,
> the file was saved, but unmappable characters were garbled: all characters not
> representable by the file|project character set were written as "?".
FYI that was expected as dialog notified user about that just before the save.

> 
> I agree that not handling the situation gracefully is even worse.
Comment 8 Svata Dedic 2012-06-27 17:36:02 UTC
(In reply to comment #7)
> FYI that was expected as dialog notified user about that just before the save.
> 
Yes, for those DES subclasses, which take care and do the detection in their saveDocument(). Some file types do not; I believe the unsupported encoding handling should be centralized.
Comment 9 Svata Dedic 2012-06-27 19:49:55 UTC
Changeset: 03dbe99d2ae8
Author:    Svata Dedic <sdedic@netbeans.org>
Date:      2012-06-27 21:49
Message:   Issue #214092 - Unable to save JSP with characters incompatible with undeclared default encoding: fixed
Reverted back the reporting in DES; Aligned XML saveDocument() handling with the other editor supports.
Comment 10 Quality Engineering 2012-06-29 04:49:20 UTC
Integrated into 'main-golden', will be available in build *201206290002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/03dbe99d2ae8
User: Svata Dedic <sdedic@netbeans.org>
Log: Issue #214092 - Unable to save JSP with characters incompatible with undeclared default encoding: fixed
Reverted back the reporting in DES; Aligned XML saveDocument() handling with the other editor supports.
Comment 11 Vladimir Riha 2012-06-29 08:48:15 UTC
verified, thanks

Product Version: NetBeans IDE Dev (Build 201206290002)
Java: 1.7.0_05; Java HotSpot(TM) Client VM 23.1-b03
System: Linux version 3.0.0-21-generic-pae running on i386; UTF-8; en_US (nb)
Comment 12 Svata Dedic 2012-08-29 14:21:52 UTC
Transplanted as http://hg.netbeans.org/releases/rev/a3ee9eccd948
Comment 13 Quality Engineering 2012-09-01 11:08:28 UTC
Integrated into 'releases', will be available in build *201209010822* or newer. Wait for official and publicly available build.
Changeset: http://hg.netbeans.org/releases/rev/a3ee9eccd948
User: Svata Dedic <sdedic@netbeans.org>
Log: Issue #214092 - Unable to save JSP with characters incompatible with undeclared default encoding: fixed
Reverted back the reporting in DES; Aligned XML saveDocument() handling with the other editor supports.
Comment 14 Vladimir Riha 2012-09-10 06:46:43 UTC
works fine in patch1


Product Version: NetBeans IDE 7.2 (Build 201207171143)
Java: 1.7.0_07; Java HotSpot(TM) Client VM 23.3-b01
System: Linux version 3.2.0-29-generic-pae running on i386; UTF-8; en_US (nb)
Comment 15 mikey_ebor 2012-09-26 08:00:36 UTC
What seems to be this same bug caused significant data loss in the following scenario:

1. Editing a java file
2. Cut&Paste from Chrome browser some documentation that includes the &thinsp; special character into the java file
3. Save the file - message "There were some problems while saving XXX.java Cause: Input length = 1" pops up
4. File has been truncated on disk (it's possible to re-edit the file to remove the changes and re-save in the IDE, but if you instead close the IDE then everything after the offending character is gone).

For example Cut&Paste the section:

   The Distance Matrix API has the following limits in place:

   100 elements per query.
   100 elements per 10 seconds.
   2 500 elements per 24 hour period.

from this URL https://developers.google.com/maps/documentation/distancematrix/
into a java file in the IDE and press save - everything after the 2 in "2500" will be truncated on disk.

I should also note that the offending character does not show in the IDE even with View->Show Non Printable Characters selected.

Product Version: NetBeans IDE 7.2 (Build 201207171143)