diff --git a/src/main/java/org/liquibase/ext/resource/git/GitConfiguration.java b/src/main/java/org/liquibase/ext/resource/git/GitConfiguration.java index a596a4d..ff310c9 100644 --- a/src/main/java/org/liquibase/ext/resource/git/GitConfiguration.java +++ b/src/main/java/org/liquibase/ext/resource/git/GitConfiguration.java @@ -2,6 +2,7 @@ import liquibase.configuration.AutoloadedConfigurations; import liquibase.configuration.ConfigurationDefinition; +import liquibase.configuration.ConfigurationValueObfuscator; public class GitConfiguration implements AutoloadedConfigurations { @@ -20,6 +21,7 @@ public class GitConfiguration implements AutoloadedConfigurations { GIT_PASSWORD = builder.define("password", String.class) .addAliasKey("git.password") .setDescription("Git password for searchPath repository URL") + .setValueObfuscator(ConfigurationValueObfuscator.STANDARD) .build(); GIT_PATH = builder.define("path", String.class) .addAliasKey("git.path") diff --git a/src/main/java/org/liquibase/ext/resource/git/GitPathHandler.java b/src/main/java/org/liquibase/ext/resource/git/GitPathHandler.java index ce401b8..8238050 100644 --- a/src/main/java/org/liquibase/ext/resource/git/GitPathHandler.java +++ b/src/main/java/org/liquibase/ext/resource/git/GitPathHandler.java @@ -52,18 +52,16 @@ public ResourceAccessor getResourceAccessor(String root) throws IOException { if (!path.exists()) { path.mkdirs(); } - Repository repository = null; - try { - RepositoryBuilder repositoryBuilder = new RepositoryBuilder().setGitDir(gitPath); - repository = repositoryBuilder.build(); + try (Repository repository = new RepositoryBuilder().setGitDir(gitPath).build()) { if (repository.getObjectDatabase().exists()) { - Git git = Git.open(path); - if (branch != null && !branch.isEmpty()) { - git.checkout().setName(branch).call(); - } else { - git.pull().call(); + try (Git git = Git.open(path)) { + if (branch != null && !branch.isEmpty()) { + git.checkout().setName(branch).call(); + } else { + git.pull().call(); + } + Scope.getCurrentScope().getLog(GitPathHandler.class).fine("Repository updated: " + path); } - Scope.getCurrentScope().getLog(GitPathHandler.class).fine("Repository updated: " + path); } else { CloneCommand cloneCommand = this.getCloneCommand(root, path, branch); cloneCommand.call(); @@ -71,11 +69,6 @@ public ResourceAccessor getResourceAccessor(String root) throws IOException { } } catch (GitAPIException | JGitInternalException e) { throw new IOException(e.getMessage()); - } finally { - if (repository != null) { - repository.close(); - } - Git.shutdown(); } Scope.getCurrentScope().getLog(GitPathHandler.class).fine("Return DirectoryResourceAccessor for root path " + path); return new DirectoryResourceAccessor(path);