-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace usages of javax.xml.bind.DatatypeConverter #5083
Replace usages of javax.xml.bind.DatatypeConverter #5083
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. Two additional improvements are possible. See comments inside.
now fails on the DenonMarantz Binding
We should open a new issue to refactor the binding and add the "help wanted" label.
@@ -1007,7 +1007,7 @@ public void filter(ClientRequestContext requestContext) throws IOException { | |||
private String getBasicAuthentication() { | |||
String token = this.user + ":" + this.password; | |||
try { | |||
return "Basic " + DatatypeConverter.printBase64Binary(token.getBytes("UTF-8")); | |||
return "Basic " + Base64.getEncoder().encodeToString(token.getBytes("UTF-8")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could use StandardCharsets.UTF_8
instead of "UTF-8"
to omit the check for UnsupportedEncodingException
.
return "Basic " + Base64.getEncoder().encodeToString(token.getBytes("UTF-8")); | |
return "Basic " + Base64.getEncoder().encodeToString(token.getBytes(StandardCharsets.UTF_8)); |
@@ -1416,7 +1416,7 @@ public void filter(ClientRequestContext requestContext) throws IOException { | |||
private String getBasicAuthentication() { | |||
String token = this.user + ":" + this.password; | |||
try { | |||
return "Basic " + DatatypeConverter.printBase64Binary(token.getBytes("UTF-8")); | |||
return "Basic " + Base64.getEncoder().encodeToString(token.getBytes("UTF-8")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could use StandardCharsets.UTF_8
instead of "UTF-8"
to omit the check for UnsupportedEncodingException
.
return "Basic " + Base64.getEncoder().encodeToString(token.getBytes("UTF-8")); | |
return "Basic " + Base64.getEncoder().encodeToString(token.getBytes(StandardCharsets.UTF_8)); |
Does it make sense to add the package |
It's still possible for the framework to provide a bundle for the JAXB packages. The bindings could also add these libraries themselves e.g. using Maven dependencies. See also this nice migration guide and stackoverflow post. |
We certainly should and maybe label them accordingly so we can easily see what needs to be done for supporting Java 11 (openhab/openhab-distro#768). There are already several issues for other bindings depending on full JREs. I'll run SAT again and see what other bindings depend on a full JRE. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, given the remarks by @cweitkamp
The DatatypeConverter class is no longer provided by the default Java 11 modules Signed-off-by: Wouter Born <[email protected]>
Signed-off-by: Wouter Born <[email protected]>
c59ee23
to
8c40ca1
Compare
I've applied the two improvements @cweitkamp! 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job. Thanks.
* Replace usages of javax.xml.bind.DatatypeConverter The DatatypeConverter class is no longer provided by the default Java 11 modules * Replace "UTF-8" with StandardCharsets.UTF_8 Signed-off-by: Wouter Born <[email protected]> Signed-off-by: Pshatsillo <[email protected]>
* Replace usages of javax.xml.bind.DatatypeConverter The DatatypeConverter class is no longer provided by the default Java 11 modules * Replace "UTF-8" with StandardCharsets.UTF_8 Signed-off-by: Wouter Born <[email protected]> Signed-off-by: Maximilian Hess <[email protected]>
The
DatatypeConverter
class is no longer provided by the default Java 11 modules.See https://github.com/openhab/openhab2-addons/pull/5080#issuecomment-471343209
With these changes the Java 11 build now fails on the DenonMarantz Binding which uses even more
javax.xml.bind
classes. See this Travis Java 11 build of a branch with these fixes and https://github.com/openhab/openhab2-addons/pull/5080.