-
Notifications
You must be signed in to change notification settings - Fork 109
Running on Java 9
Java 9's HttpClient (for HTTP/2 support) doesn't allow setting the authorization
header using the public APIs. On further investigation, it's a forbidden header. Even if you set it using jdk.incubator.http.HttpRequest.Builder#header
, internally, it won't respect it.
As it stands currently, only HTTP basic authentication is supported, via a different callback mechanism. However, Apple's service doesn't use basic authentication. It requires that the authorization
header be set to bearer xxxxxxx.
Our initial solution to this is to use reflection. While this might seem a little weird, it's the only way to communicate using Java 9's new HTTP/2 client. We've already filed a bug with Oracle for this, as this violates the specification (the public API must accept the authorization header). Oracle has fixed this bug in Java 11, however, they haven't indicated whether or not it'll be back ported to Java 10 or even 9. There's an additional discussion thread on Stack Overflow here.
As a result of the above, this library only works with JDK 9.0.1. Oracle has removed the internal API which was accessed via reflection since JDK 9.0.4.
To use this library successfully with Java 9's HttpClient, add the following to your VM command line parameters:
--add-opens jdk.incubator.httpclient/jdk.incubator.http=com.clevertap.apns
This will allow the library to access the internal setSystemHeader
via reflection.
We've already filed a bug with Oracle, and it's been acknowledged here.