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 36326 - When saving files, content is not writen to disk.
Summary: When saving files, content is not writen to disk.
Status: RESOLVED DUPLICATE of bug 33165
Alias: None
Product: editor
Classification: Unclassified
Component: -- Other -- (show other bugs)
Version: 3.x
Hardware: PC Windows ME/2000
: P4 blocker (vote)
Assignee: issues@editor
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-09-29 11:10 UTC by paulcarroll
Modified: 2007-11-05 13:44 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
NetBeans log file. (46.08 KB, text/plain)
2003-09-29 11:12 UTC, paulcarroll
Details

Note You need to log in before you can comment on or make changes to this bug.
Description paulcarroll 2003-09-29 11:10:46 UTC
I edit a java file, cutting & pasting really 
seems to generate this one, and the compile the 
file (F9) and get an exception saying class or 
interface expected, the error is usually located 
at the end of the source file and its the result 
of part of a method being duplicated after the 
closing bracket '}' of the class e.g.


public class Test{
    public class Tesrt(){
    }
    ..
    ..    
    ..
}//end class bracket...
    public String getErrorLogFileName(){
        if(logFile == null){
            return "";
        }
        else{
            return logFile.getAbsolutePath();
        }
    }
}
            return "";
        }
        else{
            return logFile.getAbsolutePath();
        }
    }
}
Comment 1 paulcarroll 2003-09-29 11:12:14 UTC
Created attachment 11735 [details]
NetBeans log file.
Comment 2 ehucka 2003-11-03 15:08:22 UTC
Seems like editor issue. Could you repeat any steps to reproduce it,
please?
Comment 3 paulcarroll 2003-11-03 15:51:46 UTC
---------------------------------------------------------------


dateCreated: Fri Oct 24 11:47:03 MDT 2003
type:        bug
cust_name:   Paul Carroll
cust_email:  Paul.Carroll@ericsson.com
jdcid:       paulcarroll1
status:      Waiting
category:    java
subcategory: classes_io
company:     Ericsson
release:     1.4.2
hardware:    x86
OSversion:   windows_2000
priority:    4
synopsis:    FileOutputStream (with append == false)  does not ever
write file completely
description: FULL PRODUCT VERSION :
java version "1.3.1_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_01)
Java HotSpot(TM) Client VM (build 1.3.1_01, mixed mode)

and

java version "1.4.2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-b28)
Java HotSpot(TM) Client VM (build 1.4.2-b28, mixed mode)

FULL OS VERSION :
Microsoft Windows 2000 [Version 5.00.2195] SP4

EXTRA RELEVANT SYSTEM CONFIGURATION :
ClearCase 5.0.0.1
  Patches : ClearCase_p2002.05.00-13,
ClearCase_p2002.05.00-13,
ClearCase_p2002.05.00-18

A DESCRIPTION OF THE PROBLEM :
Setup as follows:
Clearcase dynamic views mounted to Win2K machine.

I have a simple test class that generates a file (view private) on the
clearcase view and write some contents into it, then the file is
re-written with new contents (which is less that what was originally
written to the file) using FileOutputStream (append == false). The
contents of the file after it has been re-written is the new contents
with the difference of the old contents at the end of the file.First
seen this when we had our machine upgrades to Win2K SP4 from Win2K SP3
for security reasons.
The IDE I used is NetBeans 3.5.1 which I can reproduce this problem on
always but doing the same operation in JBuilder 7 the file is written ok.

If I perform the same test but this time write the file to a samba
drive the resulting file is ok?


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :

First write of file:
public class TestFile{
	public TestFile(){
		int i=0;
		i=0;
		i=1;
		i=2;
		i=3;
		i=4;
	}
}

Contents to be re-written to file are :
public class TestFile{
	public TestFile(){
		int i=0;
		i=0;
	}
}


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
public class TestFile{
	public TestFile(){
		int i=0;
		i=0;
	}
}
ACTUAL -

Resulting file is :

public class TestFile{
	public TestFile(){
		int i=0;
		i=0;
	}
}1;
		i=2;
		i=3;
		i=4;
	}
}



REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.io.*;
public class FileWriteTest {
    public static String generate(int loop){
        String old_c = "public class TestFile{\n\tpublic TestFile(){";
        old_c += "\n\t\tint i=0;";
        for(int i=0;i<loop;i++){
            old_c += "\n\t\ti="+i+";";
        }
        old_c += "\n\t}\n}";
        return old_c;
    }
    public static void doit(String filename){
        File f = new File(filename);
        if(!f.exists()){
            try{
                boolean b = f.createNewFile();
                System.out.println("File did not exist, created == "+b);
            }
            catch(IOException e){
                e.printStackTrace();
            }
        }
        OutputStream os = null;
        try{
            os =  new FileOutputStream (filename,false);
            String c = generate(5);
            os.write(c.getBytes());
            System.out.println("File contents written.");
            os.close();
            os=null;
            os =  new FileOutputStream (filename,false);
            c = generate(1);
            os.write(c.getBytes());
            os.flush();
            os.close();
            System.out.println("File contents over-written.");
        }
        catch(Throwable t){
            t.printStackTrace();
        }
        finally{
        	if(os!=null){
        		try{
        			os.close();
        		}
        		catch(Throwable t){
            		t.printStackTrace();
        		}
        	}
        }
        
    }
    public static void main(String[] args) {
        String filename = "some file on clearcase dynamic view ";
        doit(filename);
        filename = "C:/Documents and
Settings/user/Desktop/ide/TestFile.java";
        doit(filename);
    }
}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
None for NetBeans.
workaround: 
Comment 4 paulcarroll 2003-11-03 15:58:48 UTC
I did a little more poking around and found it to be a
Java/Win2K(SP4)/ClearCase interaction problem. Basically the
FileOutputStream (with 'append' set to false in the constructor) does
not empty out the file prior to writing to it resulting in the
difference being lest in the file if the new contents being written to
it are less that the original contents.....

I have a bug submitted on Java's site (still internal to the above
comments are what I submitted(a little trigger happy on the commits)
The BugId is 217556
/Paul.
Comment 5 Martin Roskanin 2003-12-03 12:38:42 UTC
The problem is connected with the the issue #33040 (look at the
exceptions in ide.log) that was duplicated to #33165.




*** This issue has been marked as a duplicate of 33165 ***