Browse Source

Merge branch '6.2.x'

pull/34884/head
Sam Brannen 11 months ago
parent
commit
18756c0701
  1. 16
      spring-beans/src/main/java/org/springframework/beans/factory/config/PlaceholderConfigurerSupport.java
  2. 28
      spring-core/src/main/java/org/springframework/core/env/AbstractPropertyResolver.java
  3. 13
      spring-core/src/main/java/org/springframework/util/SystemPropertyUtils.java

16
spring-beans/src/main/java/org/springframework/beans/factory/config/PlaceholderConfigurerSupport.java

@ -23,6 +23,7 @@ import org.springframework.beans.factory.BeanFactory; @@ -23,6 +23,7 @@ import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.util.StringValueResolver;
import org.springframework.util.SystemPropertyUtils;
/**
* Abstract base class for property resource configurers that resolve placeholders
@ -93,16 +94,16 @@ public abstract class PlaceholderConfigurerSupport extends PropertyResourceConfi @@ -93,16 +94,16 @@ public abstract class PlaceholderConfigurerSupport extends PropertyResourceConfi
implements BeanNameAware, BeanFactoryAware {
/** Default placeholder prefix: {@value}. */
public static final String DEFAULT_PLACEHOLDER_PREFIX = "${";
public static final String DEFAULT_PLACEHOLDER_PREFIX = SystemPropertyUtils.PLACEHOLDER_PREFIX;
/** Default placeholder suffix: {@value}. */
public static final String DEFAULT_PLACEHOLDER_SUFFIX = "}";
public static final String DEFAULT_PLACEHOLDER_SUFFIX = SystemPropertyUtils.PLACEHOLDER_SUFFIX;
/** Default value separator: {@value}. */
public static final String DEFAULT_VALUE_SEPARATOR = ":";
public static final String DEFAULT_VALUE_SEPARATOR = SystemPropertyUtils.VALUE_SEPARATOR;
/** Default escape character: {@code '\'}. */
public static final Character DEFAULT_ESCAPE_CHARACTER = '\\';
public static final Character DEFAULT_ESCAPE_CHARACTER = SystemPropertyUtils.ESCAPE_CHARACTER;
/** Defaults to {@value #DEFAULT_PLACEHOLDER_PREFIX}. */
@ -155,9 +156,10 @@ public abstract class PlaceholderConfigurerSupport extends PropertyResourceConfi @@ -155,9 +156,10 @@ public abstract class PlaceholderConfigurerSupport extends PropertyResourceConfi
}
/**
* Specify the escape character to use to ignore the placeholder prefix or
* value separator, or {@code null} if no escaping should take place.
* <p>Default is {@link #DEFAULT_ESCAPE_CHARACTER}.
* Set the escape character to use to ignore the
* {@linkplain #setPlaceholderPrefix(String) placeholder prefix} and the
* {@linkplain #setValueSeparator(String) value separator}, or {@code null}
* if no escaping should take place.
* @since 6.2
*/
public void setEscapeCharacter(@Nullable Character escapeCharacter) {

28
spring-core/src/main/java/org/springframework/core/env/AbstractPropertyResolver.java vendored

@ -86,9 +86,9 @@ public abstract class AbstractPropertyResolver implements ConfigurablePropertyRe @@ -86,9 +86,9 @@ public abstract class AbstractPropertyResolver implements ConfigurablePropertyRe
}
/**
* Set the prefix that placeholders replaced by this resolver must begin with.
* <p>The default is "${".
* @see org.springframework.util.SystemPropertyUtils#PLACEHOLDER_PREFIX
* {@inheritDoc}
* <p>The default is <code>"${"</code>.
* @see SystemPropertyUtils#PLACEHOLDER_PREFIX
*/
@Override
public void setPlaceholderPrefix(String placeholderPrefix) {
@ -97,9 +97,9 @@ public abstract class AbstractPropertyResolver implements ConfigurablePropertyRe @@ -97,9 +97,9 @@ public abstract class AbstractPropertyResolver implements ConfigurablePropertyRe
}
/**
* Set the suffix that placeholders replaced by this resolver must end with.
* <p>The default is "}".
* @see org.springframework.util.SystemPropertyUtils#PLACEHOLDER_SUFFIX
* {@inheritDoc}
* <p>The default is <code>"}"</code>.
* @see SystemPropertyUtils#PLACEHOLDER_SUFFIX
*/
@Override
public void setPlaceholderSuffix(String placeholderSuffix) {
@ -108,11 +108,9 @@ public abstract class AbstractPropertyResolver implements ConfigurablePropertyRe @@ -108,11 +108,9 @@ public abstract class AbstractPropertyResolver implements ConfigurablePropertyRe
}
/**
* Specify the separating character between the placeholders replaced by this
* resolver and their associated default value, or {@code null} if no such
* special character should be processed as a value separator.
* <p>The default is ":".
* @see org.springframework.util.SystemPropertyUtils#VALUE_SEPARATOR
* {@inheritDoc}
* <p>The default is {@code ":"}.
* @see SystemPropertyUtils#VALUE_SEPARATOR
*/
@Override
public void setValueSeparator(@Nullable String valueSeparator) {
@ -120,12 +118,10 @@ public abstract class AbstractPropertyResolver implements ConfigurablePropertyRe @@ -120,12 +118,10 @@ public abstract class AbstractPropertyResolver implements ConfigurablePropertyRe
}
/**
* Specify the escape character to use to ignore placeholder prefix
* or value separator, or {@code null} if no escaping should take
* place.
* <p>The default is '\'.
* {@inheritDoc}
* <p>The default is {@code '\'}.
* @since 6.2
* @see org.springframework.util.SystemPropertyUtils#ESCAPE_CHARACTER
* @see SystemPropertyUtils#ESCAPE_CHARACTER
*/
@Override
public void setEscapeCharacter(@Nullable Character escapeCharacter) {

13
spring-core/src/main/java/org/springframework/util/SystemPropertyUtils.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 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.
@ -35,16 +35,19 @@ import org.jspecify.annotations.Nullable; @@ -35,16 +35,19 @@ import org.jspecify.annotations.Nullable;
*/
public abstract class SystemPropertyUtils {
/** Prefix for system property placeholders: {@value}. */
/** Prefix for property placeholders: {@value}. */
public static final String PLACEHOLDER_PREFIX = "${";
/** Suffix for system property placeholders: {@value}. */
/** Suffix for property placeholders: {@value}. */
public static final String PLACEHOLDER_SUFFIX = "}";
/** Value separator for system property placeholders: {@value}. */
/** Value separator for property placeholders: {@value}. */
public static final String VALUE_SEPARATOR = ":";
/** Default escape character: {@code '\'}. */
/**
* Escape character for property placeholders: {@code '\'}.
* @since 6.2
*/
public static final Character ESCAPE_CHARACTER = '\\';

Loading…
Cancel
Save