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 2022/11/14 21:11:19 UTC
[httpcomponents-core] 02/03: HTTPCORE-729: NPE in ServerHttp1IOEventHandlerFactory due to a missing null check
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 b3ae4f24521aaa4fab76871975bc23b4e3cfc316
Author: Oleg Kalnichevski <ol...@apache.org>
AuthorDate: Mon Nov 14 15:10:21 2022 +0100
HTTPCORE-729: NPE in ServerHttp1IOEventHandlerFactory due to a missing null check
---
RELEASE_NOTES.txt | 3 +++
.../impl/nio/ServerHttp1IOEventHandlerFactory.java | 29 ++++++++++++----------
2 files changed, 19 insertions(+), 13 deletions(-)
diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt
index 9980002ab..17ffbf01f 100644
--- a/RELEASE_NOTES.txt
+++ b/RELEASE_NOTES.txt
@@ -14,6 +14,9 @@ Change Log
* Examples should log exceptions instead of swallowing them.
Contributed by Gary Gregory <ggregory at apache.org>
+* Fix HTTPCORE-729: NullPointerException at org.apache.hc.core5.http.impl.nio.ServerHttp1IOEventHandlerFactory.createHandler()
+ Contributed by Oleg Kalnichevski <olegk at apache.org>
+
Release 5.2
------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ServerHttp1IOEventHandlerFactory.java b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ServerHttp1IOEventHandlerFactory.java
index 1ec001616..4a1aea997 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ServerHttp1IOEventHandlerFactory.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ServerHttp1IOEventHandlerFactory.java
@@ -62,24 +62,27 @@ public class ServerHttp1IOEventHandlerFactory implements IOEventHandlerFactory {
@Override
public IOEventHandler createHandler(final ProtocolIOSession ioSession, final Object attachment) {
String endpointScheme = URIScheme.HTTP.id;
- if (attachment instanceof EndpointParameters) {
- final EndpointParameters params = (EndpointParameters) attachment;
- endpointScheme = params.getScheme();
- if (tlsStrategy != null && URIScheme.HTTPS.same(endpointScheme)) {
+ if (tlsStrategy != null) {
+ if (attachment instanceof EndpointParameters) {
+ final EndpointParameters params = (EndpointParameters) attachment;
+ endpointScheme = params.getScheme();
+ if (URIScheme.HTTPS.same(endpointScheme)) {
+ tlsStrategy.upgrade(
+ ioSession,
+ params,
+ params.getAttachment(),
+ handshakeTimeout,
+ null);
+ }
+ } else {
+ endpointScheme = URIScheme.HTTPS.id;
tlsStrategy.upgrade(
ioSession,
- params,
- params.getAttachment(),
+ null,
+ attachment,
handshakeTimeout,
null);
}
- } else {
- tlsStrategy.upgrade(
- ioSession,
- null,
- attachment,
- handshakeTimeout,
- null);
}
return new ServerHttp1IOEventHandler(streamDuplexerFactory.create(endpointScheme, ioSession));
}