Buggy code:
final class HttpEventCollectorSender extends TimerTask implements HttpEventCollectorMiddleware . IHttpSender { public static final String MetadataTimeTag = "time" ; public static final String MetadataHostTag = "host" ; public static final String MetadataIndexTag = "index" ; public static final String MetadataSourceTag = "source" ; public static final String MetadataSourceTypeTag = "sourcetype" ; private static final String AuthorizationHeaderTag = "Authorization" ; private static final String AuthorizationHeaderScheme = "Splunk<seq2seq4repair_space>%s" ; private static final String HttpEventCollectorUriPath = "//services//collector//event//1.0" ; private static final String HttpContentType = "application//json;<seq2seq4repair_space>profile=urn:splunk:event:1.0;<seq2seq4repair_space>charset=utf-8" ; private static final String SendModeSequential = "sequential" ; private static final String SendModeSParallel = "parallel" ; public enum SendMode { Sequential , Parallel ; } public static final int DefaultBatchInterval = 10 * 1000 ; public static final int DefaultBatchSize = 10 * 1024 ; public static final int DefaultBatchCount = 10 ; private String url ; private String token ; private long maxEventsBatchCount ; private long maxEventsBatchSize ; private Dictionary < String , String > metadata ; private Timer timer ; private List < HttpEventCollectorEventInfo > eventsBatch = new LinkedList < HttpEventCollectorEventInfo > ( ) ; private long eventsBatchSize = 0 ; private CloseableHttpAsyncClient httpClient ; private boolean disableCertificateValidation = false ; private HttpEventCollectorSender . SendMode sendMode = HttpEventCollectorSender . SendMode . Sequential ; private HttpEventCollectorMiddleware middleware = new HttpEventCollectorMiddleware ( ) ; public HttpEventCollectorSender ( final String Url , final String token , long delay , long maxEventsBatchCount , long maxEventsBatchSize , String sendModeStr , Dictionary < String , String > metadata ) { } public void addMiddleware ( HttpEventCollectorMiddleware . HttpSenderMiddleware middleware ) { } public synchronized void send ( final String severity , final String message ) { } public synchronized void flush ( ) { } public void close ( ) { } @ Override public void run ( ) { } public void disableCertificateValidation ( ) { } private String serializeEventInfo ( HttpEventCollectorEventInfo eventInfo ) { JSONObject event = new JSONObject ( ) ; String host = metadata . get ( HttpEventCollectorSender . MetadataHostTag ) ; String index = metadata . get ( HttpEventCollectorSender . MetadataIndexTag ) ; String source = metadata . get ( HttpEventCollectorSender . MetadataSourceTag ) ; String sourceType = metadata . get ( HttpEventCollectorSender . MetadataSourceTypeTag ) ; event . put ( HttpEventCollectorSender . MetadataTimeTag , String . format ( Locale . US , "%.3f" , eventInfo . getTime ( ) ) ) ; if ( ( host != null ) && ( ( host . length ( ) ) > 0 ) ) <START_BUG> event . put ( HttpEventCollectorSender . MetadataHostTag , index ) ; <END_BUG> if ( ( index != null ) && ( ( index . length ( ) ) > 0 ) ) event . put ( HttpEventCollectorSender . MetadataIndexTag , index ) ; if ( ( source != null ) && ( ( source . length ( ) ) > 0 ) ) event . put ( HttpEventCollectorSender . MetadataSourceTag , source ) ; if ( ( sourceType != null ) && ( ( sourceType . length ( ) ) > 0 ) ) event . put ( HttpEventCollectorSender . MetadataSourceTypeTag , sourceType ) ; JSONObject body = new JSONObject ( ) ; body . put ( "severity" , eventInfo . getSeverity ( ) ) ; body . put ( "message" , eventInfo . getMessage ( ) ) ; event . put ( "event" , body ) ; return event . toString ( ) ; } private void startHttpClient ( ) { } private void stopHttpClient ( ) throws SecurityException { } private void postEventsAsync ( final List < HttpEventCollectorEventInfo > events ) { } public void postEvents ( final List < HttpEventCollectorEventInfo > events , final HttpEventCollectorMiddleware . IHttpSenderCallback callback ) { } }

Fix:
event . put ( HttpEventCollectorSender . MetadataHostTag , host ) ;