Skip to content

Commit

Permalink
HTTPCORE-620: removed unnecessary rank attribute from IOSession.Statu…
Browse files Browse the repository at this point in the history
…s enum
  • Loading branch information
ok2c committed Jan 1, 2020
1 parent c4a68cc commit 8511b22
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
18 changes: 8 additions & 10 deletions httpcore5/src/main/java/org/apache/hc/core5/reactor/IOSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,15 @@
@Internal
public interface IOSession extends ByteChannel, SocketModalCloseable, Identifiable {

public enum Status {

ACTIVE(0),
CLOSING(1),
CLOSED(Integer.MAX_VALUE);

private Status(final int rank) {
this.rank = rank;
}
/**
* This enum represents a set of states I/O session transitions through
* during its life-span.
*/
enum Status {

public final int rank;
ACTIVE,
CLOSING,
CLOSED

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import javax.net.ssl.SSLEngine;
import javax.net.ssl.SSLEngineResult;
import javax.net.ssl.SSLEngineResult.HandshakeStatus;
import javax.net.ssl.SSLEngineResult.Status;
import javax.net.ssl.SSLException;
import javax.net.ssl.SSLSession;

Expand Down Expand Up @@ -228,7 +227,7 @@ private void initialize() throws SSLException {

this.session.getLock().lock();
try {
if (this.status.rank >= Status.CLOSING.rank) {
if (this.status.compareTo(Status.CLOSING) >= 0) {
return;
}
switch (this.sslMode) {
Expand Down Expand Up @@ -352,7 +351,7 @@ private void doHandshake() throws SSLException {
}
}

if (this.status.rank >= Status.CLOSING.rank) {
if (this.status.compareTo(Status.CLOSING) >= 0) {
this.inPlain.release();
}
if (result.getStatus() != SSLEngineResult.Status.OK) {
Expand Down Expand Up @@ -404,7 +403,7 @@ private void updateEventMask() {
this.status = Status.CLOSED;
}
// Abnormal session termination
if (this.status.rank <= Status.CLOSING.rank && this.endOfStream
if (this.status.compareTo(Status.CLOSING) <= 0 && this.endOfStream
&& this.sslEngine.getHandshakeStatus() == HandshakeStatus.NEED_UNWRAP) {
this.status = Status.CLOSED;
}
Expand Down Expand Up @@ -632,7 +631,7 @@ public void close(final CloseMode closeMode) {
this.session.getLock().lock();
try {
if (closeMode == CloseMode.GRACEFUL) {
if (this.status.rank >= Status.CLOSING.rank) {
if (this.status.compareTo(Status.CLOSING) >= 0) {
return;
}
this.status = Status.CLOSING;
Expand Down

0 comments on commit 8511b22

Please sign in to comment.