Skip to content

Commit

Permalink
Narrow handler scope.
Browse files Browse the repository at this point in the history
  • Loading branch information
mnlipp committed Apr 28, 2024
1 parent df7b921 commit 779cb03
Showing 1 changed file with 34 additions and 13 deletions.
47 changes: 34 additions & 13 deletions org.jgrapes.io/src/org/jgrapes/net/SslCodec.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public void checkServerTrusted(
* @param event
* the accepted event
*/
@Handler(channels = EncryptedChannel.class)
@Handler(channels = EncryptedChannel.class, excludeSelf = true)
public void onAccepted(Accepted event, IOSubchannel encryptedChannel) {
new PlainChannel(event, encryptedChannel);
}
Expand All @@ -175,10 +175,11 @@ public void onOpenConnection(OpenSocketConnection event) {
* @param event
* the accepted event
*/
@Handler(channels = EncryptedChannel.class)
@Handler(channels = EncryptedChannel.class, excludeSelf = true)
public void onConnected(ClientConnected event,
IOSubchannel encryptedChannel) {
if (event.openEvent().associated(SslCodec.class).isPresent()) {
if (event.openEvent()
.associated(SslCodec.class, Object.class).isPresent()) {
new PlainChannel(event, encryptedChannel);
}
}
Expand All @@ -195,9 +196,8 @@ public void onConnected(ClientConnected event,
* @throws SSLException
* @throws ExecutionException
*/
@Handler(channels = EncryptedChannel.class)
public void onInput(
Input<ByteBuffer> event, IOSubchannel encryptedChannel)
@Handler(channels = EncryptedChannel.class, excludeSelf = true)
public void onInput(Input<ByteBuffer> event, IOSubchannel encryptedChannel)
throws InterruptedException, SSLException, ExecutionException {
@SuppressWarnings({ "unchecked", "PMD.AvoidDuplicateLiterals" })
final Optional<PlainChannel> plainChannel
Expand All @@ -216,7 +216,7 @@ public void onInput(
* @throws InterruptedException
* @throws SSLException
*/
@Handler(channels = EncryptedChannel.class)
@Handler(channels = EncryptedChannel.class, excludeSelf = true)
public void onHalfClosed(HalfClosed event, IOSubchannel encryptedChannel)
throws SSLException, InterruptedException {
@SuppressWarnings("unchecked")
Expand All @@ -236,7 +236,7 @@ public void onHalfClosed(HalfClosed event, IOSubchannel encryptedChannel)
* @throws InterruptedException
* @throws SSLException
*/
@Handler(channels = EncryptedChannel.class)
@Handler(channels = EncryptedChannel.class, excludeSelf = true)
public void onClosed(Closed<Void> event, IOSubchannel encryptedChannel)
throws SSLException, InterruptedException {
@SuppressWarnings("unchecked")
Expand All @@ -254,7 +254,7 @@ public void onClosed(Closed<Void> event, IOSubchannel encryptedChannel)
* @param event the event
* @param encryptedChannel the encrypted channel
*/
@Handler(channels = EncryptedChannel.class)
@Handler(channels = EncryptedChannel.class, excludeSelf = true)
public void onPurge(Purge event, IOSubchannel encryptedChannel) {
@SuppressWarnings("unchecked")
final Optional<PlainChannel> plainChannel
Expand All @@ -274,7 +274,7 @@ public void onPurge(Purge event, IOSubchannel encryptedChannel) {
* @throws InterruptedException
* @throws SSLException
*/
@Handler(channels = EncryptedChannel.class)
@Handler(channels = EncryptedChannel.class, excludeSelf = true)
public void onIOError(IOError event, IOSubchannel encryptedChannel)
throws SSLException, InterruptedException {
@SuppressWarnings("unchecked")
Expand All @@ -294,8 +294,7 @@ public void onIOError(IOError event, IOSubchannel encryptedChannel)
* @throws ExecutionException
*/
@Handler
public void onOutput(Output<ByteBuffer> event,
PlainChannel plainChannel)
public void onOutput(Output<ByteBuffer> event, PlainChannel plainChannel)
throws InterruptedException, SSLException, ExecutionException {
if (plainChannel.hub() != this) {
return;
Expand Down Expand Up @@ -324,7 +323,8 @@ public void onClose(Close event, PlainChannel plainChannel)
* Represents the plain channel.
*/
@SuppressWarnings("PMD.DataflowAnomalyAnalysis")
private class PlainChannel extends LinkedIOSubchannel {
private class PlainChannel extends LinkedIOSubchannel
implements SocketIOChannel {
public SocketAddress localAddress;
public SocketAddress remoteAddress;
public SSLEngine sslEngine;
Expand Down Expand Up @@ -731,5 +731,26 @@ private ManagedBuffer<ByteBuffer> acquireUpstreamBuffer()
public void purge() {
downPipeline.fire(new Purge(), this);
}

@Override
public SocketAddress localAddress() {
return localAddress;
}

@Override
public SocketAddress remoteAddress() {
return remoteAddress;
}

@Override
public boolean isPurgeable() {
return false;
}

@Override
public long purgeableSince() {
return 0;
}

}
}

0 comments on commit 779cb03

Please sign in to comment.