From 26fba6b2b7a918cf6b8995a7216389f8525ecff3 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 14 Jun 2023 23:46:26 +0200 Subject: [PATCH] CliGitAPIImpl: reconcile use of PrintWriter with changes in the PR #644 (by @markewaite) --- .../org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java b/src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java index 8f4ecd39bd..c872332ea5 100644 --- a/src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java +++ b/src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java @@ -874,13 +874,16 @@ public void execute() throws GitException, InterruptedException { } else { // Go behind git's back to write a meta file in new workspace File alternates = new File(workspace, ".git/objects/info/alternates"); - try (PrintWriter w = new PrintWriter(alternates, Charset.defaultCharset())) { + try (PrintWriter w = new PrintWriter( + alternates, Charset.defaultCharset().toString())) { String absoluteReference = objectsPath.getAbsolutePath().replace('\\', '/'); listener.getLogger().println("Using reference repository: " + reference); // git implementations on windows also use w.print(absoluteReference); - } catch (IOException e) { + } catch (UnsupportedEncodingException ex) { + listener.error("Default character set is an unsupported encoding"); + } catch (FileNotFoundException e) { listener.error("Failed to setup reference"); } }