Class Channels


  • public final class Channels
    extends java.lang.Object
    Converts OutputStream, PrintStream, InputStream to the Java Channel.
    We do not use the Java's utility class Channels because the utility closes the stream as soon as the particular Thread is interrupted. If the frameworks (Zookeeper, Netty) interrupts the thread, the communication channels become closed and the JVM hangs. Therefore we developed internal utility which is safe for the Surefire.
    Since:
    3.0.0-M5
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static int BUFFER_SIZE  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private Channels()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.nio.channels.ReadableByteChannel newBufferedChannel​(java.io.InputStream is)  
      static WritableBufferedByteChannel newBufferedChannel​(java.io.OutputStream out)  
      static java.nio.channels.ReadableByteChannel newChannel​(java.io.InputStream is)  
      private static java.nio.channels.ReadableByteChannel newChannel​(java.io.InputStream is, int bufferSize)  
      static java.nio.channels.WritableByteChannel newChannel​(java.io.OutputStream out)  
      private static WritableBufferedByteChannel newChannel​(java.io.OutputStream out, int bufferSize)  
      static java.io.InputStream newInputStream​(java.nio.channels.AsynchronousByteChannel channel)  
      static java.io.OutputStream newOutputStream​(java.nio.channels.AsynchronousByteChannel channel)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Channels

        private Channels()
    • Method Detail

      • newChannel

        public static java.nio.channels.WritableByteChannel newChannel​(@Nonnull
                                                                       java.io.OutputStream out)
      • newChannel

        public static java.nio.channels.ReadableByteChannel newChannel​(@Nonnull
                                                                       java.io.InputStream is)
      • newBufferedChannel

        public static java.nio.channels.ReadableByteChannel newBufferedChannel​(@Nonnull
                                                                               java.io.InputStream is)
      • newOutputStream

        public static java.io.OutputStream newOutputStream​(java.nio.channels.AsynchronousByteChannel channel)
      • newInputStream

        public static java.io.InputStream newInputStream​(java.nio.channels.AsynchronousByteChannel channel)
      • newChannel

        private static java.nio.channels.ReadableByteChannel newChannel​(@Nonnull
                                                                        java.io.InputStream is,
                                                                        @Nonnegative
                                                                        int bufferSize)
      • newChannel

        private static WritableBufferedByteChannel newChannel​(@Nonnull
                                                              java.io.OutputStream out,
                                                              @Nonnegative
                                                              int bufferSize)