Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-16101

Add an empty constructor for SolrInputDocument

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 5.5, 6.6, 7.7, 8.11.1
    • 9.0, 8.11.2
    • SolrJ
    • None

    Description

      While trying to serialize and deserialize SolrInputDocument using the following code,

      final SolrInputDocument inputDoc = new SolrInputDocument();
              inputDoc.addField("foo", "bar");
              Gson gson = new Gson();
              String docString = gson.toJson(inputDoc);
              SolrInputDocument solrInputDocument = new SolrInputDocument(gson.fromJson(docString, SolrInputDocument.class));
      

      the deserializing fails w/

      "java.lang.ClassCastException: Cannot cast com.google.gson.internal.LinkedTreeMap to org.apache.solr.common.SolrInputDocument"

      SolrInputDocument needs an empty constructor for this.

      There seem to be some ways to get around this for older versions but with vanilla code this affects all versions starting 5.5 all the way until 8.11.1

      Attachments

        Issue Links

          Activity

            People

              anshum Anshum Gupta
              anshum Anshum Gupta
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1h
                  1h