Name: boT120536 Date: 01/31/2001
unable youn(submitted against Solaris)
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0)
Java HotSpot(TM) Client VM (build 1.3.0, mixed mode)
With Java 2 SDK 1.3 on Solaris 7, a program (all threads) will be suspended
when one of the threads blocks on closing an NFS mounted file which has
temporarily become unavailable (e.g. the other machine is rebooted).
To reproduce the problem, share a drive on machineB, NFS mount that drive
on machineA, then replace the string "/machineB/log/badfile" in the following
test program with the correct path, then compile and run the program. The
program's main thread will be writing to System.err while another thread
will be writing files to the mounted drive. Reboot machineB, you will see
that the program will also stop writing to System.err. When machineB comes
back up, the writing to System.err will resume but you can see a gap between
the timestamps. This problem only occurs in 1.3. Running the same program
under JDK1.1.7 of 1.2.2_05a, the main thread will not get suspended.
import java.io.*;
import java.util.*;
import java.text.SimpleDateFormat;
public class TestNFS
{
public static SimpleDateFormat df =
new SimpleDateFormat("MM/dd/yyyy HH:mm:ss:SSS zz");
private static class BadThread implements Runnable
{
public BadThread() {}
public void run()
{
String str = "This is a stupid string:";
BufferedOutputStream writer = null;
try
{
String fname = "/machineB/log/badfile";
FileOutputStream fs = new FileOutputStream(fname);
writer = new BufferedOutputStream(fs);
int i = 0;
while (true)
{
String s = df.format(new Date()) + " " + i++ + "\n";
writer.write(s.getBytes());
writer.flush();
if ((i % 100) == 0) {
String n = fname + i;
System.err.println("Closing ...");
writer.close();
System.err.println("opening ...");
writer = new BufferedOutputStream(new FileOutputStream(n));
System.err.println("after opening ...");
}
Thread.currentThread().sleep(100);
}
}
catch (Exception e)
{
e.printStackTrace();
}
if (writer != null)
{
try
{
writer.flush();
writer.close();
}
catch (Exception e)
{
System.err.println("error on flushing/closing");
}
}
}
}
public static void main(String args[])
{
Thread t = new Thread(new BadThread());
t.start();
BufferedOutputStream bw = null;
while (true)
{
try
{
String s = "I am awake " + df.format(new Date()) + "\n";
System.err.println(s);
Thread.currentThread().sleep(100);
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
}
}
(Review ID: 111486)
======================================================================
unable youn(submitted against Solaris)
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0)
Java HotSpot(TM) Client VM (build 1.3.0, mixed mode)
With Java 2 SDK 1.3 on Solaris 7, a program (all threads) will be suspended
when one of the threads blocks on closing an NFS mounted file which has
temporarily become unavailable (e.g. the other machine is rebooted).
To reproduce the problem, share a drive on machineB, NFS mount that drive
on machineA, then replace the string "/machineB/log/badfile" in the following
test program with the correct path, then compile and run the program. The
program's main thread will be writing to System.err while another thread
will be writing files to the mounted drive. Reboot machineB, you will see
that the program will also stop writing to System.err. When machineB comes
back up, the writing to System.err will resume but you can see a gap between
the timestamps. This problem only occurs in 1.3. Running the same program
under JDK1.1.7 of 1.2.2_05a, the main thread will not get suspended.
import java.io.*;
import java.util.*;
import java.text.SimpleDateFormat;
public class TestNFS
{
public static SimpleDateFormat df =
new SimpleDateFormat("MM/dd/yyyy HH:mm:ss:SSS zz");
private static class BadThread implements Runnable
{
public BadThread() {}
public void run()
{
String str = "This is a stupid string:";
BufferedOutputStream writer = null;
try
{
String fname = "/machineB/log/badfile";
FileOutputStream fs = new FileOutputStream(fname);
writer = new BufferedOutputStream(fs);
int i = 0;
while (true)
{
String s = df.format(new Date()) + " " + i++ + "\n";
writer.write(s.getBytes());
writer.flush();
if ((i % 100) == 0) {
String n = fname + i;
System.err.println("Closing ...");
writer.close();
System.err.println("opening ...");
writer = new BufferedOutputStream(new FileOutputStream(n));
System.err.println("after opening ...");
}
Thread.currentThread().sleep(100);
}
}
catch (Exception e)
{
e.printStackTrace();
}
if (writer != null)
{
try
{
writer.flush();
writer.close();
}
catch (Exception e)
{
System.err.println("error on flushing/closing");
}
}
}
}
public static void main(String args[])
{
Thread t = new Thread(new BadThread());
t.start();
BufferedOutputStream bw = null;
while (true)
{
try
{
String s = "I am awake " + df.format(new Date()) + "\n";
System.err.println(s);
Thread.currentThread().sleep(100);
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
}
}
(Review ID: 111486)
======================================================================