FULL PRODUCT VERSION : java version "1.5.0_06" Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05) Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode, sharing) ADDITIONAL OS VERSION INFORMATION : Microsoft Windows XP [Version 5.1.2600] EXTRA RELEVANT SYSTEM CONFIGURATION : Service Pack 2 CPU: Pentium 4 3.00GHz RAM: 1G A DESCRIPTION OF THE PROBLEM : If we open exclusive locked doc(MS-WORD) file with microsoft word and then word doesn't display proper lock message. For several tens of seconds microsoft word is waiting and then issue error message(not lock message). But doc file is locked by another native application and then microsoft word issue proper lock message. This problem happens to all microsoft office application(excel,powerpoint,word). STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : 1. Create microsoft office word document. 2. Do exclusive Lock on a doc file 3. Open locked doc file with microsoft word EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - Microsoft word issue proper lock message immediately ACTUAL - For several tens of seconds microsoft word is waiting and then issue error message(not lock message). ERROR MESSAGES/STACK TRACES THAT OCCUR : no error message REPRODUCIBILITY : This bug can be reproduced always. ---------- BEGIN SOURCE ---------- import java.io.File; import java.io.RandomAccessFile; import java.nio.channels.FileChannel; import java.nio.channels.FileLock; public class TestLock { public TestLock(){ } public void lock(String path){ try{ File file = new File(path); RandomAccessFile afile = new RandomAccessFile(file,"rw"); FileChannel channel = afile.getChannel(); FileLock lock = channel.tryLock(); try { if(lock !=null){ // waiting until user input System.in.read(new byte[10]); } } finally { if(lock !=null){ lock.release(); } } } catch(Exception ex){ ex.printStackTrace(); } } public static void main(String[] args){ TestLock test = new TestLock(); test.lock(args[0]); } } ---------- END SOURCE ----------
|