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 2010/11/29 20:33:21 UTC
svn commit: r1040240 - in
/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio:
DefaultClientIOEventDispatch.java DefaultServerIOEventDispatch.java
ssl/SSLClientIOEventDispatch.java ssl/SSLServerIOEventDispatch.java
Author: olegk
Date: Mon Nov 29 19:33:20 2010
New Revision: 1040240
URL: http://svn.apache.org/viewvc?rev=1040240&view=rev
Log:
HTTPCORE-243: check for HTTP connection and SSL I/O session being non null
Modified:
httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultClientIOEventDispatch.java
httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultServerIOEventDispatch.java
httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/ssl/SSLClientIOEventDispatch.java
httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/ssl/SSLServerIOEventDispatch.java
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultClientIOEventDispatch.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultClientIOEventDispatch.java?rev=1040240&r1=1040239&r2=1040240&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultClientIOEventDispatch.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultClientIOEventDispatch.java Mon Nov 29 19:33:20 2010
@@ -142,21 +142,30 @@ public class DefaultClientIOEventDispatc
}
}
+ private void ensureNotNull(final NHttpClientIOTarget conn) {
+ if (conn == null) {
+ throw new IllegalStateException("HTTP connection is null");
+ }
+ }
+
public void inputReady(final IOSession session) {
NHttpClientIOTarget conn =
(NHttpClientIOTarget) session.getAttribute(ExecutionContext.HTTP_CONNECTION);
+ ensureNotNull(conn);
conn.consumeInput(this.handler);
}
public void outputReady(final IOSession session) {
NHttpClientIOTarget conn =
(NHttpClientIOTarget) session.getAttribute(ExecutionContext.HTTP_CONNECTION);
+ ensureNotNull(conn);
conn.produceOutput(this.handler);
}
public void timeout(final IOSession session) {
NHttpClientIOTarget conn =
(NHttpClientIOTarget) session.getAttribute(ExecutionContext.HTTP_CONNECTION);
+ ensureNotNull(conn);
this.handler.timeout(conn);
}
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultServerIOEventDispatch.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultServerIOEventDispatch.java?rev=1040240&r1=1040239&r2=1040240&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultServerIOEventDispatch.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultServerIOEventDispatch.java Mon Nov 29 19:33:20 2010
@@ -141,21 +141,30 @@ public class DefaultServerIOEventDispatc
}
}
+ private void ensureNotNull(final NHttpServerIOTarget conn) {
+ if (conn == null) {
+ throw new IllegalStateException("HTTP connection is null");
+ }
+ }
+
public void inputReady(final IOSession session) {
NHttpServerIOTarget conn =
(NHttpServerIOTarget) session.getAttribute(ExecutionContext.HTTP_CONNECTION);
+ ensureNotNull(conn);
conn.consumeInput(this.handler);
}
public void outputReady(final IOSession session) {
NHttpServerIOTarget conn =
(NHttpServerIOTarget) session.getAttribute(ExecutionContext.HTTP_CONNECTION);
+ ensureNotNull(conn);
conn.produceOutput(this.handler);
}
public void timeout(final IOSession session) {
NHttpServerIOTarget conn =
(NHttpServerIOTarget) session.getAttribute(ExecutionContext.HTTP_CONNECTION);
+ ensureNotNull(conn);
this.handler.timeout(conn);
}
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/ssl/SSLClientIOEventDispatch.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/ssl/SSLClientIOEventDispatch.java?rev=1040240&r1=1040239&r2=1040240&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/ssl/SSLClientIOEventDispatch.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/ssl/SSLClientIOEventDispatch.java Mon Nov 29 19:33:20 2010
@@ -217,11 +217,25 @@ public class SSLClientIOEventDispatch im
}
}
+ private void ensureNotNull(final NHttpClientIOTarget conn) {
+ if (conn == null) {
+ throw new IllegalStateException("HTTP connection is null");
+ }
+ }
+
+ private void ensureNotNull(final SSLIOSession ssliosession) {
+ if (ssliosession == null) {
+ throw new IllegalStateException("SSL I/O session is null");
+ }
+ }
+
public void inputReady(final IOSession session) {
NHttpClientIOTarget conn =
(NHttpClientIOTarget) session.getAttribute(ExecutionContext.HTTP_CONNECTION);
+ ensureNotNull(conn);
SSLIOSession sslSession =
(SSLIOSession) session.getAttribute(SSL_SESSION);
+ ensureNotNull(sslSession);
try {
if (sslSession.isAppInputReady()) {
@@ -237,8 +251,10 @@ public class SSLClientIOEventDispatch im
public void outputReady(final IOSession session) {
NHttpClientIOTarget conn =
(NHttpClientIOTarget) session.getAttribute(ExecutionContext.HTTP_CONNECTION);
+ ensureNotNull(conn);
SSLIOSession sslSession =
(SSLIOSession) session.getAttribute(SSL_SESSION);
+ ensureNotNull(sslSession);
try {
if (sslSession.isAppOutputReady()) {
@@ -254,8 +270,10 @@ public class SSLClientIOEventDispatch im
public void timeout(final IOSession session) {
NHttpClientIOTarget conn =
(NHttpClientIOTarget) session.getAttribute(ExecutionContext.HTTP_CONNECTION);
+ ensureNotNull(conn);
SSLIOSession sslSession =
(SSLIOSession) session.getAttribute(SSL_SESSION);
+ ensureNotNull(sslSession);
this.handler.timeout(conn);
synchronized (sslSession) {
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/ssl/SSLServerIOEventDispatch.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/ssl/SSLServerIOEventDispatch.java?rev=1040240&r1=1040239&r2=1040240&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/ssl/SSLServerIOEventDispatch.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/ssl/SSLServerIOEventDispatch.java Mon Nov 29 19:33:20 2010
@@ -217,11 +217,25 @@ public class SSLServerIOEventDispatch im
}
}
+ private void ensureNotNull(final NHttpServerIOTarget conn) {
+ if (conn == null) {
+ throw new IllegalStateException("HTTP connection is null");
+ }
+ }
+
+ private void ensureNotNull(final SSLIOSession ssliosession) {
+ if (ssliosession == null) {
+ throw new IllegalStateException("SSL I/O session is null");
+ }
+ }
+
public void inputReady(final IOSession session) {
NHttpServerIOTarget conn =
(NHttpServerIOTarget) session.getAttribute(ExecutionContext.HTTP_CONNECTION);
+ ensureNotNull(conn);
SSLIOSession sslSession =
(SSLIOSession) session.getAttribute(SSL_SESSION);
+ ensureNotNull(sslSession);
try {
if (sslSession.isAppInputReady()) {
@@ -237,8 +251,10 @@ public class SSLServerIOEventDispatch im
public void outputReady(final IOSession session) {
NHttpServerIOTarget conn =
(NHttpServerIOTarget) session.getAttribute(ExecutionContext.HTTP_CONNECTION);
+ ensureNotNull(conn);
SSLIOSession sslSession =
(SSLIOSession) session.getAttribute(SSL_SESSION);
+ ensureNotNull(sslSession);
try {
if (sslSession.isAppOutputReady()) {
@@ -254,8 +270,10 @@ public class SSLServerIOEventDispatch im
public void timeout(final IOSession session) {
NHttpServerIOTarget conn =
(NHttpServerIOTarget) session.getAttribute(ExecutionContext.HTTP_CONNECTION);
+ ensureNotNull(conn);
SSLIOSession sslSession =
(SSLIOSession) session.getAttribute(SSL_SESSION);
+ ensureNotNull(sslSession);
this.handler.timeout(conn);
synchronized (sslSession) {