AtlasOfLivingAustralia / biocache-store

Occurrence processing, indexing and batch processing
Other
7 stars 24 forks source link

Fix for UnsupportedOperationException trying to add additional fields #330

Open vjrj opened 5 years ago

vjrj commented 5 years ago

I'm trying to indexing additional fields like habitat adding to additional.fields.to.index but I get a java.lang.UnsupportedOperationException because Scala is using a inmutable map for the fields in SolrIndexDAO.scala so does not have a put method.

The complete trace:

gbif18-cass3 2019-03-24 17:54:27,782 ERROR: [IndexRunner] - guid:f4953c71-1d1c-4120-81b5-a61a5370cb11, null
java.lang.UnsupportedOperationException
    at java.util.AbstractMap.put(AbstractMap.java:209)
    at au.org.ala.biocache.index.SolrIndexDAO$$anonfun$indexFromArray$3.apply(SolrIndexDAO.scala:1074)
    at au.org.ala.biocache.index.SolrIndexDAO$$anonfun$indexFromArray$3.apply(SolrIndexDAO.scala:1073)
    at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:33)
    at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:108)
    at au.org.ala.biocache.index.SolrIndexDAO.indexFromArray(SolrIndexDAO.scala:1073)
    at au.org.ala.biocache.index.IndexRunner$ProcessThread$1.run(IndexRunner.scala:164)
gbif18-cass3 2019-03-24 17:54:27,782 ERROR: [IndexRunner] - guid:019057b1-68e7-41f1

The tests fail if we add only new fields in the test config, but using a mutable map for the fields all tests past correctly.

I'm quite newbie here, so double check this PR ...