From 90952a2dd9a42d15aa9705b86c0416c3b69bc421 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Mon, 24 Apr 2023 14:44:04 +0100 Subject: [PATCH] Do not turn a null Flyway-specific password into an empty string It prevents using PGPASS for authentication with Postgres. Fixes gh-35110 --- .../boot/autoconfigure/flyway/FlywayProperties.java | 4 ++-- .../autoconfigure/flyway/FlywayAutoConfigurationTests.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayProperties.java index 9c8663e32e..46edd4f818 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2022 the original author or authors. + * Copyright 2012-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -601,7 +601,7 @@ public class FlywayProperties { } public String getPassword() { - return (this.password != null) ? this.password : ""; + return this.password; } public void setPassword(String password) { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfigurationTests.java index f6cd5f2f14..e53ef5277a 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfigurationTests.java @@ -154,7 +154,7 @@ class FlywayAutoConfigurationTests { DataSource dataSource = context.getBean(Flyway.class).getConfiguration().getDataSource(); assertThat(dataSource).isNotNull(); assertThat(dataSource).hasFieldOrPropertyWithValue("username", null); - assertThat(dataSource).hasFieldOrPropertyWithValue("password", ""); + assertThat(dataSource).hasFieldOrPropertyWithValue("password", null); }); }