From cd76da9a4cae4fcc718a584fe8f6a3c3d7c42bab Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Thu, 16 Mar 2017 12:39:48 +0100 Subject: [PATCH] Avoid using immutable collections for configuration proprerties Closes gh-8620 --- .../elasticsearch/jest/JestProperties.java | 8 +++++--- .../autoconfigure/flyway/FlywayProperties.java | 8 ++++---- .../security/SecurityProperties.java | 7 ++++--- .../boot/jta/narayana/NarayanaProperties.java | 15 ++++++++------- 4 files changed, 21 insertions(+), 17 deletions(-) diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/elasticsearch/jest/JestProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/elasticsearch/jest/JestProperties.java index bb0ca4cef1..c912a3a89c 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/elasticsearch/jest/JestProperties.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/elasticsearch/jest/JestProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2017 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. @@ -16,7 +16,8 @@ package org.springframework.boot.autoconfigure.elasticsearch.jest; -import java.util.Arrays; +import java.util.ArrayList; +import java.util.Collections; import java.util.List; import org.springframework.boot.context.properties.ConfigurationProperties; @@ -33,7 +34,8 @@ public class JestProperties { /** * Comma-separated list of the Elasticsearch instances to use. */ - private List uris = Arrays.asList("http://localhost:9200"); + private List uris = new ArrayList( + Collections.singletonList("http://localhost:9200")); /** * Login user. diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayProperties.java index f63a4f6b71..951fc871f0 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayProperties.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2017 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. @@ -17,7 +17,6 @@ package org.springframework.boot.autoconfigure.flyway; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -40,7 +39,8 @@ public class FlywayProperties { /** * Locations of migrations scripts. */ - private List locations = new ArrayList(Arrays.asList("db/migration")); + private List locations = new ArrayList( + Collections.singletonList("db/migration")); /** * Check that migration scripts location exists. @@ -72,7 +72,7 @@ public class FlywayProperties { * SQL statements to execute to initialize a connection immediately after obtaining * it. */ - private List initSqls = Collections.emptyList(); + private List initSqls = new ArrayList(); public void setLocations(List locations) { this.locations = locations; diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/SecurityProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/SecurityProperties.java index 6a2771b91b..18d014a518 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/SecurityProperties.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/SecurityProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2017 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. @@ -17,7 +17,7 @@ package org.springframework.boot.autoconfigure.security; import java.util.ArrayList; -import java.util.Arrays; +import java.util.Collections; import java.util.List; import java.util.Set; import java.util.UUID; @@ -314,7 +314,8 @@ public class SecurityProperties implements SecurityPrerequisite { /** * Granted roles for the default user name. */ - private List role = new ArrayList(Arrays.asList("USER")); + private List role = new ArrayList( + Collections.singletonList("USER")); private boolean defaultPassword = true; diff --git a/spring-boot/src/main/java/org/springframework/boot/jta/narayana/NarayanaProperties.java b/spring-boot/src/main/java/org/springframework/boot/jta/narayana/NarayanaProperties.java index c3818652d8..e09c527821 100644 --- a/spring-boot/src/main/java/org/springframework/boot/jta/narayana/NarayanaProperties.java +++ b/spring-boot/src/main/java/org/springframework/boot/jta/narayana/NarayanaProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2017 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. @@ -16,6 +16,7 @@ package org.springframework.boot.jta.narayana; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -90,22 +91,22 @@ public class NarayanaProperties { /** * Comma-separated list of orphan filters. */ - private List xaResourceOrphanFilters = Arrays.asList( + private List xaResourceOrphanFilters = new ArrayList(Arrays.asList( "com.arjuna.ats.internal.jta.recovery.arjunacore.JTATransactionLogXAResourceOrphanFilter", - "com.arjuna.ats.internal.jta.recovery.arjunacore.JTANodeNameXAResourceOrphanFilter"); + "com.arjuna.ats.internal.jta.recovery.arjunacore.JTANodeNameXAResourceOrphanFilter")); /** * Comma-separated list of recovery modules. */ - private List recoveryModules = Arrays.asList( + private List recoveryModules = new ArrayList(Arrays.asList( "com.arjuna.ats.internal.arjuna.recovery.AtomicActionRecoveryModule", - "com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule"); + "com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule")); /** * Comma-separated list of expiry scanners. */ - private List expiryScanners = Collections.singletonList( - "com.arjuna.ats.internal.arjuna.recovery.ExpiredTransactionStatusManagerScanner"); + private List expiryScanners = new ArrayList(Collections.singletonList( + "com.arjuna.ats.internal.arjuna.recovery.ExpiredTransactionStatusManagerScanner")); public String getLogDir() { return this.logDir;