Bug 394413 - Handling 0-chars (ASCII 0x00) in Eclipse debugger or UnitTest Comparison view does not work as expected
Summary: Handling 0-chars (ASCII 0x00) in Eclipse debugger or UnitTest Comparison view...
Status: REOPENED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Debug (show other bugs)
Version: 3.8   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Debug-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2012-11-15 12:53 EST by Michael Meß CLA
Modified: 2024-04-30 19:33 EDT (History)
4 users (show)

See Also:


Attachments
Screenshot of Eclipse running UnitTest to reproduce the issue (172.48 KB, image/png)
2013-02-22 03:09 EST, Michael Meß CLA
no flags Details
Console window showing test result of failed test containing 0-character (44.58 KB, image/png)
2022-05-10 06:05 EDT, Michael Meß CLA
no flags Details
When using 01-Characters, Eclipse displays the comparison result and console output as expected (127.21 KB, image/png)
2022-05-10 06:50 EDT, Michael Meß CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Meß CLA 2012-11-15 12:53:29 EST
Steps to reproduce: Debug the following JUnit4 testcase in Eclipse:

* The test will fail: org.junit.ComparisonFailure: expected:<[xxx]> but was: <[X
	* The remaining "\0Y]>" is missing in the "Failure Trace" view.
	* Double clicking to get the "Result Comparison" window shows the same issue.
* The output of System.out.println seems to miss the rest of the String, beginning from the null byte.
* When debugging, editing char values in variables behaves strange as long as there is a \0 value inside.
* It is not possible to enter a \0 value in a char variable when debugging.

Expected behaviour:

* ASCII-0x00 characters should be displayed as \0 and following String parts should not be missing when displayed.

Test Code:

pre..

    @Test
    public void testEclipseBug() throws Exception {
        

        final String value =  "\0";
        
        
        assertEquals( 1, value.length() );
        assertEquals( 0, value.charAt( 0 ) );
        
        String logmessage = "X"+ value+"Y";
        assertEquals(3, logmessage.length());

        System.out.println( logmessage);

        assertEquals("xxx", logmessage); // This will fail. Look at the comparison view. Also use Eclipse for debugging.
    }
   
pre..
Comment 1 Michael Meß CLA 2013-02-22 03:09:41 EST
Created attachment 227438 [details]
Screenshot of Eclipse running UnitTest to reproduce the issue

Can be reproduced with Eclipse Version: 3.8.1, Build id: M20120914-1540
Comment 2 Michael Meß CLA 2013-03-22 09:45:43 EDT
Is still an issue with Eclipse SDK Version: 3.8.2 - Build id: M20130131-0800
Comment 3 Michael Meß CLA 2013-03-22 09:49:01 EDT
Hi Stephan, could you please have a look at this?
Comment 4 Eclipse Genie CLA 2020-03-07 17:36:40 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 5 Michael Meß CLA 2020-04-16 05:14:09 EDT
This is still an issue with

Eclipse IDE for Enterprise Java Developers.
Version: 2018-12 (4.10.0)
Build id: 20181214-0600

As it should be fixed, I reopen this bug.
Comment 6 Sarika Sinha CLA 2020-04-16 05:27:41 EDT
@Paul,
will you be able to look into this?
Comment 7 Eclipse Genie CLA 2022-04-07 08:05:42 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 8 Michael Meß CLA 2022-05-02 06:15:52 EDT
Did anyone even try to reproduce the issue?
Comment 9 Sarika Sinha CLA 2022-05-09 14:25:47 EDT
(In reply to Michael Meß from comment #8)
> Did anyone even try to reproduce the issue?

Yes, I tried reproducing it.
It's not only while debugging but even printing it is not handled.

System.out.println(logmessage);

It prints "XY".
Comment 10 Michael Meß CLA 2022-05-10 06:02:05 EDT
System.out.println(logmessage) seems to print only "X" in my eclipse Console.

But System.out.println(logmessage) prints all characters, even the "Y" which can be verified by executing the test on a Linux console, see Attachment. 

The 0-character is a non-printable control character which is "executed" by the console but usually does nothing.
There are other control characters which are also executed by the console and for example move the curser, delete characters, etc.

If I modify the test to use a newline ("\n"), the newline is printed in the test comparison result followed the "Y" as well as in the Console from System.out.println(logmessage), which is OK.

Maybe the eclipse Console (Probably the dialog showing the comparison result is also using something like a console to display text) uses the 0-character as a terminating character, maybe e.g. in C/C++ native method where strings usually are handled as char* terminated by 0-characters.
Comment 11 Michael Meß CLA 2022-05-10 06:05:04 EDT
Created attachment 288504 [details]
Console window showing test result of failed test containing 0-character
Comment 12 Michael Meß CLA 2022-05-10 06:50:54 EDT
Created attachment 288505 [details]
When using 01-Characters, Eclipse displays the comparison result and console output as expected
Comment 13 Eclipse Genie CLA 2024-04-30 19:33:38 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.