Top Description Inners Constructors Methods
org.newsclub.net.unix

pack-priv final Class InterruptibleChannelUtil

extends Object
Class Inheritance
Imports
java.io.IOException, java.nio.channels.AsynchronousCloseException, .ClosedByInterruptException, .ClosedChannelException, .NotYetBoundException, .NotYetConnectedException, java.nio.channels.spi.AbstractInterruptibleChannel, java.util.Objects

Helper methods when working with AbstractInterruptibleChannel subclasses.
Author
Christian Kohlschütter

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static interface
InterruptibleChannelUtil.EndMethod

Reference to the protected AbstractInterruptibleChannel#end(boolean) method.

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
private static <T extends Exception> T
pack-priv static void
endInterruptable(AFSomeSocketChannel
The channel.
channel
,
InterruptibleChannelUtil.EndMethod
The reference to the protected AbstractInterruptibleChannel#end(boolean) method.
end
,
boolean
true if the block started with begin succeeded without an exception.
complete
,
Exception
An optional exception that was caught in the try-catch-finally block.
exception
)

Wrapper method that calls AbstractInterruptibleChannel#end(boolean), making sure the socket is closed and the Thread#interrupted() state is set correctly upon error.

pack-priv static Exception

Returns:

The exception.
handleException
(AFSomeSocketChannel
The channel to work with.
channel
,
IOException
The exception
e
)

Makes sure that upon an exception that is documented to have the channel be closed the channel is indeed closed before throwing that exception.

pack-priv static IOException
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

InterruptibleChannelUtilback to summary
pack-priv InterruptibleChannelUtil()

Method Detail

closeAndThrowback to summary
private static <T extends Exception> T closeAndThrow(AFSomeSocketChannel channel, T exc)
endInterruptableback to summary
pack-priv static void endInterruptable(AFSomeSocketChannel channel, InterruptibleChannelUtil.EndMethod end, boolean complete, Exception exception) throws AsynchronousCloseException

Wrapper method that calls AbstractInterruptibleChannel#end(boolean), making sure the socket is closed and the Thread#interrupted() state is set correctly upon error.

Parameters
channel:AFSomeSocketChannel

The channel.

end:InterruptibleChannelUtil.EndMethod

The reference to the protected AbstractInterruptibleChannel#end(boolean) method.

complete:boolean

true if the block started with begin succeeded without an exception.

exception:Exception

An optional exception that was caught in the try-catch-finally block.

Exceptions
AsynchronousCloseException:
on error.
handleExceptionback to summary
pack-priv static Exception handleException(AFSomeSocketChannel channel, IOException e)

Makes sure that upon an exception that is documented to have the channel be closed the channel is indeed closed before throwing that exception. If the exception is also documented to have the "Thread interrupted" state be set, make sure that this state is actually set as well.

Parameters
channel:AFSomeSocketChannel

The channel to work with.

e:IOException

The exception

Returns:Exception

The exception.

Annotations
@SuppressWarnings:PMD.CognitiveComplexity
ioExceptionOrThrowRuntimeExceptionback to summary
pack-priv static IOException ioExceptionOrThrowRuntimeException(Exception exception)
org.newsclub.net.unix back to summary

pack-priv Interface InterruptibleChannelUtil.EndMethod

Annotations
@FunctionalInterface

Reference to the protected AbstractInterruptibleChannel#end(boolean) method.

Method Summary

Modifier and TypeMethod and Description
public void
end(boolean completed)

Method Detail

endback to summary
public void end(boolean completed) throws AsynchronousCloseException