Buggy code:
public class DocumentBuilder { private final IndexSchema schema ; private Document doc ; private HashMap < String , String > map ; public DocumentBuilder ( IndexSchema schema ) { } public void startDoc ( ) { } protected void addSingleField ( SchemaField sfield , String val , float boost ) { } public void addField ( SchemaField sfield , String val , float boost ) { } public void addField ( String name , String val ) { } public void addField ( String name , String val , float boost ) { } public void setBoost ( float boost ) { } public void endDoc ( ) { } public Document getDoc ( ) throws IllegalArgumentException { } public static Document toDocument ( SolrInputDocument doc , IndexSchema schema ) { Document out = new Document ( ) ; out . setBoost ( doc . getDocumentBoost ( ) ) ; for ( SolrInputField field : doc ) { String name = field . getName ( ) ; SchemaField sfield = schema . getFieldOrNull ( name ) ; boolean used = false ; float boost = field . getBoost ( ) ; if ( ( ( sfield != null ) && ( ! ( sfield . multiValued ( ) ) ) ) && ( ( field . getValueCount ( ) ) > 1 ) ) { String id = "" ; SchemaField sf = schema . getUniqueKeyField ( ) ; if ( sf != null ) { id = ( "[" + ( doc . getFieldValue ( sf . getName ( ) ) ) ) + "]<seq2seq4repair_space>" ; } throw new org . apache . solr . common . SolrException ( ErrorCode . BAD_REQUEST , ( ( ( ( ( "ERROR:<seq2seq4repair_space>" + id ) + "multiple<seq2seq4repair_space>values<seq2seq4repair_space>encountered<seq2seq4repair_space>for<seq2seq4repair_space>non<seq2seq4repair_space>multiValued<seq2seq4repair_space>field<seq2seq4repair_space>" ) + ( sfield . getName ( ) ) ) + ":<seq2seq4repair_space>" ) + ( field . getValue ( ) ) ) ) ; } boolean hasField = false ; for ( Object v : field ) { if ( v == null ) { continue ; } String val = null ; hasField = true ; boolean isBinaryField = false ; if ( ( sfield != null ) && ( ( sfield . getType ( ) ) instanceof BinaryField ) ) { isBinaryField = true ; BinaryField binaryField = ( ( BinaryField ) ( sfield . getType ( ) ) ) ; Field f = binaryField . createField ( sfield , v , boost ) ; if ( f != null ) out . add ( f ) ; used = true ; } else { if ( ( ( sfield != null ) && ( v instanceof Date ) ) && ( ( sfield . getType ( ) ) instanceof DateField ) ) { DateField df = ( ( DateField ) ( sfield . getType ( ) ) ) ; val = ( df . toInternal ( ( ( Date ) ( v ) ) ) ) + 'Z' ; } else if ( v != null ) { val = v . toString ( ) ; } if ( sfield != null ) { used = true ; Field f = sfield . createField ( val , boost ) ; if ( f != null ) { out . add ( f ) ; } } } List < CopyField > copyFields = schema . getCopyFieldsList ( name ) ; for ( CopyField cf : copyFields ) { SchemaField destinationField = cf . getDestination ( ) ; if ( ( ! ( destinationField . multiValued ( ) ) ) && ( ( out . get ( destinationField . getName ( ) ) ) != null ) ) { throw new org . apache . solr . common . SolrException ( ErrorCode . BAD_REQUEST , ( ( ( "ERROR:<seq2seq4repair_space>multiple<seq2seq4repair_space>values<seq2seq4repair_space>encountered<seq2seq4repair_space>for<seq2seq4repair_space>non<seq2seq4repair_space>multiValued<seq2seq4repair_space>copy<seq2seq4repair_space>field<seq2seq4repair_space>" + ( destinationField . getName ( ) ) ) + ":<seq2seq4repair_space>" ) + val ) ) ; } used = true ; Field f = null ; if ( isBinaryField ) { if ( ( destinationField . getType ( ) ) instanceof BinaryField ) { BinaryField binaryField = ( ( BinaryField ) ( destinationField . getType ( ) ) ) ; <START_BUG> binaryField . createField ( destinationField , v , boost ) ; <END_BUG> } } else { f = destinationField . createField ( cf . getLimitedValue ( val ) , boost ) ; } if ( f != null ) { out . add ( f ) ; } } boost = 1.0F ; } if ( ( ! used ) && hasField ) { throw new org . apache . solr . common . SolrException ( ErrorCode . BAD_REQUEST , ( ( "ERROR:unknown<seq2seq4repair_space>field<seq2seq4repair_space>'" + name ) + "'" ) ) ; } } for ( SchemaField field : schema . getRequiredFields ( ) ) { if ( ( out . getField ( field . getName ( ) ) ) == null ) { if ( ( field . getDefaultValue ( ) ) != null ) { out . add ( field . createField ( field . getDefaultValue ( ) , 1.0F ) ) ; } else { String id = schema . printableUniqueKey ( out ) ; String msg = ( ( "Document<seq2seq4repair_space>[" + id ) + "]<seq2seq4repair_space>missing<seq2seq4repair_space>required<seq2seq4repair_space>field:<seq2seq4repair_space>" ) + ( field . getName ( ) ) ; throw new org . apache . solr . common . SolrException ( ErrorCode . BAD_REQUEST , msg ) ; } } } return out ; } public SolrDocument loadStoredFields ( SolrDocument doc , Document luceneDoc ) { } }

Fix:
f = binaryField . createField ( destinationField , v , boost ) ;