Buggy code:
public void deleteRef ( String refName ) throws GitException , InterruptedException { } public Set < String > getRefNames ( String refPrefix ) throws GitException , InterruptedException { } public Map < String , ObjectId > getHeadRev ( String url ) throws GitException , InterruptedException { } public Map < String , ObjectId > getRemoteReferences ( String url , String pattern , boolean headsOnly , boolean tagsOnly ) throws GitException , InterruptedException { } private String createRefRegexFromGlob ( String glob ) { } public ObjectId getHeadRev ( String remoteRepoUrl , String branchSpec ) throws GitException { } private Repository openDummyRepository ( ) throws IOException { } public String getRemoteUrl ( String name ) throws GitException { } @ NonNull public Repository getRepository ( ) throws GitException { } public FilePath getWorkTree ( ) { } public void setRemoteUrl ( String name , String url ) throws GitException { } public void addRemoteUrl ( String name , String url ) throws GitException , InterruptedException { } public void addNote ( String note , String namespace ) throws GitException { } private String normalizeNote ( String note ) { } private String qualifyNotesNamespace ( String namespace ) { } public void appendNote ( String note , String namespace ) throws GitException { } public ChangelogCommand changelog ( ) { } class RawFormatter { private boolean hasNewPath ( DiffEntry d ) { } private String statusOf ( DiffEntry d ) { } void format ( RevCommit commit , @ Nullable RevCommit parent , PrintWriter pw ) throws IOException { } } public void clean ( ) throws GitException { } public CloneCommand clone_ ( ) { return new CloneCommand ( ) { String url ; String remote = Constants . DEFAULT_REMOTE_NAME ; String reference ; Integer timeout ; boolean shared ; public CloneCommand url ( String url ) { this . url = url ; return this ; } public CloneCommand repositoryName ( String name ) { this . remote = name ; return this ; } public CloneCommand shallow ( ) { listener . getLogger ( ) . println ( "[WARNING]<seq2seq4repair_space>JGit<seq2seq4repair_space>doesn't<seq2seq4repair_space>support<seq2seq4repair_space>shallow<seq2seq4repair_space>clone.<seq2seq4repair_space>This<seq2seq4repair_space>flag<seq2seq4repair_space>is<seq2seq4repair_space>ignored" ) ; return this ; } public CloneCommand shared ( ) { this . shared = true ; return this ; } public CloneCommand reference ( String reference ) { this . reference = reference ; return this ; } public CloneCommand timeout ( Integer timeout ) { this . timeout = timeout ; return this ; } public CloneCommand noCheckout ( ) { return this ; } public void execute ( ) throws GitException , InterruptedException { Repository repository = null ; try { if ( workspace . exists ( ) ) Util . deleteContentsRecursive ( workspace ) ; RepositoryBuilder builder = new RepositoryBuilder ( ) ; builder . readEnvironment ( ) . setGitDir ( new File ( workspace , Constants . DOT_GIT ) ) ; if ( shared ) { if ( ( ( reference ) == null ) || ( reference . isEmpty ( ) ) ) { reference = url ; } else { listener . getLogger ( ) . println ( "[WARNING]<seq2seq4repair_space>Both<seq2seq4repair_space>'shared'<seq2seq4repair_space>and<seq2seq4repair_space>'reference'<seq2seq4repair_space>is<seq2seq4repair_space>used,<seq2seq4repair_space>shared<seq2seq4repair_space>is<seq2seq4repair_space>ignored." ) ; } } if ( ( ( reference ) != null ) && ( ! ( reference . isEmpty ( ) ) ) ) builder . addAlternateObjectDirectory ( new File ( reference ) ) ; repository = builder . build ( ) ; repository . create ( ) ; if ( ( ( reference ) != null ) && ( ! ( reference . isEmpty ( ) ) ) ) { File referencePath = new File ( reference ) ; if ( ! ( referencePath . exists ( ) ) ) listener . error ( ( "Reference<seq2seq4repair_space>path<seq2seq4repair_space>does<seq2seq4repair_space>not<seq2seq4repair_space>exist:<seq2seq4repair_space>" + ( reference ) ) ) ; else if ( ! ( referencePath . isDirectory ( ) ) ) listener . error ( ( "Reference<seq2seq4repair_space>path<seq2seq4repair_space>is<seq2seq4repair_space>not<seq2seq4repair_space>a<seq2seq4repair_space>directory:<seq2seq4repair_space>" + ( reference ) ) ) ; else { File objectsPath = new File ( referencePath , ".git//objects" ) ; if ( ! ( objectsPath . isDirectory ( ) ) ) { objectsPath = new File ( referencePath , "objects" ) ; } if ( ! ( objectsPath . isDirectory ( ) ) ) listener . error ( ( "Reference<seq2seq4repair_space>path<seq2seq4repair_space>does<seq2seq4repair_space>not<seq2seq4repair_space>contain<seq2seq4repair_space>an<seq2seq4repair_space>objects<seq2seq4repair_space>directory<seq2seq4repair_space>(no<seq2seq4repair_space>git<seq2seq4repair_space>repo?):<seq2seq4repair_space>" + objectsPath ) ) ; else { try { File alternates = new File ( workspace , ".git//objects//info//alternates" ) ; <START_BUG> PrintWriter w = new PrintWriter ( alternates ) ; <END_BUG> w . print ( objectsPath . getAbsolutePath ( ) . replace ( '\\' , '//' ) ) ; w . close ( ) ; } catch ( FileNotFoundException e ) { listener . error ( "Failed<seq2seq4repair_space>to<seq2seq4repair_space>setup<seq2seq4repair_space>reference" ) ; } } } } repository . close ( ) ; repository = getRepository ( ) ; RefSpec refSpec = new RefSpec ( ( ( "+refs//heads//*:refs//remotes//" + ( remote ) ) + "//*" ) ) ; FetchCommand fetch = new Git ( repository ) . fetch ( ) . setProgressMonitor ( new JGitProgressMonitor ( listener ) ) . setRemote ( url ) . setCredentialsProvider ( getProvider ( ) ) . setRefSpecs ( refSpec ) ; if ( ( timeout ) != null ) fetch . setTimeout ( timeout ) ; fetch . call ( ) ; StoredConfig config = repository . getConfig ( ) ; config . setString ( "remote" , remote , "url" , url ) ; config . setString ( "remote" , remote , "fetch" , refSpec . toString ( ) ) ; config . save ( ) ; } catch ( GitAPIException e ) { throw new GitException ( e ) ; } catch ( IOException e ) { throw new GitException ( e ) ; } finally { if ( repository != null ) repository . close ( ) ; } } } ; } public MergeCommand merge ( ) { } public InitCommand init_ ( ) { } public void deleteTag ( String tagName ) throws GitException { } public String getTagMessage ( String tagName ) throws GitException { }

Fix:
PrintWriter w = new PrintWriter ( alternates , "UTF-8" ) ;