gerlowskija commented on a change in pull request #665: Fixes SOLR-13539
URL: https://github.com/apache/lucene-solr/pull/665#discussion_r295847529
##########
File path:
solr/solrj/src/java/org/apache/solr/client/solrj/util/ClientUtils.java
##########
@@ -104,35 +103,51 @@ public static void writeXML( SolrInputDocument doc,
Writer writer ) throws IOExc
writer.write("</doc>");
}
- private static void writeVal(Writer writer, String name, Object v, String
update) throws IOException {
+ private static void writeVal(Writer writer, String name, Object v, String
update)
+ throws IOException {
+ boolean binary = false;
if (v instanceof Date) {
- v = ((Date)v).toInstant().toString();
+ v = ((Date) v).toInstant().toString();
} else if (v instanceof byte[]) {
byte[] bytes = (byte[]) v;
v = Base64.byteArrayToBase64(bytes, 0, bytes.length);
+ binary = true;
} else if (v instanceof ByteBuffer) {
ByteBuffer bytes = (ByteBuffer) v;
- v = Base64.byteArrayToBase64(bytes.array(),
bytes.position(),bytes.limit() - bytes.position());
+ v = Base64.byteArrayToBase64(bytes.array(), bytes.position(),
bytes.limit() - bytes.position());
+ binary = true;
}
XML.Writable valWriter = null;
- if(v instanceof SolrInputDocument) {
+ if (v instanceof SolrInputDocument) {
final SolrInputDocument solrDoc = (SolrInputDocument) v;
valWriter = (writer1) -> writeXML(solrDoc, writer1);
- } else if(v != null) {
- final Object val = v;
- valWriter = (writer1) -> XML.escapeCharData(val.toString(), writer1);
+ } else if (v != null) {
+ Object val = v;
+ if (binary) {
+ valWriter = (writer1) -> writer1.write((String) val);
+ } else {
+ valWriter = (writer1) -> XML.escapeCharData(val.toString(), writer1);
+ }
}
if (update == null) {
if (v != null) {
- XML.writeXML(writer, "field", valWriter, "name", name);
+ if (binary) {
+ XML.writeXML(writer, "field", valWriter, "name", name, "dt",
XMLLoader.BINARY_BASE64);
Review comment:
[-1] When I pull this code down locally, I get compilation errors.
XMLLoader lives in solr-core. SolrJ doesn't depend on solr-core (it's the
other way around), so when I try to compile this PR, I get:
```
[javac] Compiling 716 source files to
/Users/jasongerlowski/checkouts/lucene-solr/solr/build/solr-solrj/classes/java
[javac]
/Users/jasongerlowski/checkouts/lucene-solr/solr/solrj/src/java/org/apache/solr/client/solrj/util/ClientUtils.java:36:
error: package org.apache.solr.handler.loader does not exist
[javac] import org.apache.solr.handler.loader.XMLLoader;
```
We should move this constant to somewhere in SolrJ so that it can be seen in
both solr-core and solr-solrj.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]