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;
import org.springframework.beans.factory.BeanFactoryAware; import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.BeanNameAware; import org.springframework.beans.factory.BeanNameAware;
import org.springframework.util.StringValueResolver; import org.springframework.util.StringValueResolver;
import org.springframework.util.SystemPropertyUtils;
/** /**
* Abstract base class for property resource configurers that resolve placeholders * Abstract base class for property resource configurers that resolve placeholders
@ -93,16 +94,16 @@ public abstract class PlaceholderConfigurerSupport extends PropertyResourceConfi
implements BeanNameAware, BeanFactoryAware { implements BeanNameAware, BeanFactoryAware {
/** Default placeholder prefix: {@value}. */ /** 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}. */ /** 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}. */ /** 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 '\'}. */ /** 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}. */ /** Defaults to {@value #DEFAULT_PLACEHOLDER_PREFIX}. */
@ -155,9 +156,10 @@ public abstract class PlaceholderConfigurerSupport extends PropertyResourceConfi
} }
/** /**
* Specify the escape character to use to ignore the placeholder prefix or * Set the escape character to use to ignore the
* value separator, or {@code null} if no escaping should take place. * {@linkplain #setPlaceholderPrefix(String) placeholder prefix} and the
* <p>Default is {@link #DEFAULT_ESCAPE_CHARACTER}. * {@linkplain #setValueSeparator(String) value separator}, or {@code null}
* if no escaping should take place.
* @since 6.2 * @since 6.2
*/ */
public void setEscapeCharacter(@Nullable Character escapeCharacter) { 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
} }
/** /**
* Set the prefix that placeholders replaced by this resolver must begin with. * {@inheritDoc}
* <p>The default is "${". * <p>The default is <code>"${"</code>.
* @see org.springframework.util.SystemPropertyUtils#PLACEHOLDER_PREFIX * @see SystemPropertyUtils#PLACEHOLDER_PREFIX
*/ */
@Override @Override
public void setPlaceholderPrefix(String placeholderPrefix) { public void setPlaceholderPrefix(String placeholderPrefix) {
@ -97,9 +97,9 @@ public abstract class AbstractPropertyResolver implements ConfigurablePropertyRe
} }
/** /**
* Set the suffix that placeholders replaced by this resolver must end with. * {@inheritDoc}
* <p>The default is "}". * <p>The default is <code>"}"</code>.
* @see org.springframework.util.SystemPropertyUtils#PLACEHOLDER_SUFFIX * @see SystemPropertyUtils#PLACEHOLDER_SUFFIX
*/ */
@Override @Override
public void setPlaceholderSuffix(String placeholderSuffix) { public void setPlaceholderSuffix(String placeholderSuffix) {
@ -108,11 +108,9 @@ public abstract class AbstractPropertyResolver implements ConfigurablePropertyRe
} }
/** /**
* Specify the separating character between the placeholders replaced by this * {@inheritDoc}
* resolver and their associated default value, or {@code null} if no such * <p>The default is {@code ":"}.
* special character should be processed as a value separator. * @see SystemPropertyUtils#VALUE_SEPARATOR
* <p>The default is ":".
* @see org.springframework.util.SystemPropertyUtils#VALUE_SEPARATOR
*/ */
@Override @Override
public void setValueSeparator(@Nullable String valueSeparator) { public void setValueSeparator(@Nullable String valueSeparator) {
@ -120,12 +118,10 @@ public abstract class AbstractPropertyResolver implements ConfigurablePropertyRe
} }
/** /**
* Specify the escape character to use to ignore placeholder prefix * {@inheritDoc}
* or value separator, or {@code null} if no escaping should take * <p>The default is {@code '\'}.
* place.
* <p>The default is '\'.
* @since 6.2 * @since 6.2
* @see org.springframework.util.SystemPropertyUtils#ESCAPE_CHARACTER * @see SystemPropertyUtils#ESCAPE_CHARACTER
*/ */
@Override @Override
public void setEscapeCharacter(@Nullable Character escapeCharacter) { public void setEscapeCharacter(@Nullable Character escapeCharacter) {

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

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -35,16 +35,19 @@ import org.jspecify.annotations.Nullable;
*/ */
public abstract class SystemPropertyUtils { public abstract class SystemPropertyUtils {
/** Prefix for system property placeholders: {@value}. */ /** Prefix for property placeholders: {@value}. */
public static final String PLACEHOLDER_PREFIX = "${"; public static final String PLACEHOLDER_PREFIX = "${";
/** Suffix for system property placeholders: {@value}. */ /** Suffix for property placeholders: {@value}. */
public static final String PLACEHOLDER_SUFFIX = "}"; 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 = ":"; 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 = '\\'; public static final Character ESCAPE_CHARACTER = '\\';

Loading…
Cancel
Save