Package org.tanukisoftware.wrapper.test
Class DeadlockPrintStream
java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
java.io.PrintStream
org.tanukisoftware.wrapper.test.DeadlockPrintStream
- All Implemented Interfaces:
Closeable
,Flushable
,Appendable
,AutoCloseable
A print stream which can be put into a state in which all calls to write
to it will result in the calling threads deadlocking in the call.
Obviously, this class will not be useful to many as it is for tests.
-
Field Summary
Fields inherited from class java.io.FilterOutputStream
out
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new DeadlockPrintStream wrapped around another PrintStream.DeadlockPrintStream
(PrintStream out, boolean autoFlush, String encoding) Creates a new DeadlockPrintStream wrapped around another PrintStream. -
Method Summary
Methods inherited from class java.io.PrintStream
append, append, append, checkError, clearError, format, format, print, print, print, print, print, print, print, print, print, printf, printf, println, println, println, println, println, println, println, println, println, println, setError, writeBytes
Methods inherited from class java.io.OutputStream
nullOutputStream
-
Constructor Details
-
DeadlockPrintStream
Creates a new DeadlockPrintStream wrapped around another PrintStream.- Parameters:
out
- The PrintStream which will be wrapped by this new stream.
-
DeadlockPrintStream
public DeadlockPrintStream(PrintStream out, boolean autoFlush, String encoding) throws UnsupportedEncodingException Creates a new DeadlockPrintStream wrapped around another PrintStream.- Parameters:
out
- The PrintStream which will be wrapped by this new stream.autoFlush
- Whether the output buffer should be automatically flushed or not. ill be passed to the parent stream.encoding
- The name of a supported character encoding. Will be passed to the parent stream.- Throws:
UnsupportedEncodingException
- If the named encoding is not supported.
-
-
Method Details
-
write
public void write(int b) - Overrides:
write
in classPrintStream
-
write
- Overrides:
write
in classPrintStream
- Throws:
IOException
-
write
public void write(byte[] b, int off, int len) - Overrides:
write
in classPrintStream
-
flush
public void flush()- Specified by:
flush
in interfaceFlushable
- Overrides:
flush
in classPrintStream
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classPrintStream
-
setDeadlock
public void setDeadlock(boolean deadlock) Sets or clears the deadlock flag. If set, calls to any other method of this class will result in the calling thread being deadlocked. They will be released if the flag is cleared with this method.- Parameters:
deadlock
- True to set the flag, false to clear it.
-