You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2020/01/01 13:27:55 UTC
[httpcomponents-core] 02/02: HTTPCORE-620: removed unnecessary rank
attribute from IOSession.Status enum
This is an automated email from the ASF dual-hosted git repository.
olegk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/httpcomponents-core.git
commit 8511b22e0776e63a66871a4bed512f289b004b51
Author: Oleg Kalnichevski <ol...@apache.org>
AuthorDate: Tue Dec 31 17:48:22 2019 +0100
HTTPCORE-620: removed unnecessary rank attribute from IOSession.Status enum
---
.../java/org/apache/hc/core5/reactor/IOSession.java | 18 ++++++++----------
.../org/apache/hc/core5/reactor/ssl/SSLIOSession.java | 9 ++++-----
2 files changed, 12 insertions(+), 15 deletions(-)
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOSession.java b/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOSession.java
index b8ca8c7..2985704 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOSession.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOSession.java
@@ -55,17 +55,15 @@ import org.apache.hc.core5.util.Timeout;
@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
}
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/SSLIOSession.java b/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/SSLIOSession.java
index f4678ab..c135ea4 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/SSLIOSession.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/SSLIOSession.java
@@ -41,7 +41,6 @@ import javax.net.ssl.SSLContext;
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;
@@ -228,7 +227,7 @@ public class SSLIOSession implements IOSession {
this.session.getLock().lock();
try {
- if (this.status.rank >= Status.CLOSING.rank) {
+ if (this.status.compareTo(Status.CLOSING) >= 0) {
return;
}
switch (this.sslMode) {
@@ -352,7 +351,7 @@ public class SSLIOSession implements IOSession {
}
}
- if (this.status.rank >= Status.CLOSING.rank) {
+ if (this.status.compareTo(Status.CLOSING) >= 0) {
this.inPlain.release();
}
if (result.getStatus() != SSLEngineResult.Status.OK) {
@@ -404,7 +403,7 @@ public class SSLIOSession implements IOSession {
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;
}
@@ -632,7 +631,7 @@ public class SSLIOSession implements IOSession {
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;