Writer getWriter( Object source ) throws KettleException {
    try {
      Writer outputStreamWriter = writers.get( source );
      if ( outputStreamWriter != null ) {
        return outputStreamWriter;
      }
      FileObject file =
        getReplayFilename( destinationDirectory, processingFilename, dateString, fileExtension, source );
      ResultFile resultFile =
        new ResultFile( ResultFile.FILE_TYPE_GENERAL, file, baseStep.getTransMeta().getName(), baseStep
          .getStepname() );
      baseStep.addResultFile( resultFile );
      try {
        if ( isBlank( encoding ) ) {
          outputStreamWriter = new OutputStreamWriter( KettleVFS.getOutputStream( file, false ) );
        } else {
          outputStreamWriter = new OutputStreamWriter( KettleVFS.getOutputStream( file, false ), encoding );
        }
      } catch ( Exception e ) {
        throw new KettleException( BaseMessages.getString(
          PKG, "AbstractFileErrorHandler.Exception.CouldNotCreateFileErrorHandlerForFile" )
          + file.getName().getURI(), e );
      }
      writers.put( source, outputStreamWriter );
      return outputStreamWriter;
    } catch ( KettleFileException e ) {
      throw new KettleException( BaseMessages.getString(
        PKG, "AbstractFileErrorHandler.Exception.CouldNotCreateFileErrorHandlerForFile" ), e );
    }
  }
@Test
  public void getWriterEmptyEncoding() throws Exception {
    Object source = Mockito.mock( Object.class );
    setupErrorHandler( "", source );
    OutputStreamWriter outputStreamWriter = (OutputStreamWriter) abstractFileErrorHandler.getWriter( source );
    assertEquals( DEFAULT_ENCODING, outputStreamWriter.getEncoding() );
  }