SOLR-9115: Get rid of javax.xml.bind.DatatypeConverter in Solr's SimplePostTool

This commit is contained in:
Uwe Schindler 2016-05-16 18:01:32 +02:00
parent 05178b3e58
commit 6620fd1421
2 changed files with 6 additions and 3 deletions

View File

@ -301,6 +301,9 @@ Other Changes
* SOLR-9072: Migrate morphline-core tests to SolrCloudTestCase. (Alan Woodward)
* SOLR-9115: Get rid of javax.xml.bind.DatatypeConverter in SimplePostTool
for Java 9 compatibility. (Uwe Schindler)
================== 6.0.1 ==================
(No Changes)

View File

@ -16,7 +16,6 @@
*/
package org.apache.solr.util;
import javax.xml.bind.DatatypeConverter;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.xpath.XPath;
@ -45,6 +44,7 @@ import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Base64;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
@ -852,7 +852,7 @@ public class SimplePostTool {
if(mockMode) return;
HttpURLConnection urlc = (HttpURLConnection) url.openConnection();
if (url.getUserInfo() != null) {
String encoding = DatatypeConverter.printBase64Binary(url.getUserInfo().getBytes(StandardCharsets.US_ASCII));
String encoding = Base64.getEncoder().encodeToString(url.getUserInfo().getBytes(StandardCharsets.US_ASCII));
urlc.setRequestProperty("Authorization", "Basic " + encoding);
}
urlc.connect();
@ -887,7 +887,7 @@ public class SimplePostTool {
urlc.setAllowUserInteraction(false);
urlc.setRequestProperty("Content-type", type);
if (url.getUserInfo() != null) {
String encoding = DatatypeConverter.printBase64Binary(url.getUserInfo().getBytes(StandardCharsets.US_ASCII));
String encoding = Base64.getEncoder().encodeToString(url.getUserInfo().getBytes(StandardCharsets.US_ASCII));
urlc.setRequestProperty("Authorization", "Basic " + encoding);
}
if (null != length) {