parent
1ea3e95ff6
commit
4464a5f5bd
|
|
@ -21,7 +21,6 @@ import java.time.Duration;
|
|||
import io.micrometer.statsd.StatsdFlavor;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.context.properties.DeprecatedConfigurationProperty;
|
||||
|
||||
/**
|
||||
* {@link ConfigurationProperties} for configuring StatsD metrics export.
|
||||
|
|
@ -65,11 +64,6 @@ public class StatsdProperties {
|
|||
*/
|
||||
private Duration pollingFrequency = Duration.ofSeconds(10);
|
||||
|
||||
/**
|
||||
* Maximum size of the queue of items waiting to be sent to the StatsD server.
|
||||
*/
|
||||
private Integer queueSize = Integer.MAX_VALUE;
|
||||
|
||||
/**
|
||||
* Whether to send unchanged meters to the StatsD server.
|
||||
*/
|
||||
|
|
@ -123,17 +117,6 @@ public class StatsdProperties {
|
|||
this.pollingFrequency = pollingFrequency;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@DeprecatedConfigurationProperty(reason = "No longer configurable and an unbounded queue will always be used")
|
||||
public Integer getQueueSize() {
|
||||
return this.queueSize;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setQueueSize(Integer queueSize) {
|
||||
this.queueSize = queueSize;
|
||||
}
|
||||
|
||||
public boolean isPublishUnchangedMeters() {
|
||||
return this.publishUnchangedMeters;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,12 +73,6 @@ public class StatsdPropertiesConfigAdapter
|
|||
StatsdConfig.super::pollingFrequency);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public int queueSize() {
|
||||
return get(StatsdProperties::getQueueSize, StatsdConfig.super::queueSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean publishUnchangedMeters() {
|
||||
return get(StatsdProperties::isPublishUnchangedMeters,
|
||||
|
|
|
|||
|
|
@ -1,150 +0,0 @@
|
|||
/*
|
||||
* Copyright 2012-2018 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.actuate.metrics.web.reactive.server;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
import io.micrometer.core.instrument.MeterRegistry;
|
||||
import io.micrometer.core.instrument.Tag;
|
||||
import io.micrometer.core.instrument.Tags;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.web.reactive.function.server.HandlerFilterFunction;
|
||||
import org.springframework.web.reactive.function.server.HandlerFunction;
|
||||
import org.springframework.web.reactive.function.server.RouterFunction;
|
||||
import org.springframework.web.reactive.function.server.ServerRequest;
|
||||
import org.springframework.web.reactive.function.server.ServerResponse;
|
||||
|
||||
/**
|
||||
* Support class for WebFlux {@link RouterFunction}-related metrics.
|
||||
*
|
||||
* @author Jon Schneider
|
||||
* @since 2.0.0
|
||||
* @deprecated in favor of the auto-configured {@link MetricsWebFilter}
|
||||
*/
|
||||
@Deprecated
|
||||
public class RouterFunctionMetrics {
|
||||
|
||||
private final MeterRegistry registry;
|
||||
|
||||
private final BiFunction<ServerRequest, ServerResponse, Iterable<Tag>> defaultTags;
|
||||
|
||||
public RouterFunctionMetrics(MeterRegistry registry) {
|
||||
Assert.notNull(registry, "Registry must not be null");
|
||||
this.registry = registry;
|
||||
this.defaultTags = this::defaultTags;
|
||||
}
|
||||
|
||||
private RouterFunctionMetrics(MeterRegistry registry,
|
||||
BiFunction<ServerRequest, ServerResponse, Iterable<Tag>> defaultTags) {
|
||||
Assert.notNull(registry, "Registry must not be null");
|
||||
Assert.notNull(defaultTags, "DefaultTags must not be null");
|
||||
this.registry = registry;
|
||||
this.defaultTags = defaultTags;
|
||||
}
|
||||
|
||||
private Iterable<Tag> defaultTags(ServerRequest request, ServerResponse response) {
|
||||
if (response == null) {
|
||||
return Tags.of(getMethodTag(request));
|
||||
}
|
||||
return Tags.of(getMethodTag(request), getStatusTag(response));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new {@link RouterFunctionMetrics} instance with the specified default
|
||||
* tags.
|
||||
* @param defaultTags Generate a list of tags to apply to the timer.
|
||||
* {@code ServerResponse} may be null.
|
||||
* @return {@code this} for further configuration
|
||||
*/
|
||||
public RouterFunctionMetrics defaultTags(
|
||||
BiFunction<ServerRequest, ServerResponse, Iterable<Tag>> defaultTags) {
|
||||
return new RouterFunctionMetrics(this.registry, defaultTags);
|
||||
}
|
||||
|
||||
public HandlerFilterFunction<ServerResponse, ServerResponse> timer(String name) {
|
||||
return timer(name, Tags.empty());
|
||||
}
|
||||
|
||||
public HandlerFilterFunction<ServerResponse, ServerResponse> timer(String name,
|
||||
String... tags) {
|
||||
return timer(name, Tags.of(tags));
|
||||
}
|
||||
|
||||
public HandlerFilterFunction<ServerResponse, ServerResponse> timer(String name,
|
||||
Iterable<Tag> tags) {
|
||||
return new MetricsFilter(name, Tags.of(tags));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@code method} tag from the method of the given {@code request}.
|
||||
* @param request The HTTP request.
|
||||
* @return A "method" tag whose value is a capitalized method (e.g. GET).
|
||||
*/
|
||||
public static Tag getMethodTag(ServerRequest request) {
|
||||
return Tag.of("method", request.method().toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@code status} tag from the status of the given {@code response}.
|
||||
* @param response The HTTP response.
|
||||
* @return A "status" tag whose value is the numeric status code.
|
||||
*/
|
||||
public static Tag getStatusTag(ServerResponse response) {
|
||||
return Tag.of("status", response.statusCode().toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link HandlerFilterFunction} to handle calling micrometer.
|
||||
*/
|
||||
private class MetricsFilter
|
||||
implements HandlerFilterFunction<ServerResponse, ServerResponse> {
|
||||
|
||||
private final String name;
|
||||
|
||||
private final Tags tags;
|
||||
|
||||
MetricsFilter(String name, Tags tags) {
|
||||
this.name = name;
|
||||
this.tags = tags;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<ServerResponse> filter(ServerRequest request,
|
||||
HandlerFunction<ServerResponse> next) {
|
||||
long start = System.nanoTime();
|
||||
return next.handle(request)
|
||||
.doOnSuccess((response) -> timer(start, request, response))
|
||||
.doOnError((error) -> timer(start, request, null));
|
||||
}
|
||||
|
||||
private Iterable<Tag> getDefaultTags(ServerRequest request,
|
||||
ServerResponse response) {
|
||||
return RouterFunctionMetrics.this.defaultTags.apply(request, response);
|
||||
}
|
||||
|
||||
private void timer(long start, ServerRequest request, ServerResponse response) {
|
||||
Tags allTags = this.tags.and(getDefaultTags(request, response));
|
||||
RouterFunctionMetrics.this.registry.timer(this.name, allTags)
|
||||
.record(System.nanoTime() - start, TimeUnit.NANOSECONDS);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -17,7 +17,6 @@
|
|||
package org.springframework.boot.autoconfigure.couchbase;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
import com.couchbase.client.core.env.KeyValueServiceConfig;
|
||||
import com.couchbase.client.core.env.QueryServiceConfig;
|
||||
|
|
@ -29,7 +28,6 @@ import com.couchbase.client.java.cluster.ClusterInfo;
|
|||
import com.couchbase.client.java.env.DefaultCouchbaseEnvironment;
|
||||
|
||||
import org.springframework.boot.autoconfigure.couchbase.CouchbaseProperties.Endpoints;
|
||||
import org.springframework.boot.autoconfigure.couchbase.CouchbaseProperties.Endpoints.CouchbaseService;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.DependsOn;
|
||||
|
|
@ -129,25 +127,14 @@ public class CouchbaseConfiguration {
|
|||
return builder;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private QueryServiceConfig getQueryServiceConfig(Endpoints endpoints) {
|
||||
return getServiceConfig(endpoints.getQueryservice(), endpoints.getQuery(),
|
||||
QueryServiceConfig::create);
|
||||
return QueryServiceConfig.create(endpoints.getQueryservice().getMinEndpoints(),
|
||||
endpoints.getQueryservice().getMaxEndpoints());
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private ViewServiceConfig getViewServiceConfig(Endpoints endpoints) {
|
||||
return getServiceConfig(endpoints.getViewservice(), endpoints.getView(),
|
||||
ViewServiceConfig::create);
|
||||
}
|
||||
|
||||
private <T> T getServiceConfig(CouchbaseService service, Integer fallback,
|
||||
BiFunction<Integer, Integer, T> factory) {
|
||||
if (service.getMinEndpoints() != 1 || service.getMaxEndpoints() != 1) {
|
||||
return factory.apply(service.getMinEndpoints(), service.getMaxEndpoints());
|
||||
}
|
||||
int endpoints = (fallback != null ? fallback : 1);
|
||||
return factory.apply(endpoints, endpoints);
|
||||
return ViewServiceConfig.create(endpoints.getViewservice().getMinEndpoints(),
|
||||
endpoints.getViewservice().getMaxEndpoints());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ import java.time.Duration;
|
|||
import java.util.List;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.context.properties.DeprecatedConfigurationProperty;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
|
|
@ -128,16 +127,6 @@ public class CouchbaseProperties {
|
|||
*/
|
||||
private final CouchbaseService viewservice = new CouchbaseService();
|
||||
|
||||
/**
|
||||
* Number of sockets per node against the query (N1QL) service.
|
||||
*/
|
||||
private Integer query;
|
||||
|
||||
/**
|
||||
* Number of sockets per node against the view service.
|
||||
*/
|
||||
private Integer view;
|
||||
|
||||
public int getKeyValue() {
|
||||
return this.keyValue;
|
||||
}
|
||||
|
|
@ -146,32 +135,10 @@ public class CouchbaseProperties {
|
|||
this.keyValue = keyValue;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@DeprecatedConfigurationProperty(replacement = "spring.couchbase.env.endpoints.queryservice.max-endpoints")
|
||||
public Integer getQuery() {
|
||||
return this.query;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setQuery(Integer query) {
|
||||
this.query = query;
|
||||
}
|
||||
|
||||
public CouchbaseService getQueryservice() {
|
||||
return this.queryservice;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@DeprecatedConfigurationProperty(replacement = "spring.couchbase.env.endpoints.viewservice.max-endpoints")
|
||||
public Integer getView() {
|
||||
return this.view;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setView(Integer view) {
|
||||
this.view = view;
|
||||
}
|
||||
|
||||
public CouchbaseService getViewservice() {
|
||||
return this.viewservice;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,18 +37,6 @@ public class HibernateSettings {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify the default ddl auto value to use.
|
||||
* @param ddlAuto the default ddl auto if none is provided
|
||||
* @return this instance
|
||||
* @see #ddlAuto(Supplier)
|
||||
* @deprecated as of 2.0.1 in favour of {@link #ddlAuto(Supplier)}
|
||||
*/
|
||||
@Deprecated
|
||||
public HibernateSettings ddlAuto(String ddlAuto) {
|
||||
return ddlAuto(() -> ddlAuto);
|
||||
}
|
||||
|
||||
public String getDdlAuto() {
|
||||
return (this.ddlAuto != null ? this.ddlAuto.get() : null);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -96,18 +96,6 @@ public class CouchbaseAutoConfigurationTests {
|
|||
"spring.couchbase.env.endpoints.viewservice.max-endpoints=6");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
public void customizeEnvEndpointsWithDeprecatedProperties() {
|
||||
testCouchbaseEnv((env) -> {
|
||||
assertThat(env.queryServiceConfig().minEndpoints()).isEqualTo(3);
|
||||
assertThat(env.queryServiceConfig().maxEndpoints()).isEqualTo(3);
|
||||
assertThat(env.viewServiceConfig().minEndpoints()).isEqualTo(4);
|
||||
assertThat(env.viewServiceConfig().maxEndpoints()).isEqualTo(4);
|
||||
}, "spring.couchbase.env.endpoints.query=3",
|
||||
"spring.couchbase.env.endpoints.view=4");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customizeEnvEndpointsUsesNewInfrastructure() {
|
||||
testCouchbaseEnv((env) -> {
|
||||
|
|
@ -115,10 +103,8 @@ public class CouchbaseAutoConfigurationTests {
|
|||
assertThat(env.queryServiceConfig().maxEndpoints()).isEqualTo(5);
|
||||
assertThat(env.viewServiceConfig().minEndpoints()).isEqualTo(4);
|
||||
assertThat(env.viewServiceConfig().maxEndpoints()).isEqualTo(6);
|
||||
}, "spring.couchbase.env.endpoints.query=33",
|
||||
"spring.couchbase.env.endpoints.queryservice.min-endpoints=3",
|
||||
}, "spring.couchbase.env.endpoints.queryservice.min-endpoints=3",
|
||||
"spring.couchbase.env.endpoints.queryservice.max-endpoints=5",
|
||||
"spring.couchbase.env.endpoints.view=44",
|
||||
"spring.couchbase.env.endpoints.viewservice.min-endpoints=4",
|
||||
"spring.couchbase.env.endpoints.viewservice.max-endpoints=6");
|
||||
}
|
||||
|
|
@ -130,9 +116,7 @@ public class CouchbaseAutoConfigurationTests {
|
|||
assertThat(env.queryServiceConfig().maxEndpoints()).isEqualTo(5);
|
||||
assertThat(env.viewServiceConfig().minEndpoints()).isEqualTo(1);
|
||||
assertThat(env.viewServiceConfig().maxEndpoints()).isEqualTo(6);
|
||||
}, "spring.couchbase.env.endpoints.query=33",
|
||||
"spring.couchbase.env.endpoints.queryservice.max-endpoints=5",
|
||||
"spring.couchbase.env.endpoints.view=44",
|
||||
}, "spring.couchbase.env.endpoints.queryservice.max-endpoints=5",
|
||||
"spring.couchbase.env.endpoints.viewservice.max-endpoints=6");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,105 +0,0 @@
|
|||
/*
|
||||
* Copyright 2012-2018 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.test.util;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.core.env.ConfigurableEnvironment;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.core.env.MapPropertySource;
|
||||
import org.springframework.core.env.MutablePropertySources;
|
||||
|
||||
/**
|
||||
* Test utilities for setting environment values.
|
||||
*
|
||||
* @author Dave Syer
|
||||
* @author Stephane Nicoll
|
||||
* @since 1.4.0
|
||||
* @deprecated since 2.0.0 in favor of {@link TestPropertyValues}
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract class EnvironmentTestUtils {
|
||||
|
||||
/**
|
||||
* Add additional (high priority) values to an {@link Environment} owned by an
|
||||
* {@link ApplicationContext}. Name-value pairs can be specified with colon (":") or
|
||||
* equals ("=") separators.
|
||||
* @param context the context with an environment to modify
|
||||
* @param pairs the name:value pairs
|
||||
*/
|
||||
public static void addEnvironment(ConfigurableApplicationContext context,
|
||||
String... pairs) {
|
||||
addEnvironment(context.getEnvironment(), pairs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add additional (high priority) values to an {@link Environment}. Name-value pairs
|
||||
* can be specified with colon (":") or equals ("=") separators.
|
||||
* @param environment the environment to modify
|
||||
* @param pairs the name:value pairs
|
||||
*/
|
||||
public static void addEnvironment(ConfigurableEnvironment environment,
|
||||
String... pairs) {
|
||||
addEnvironment("test", environment, pairs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add additional (high priority) values to an {@link Environment}. Name-value pairs
|
||||
* can be specified with colon (":") or equals ("=") separators.
|
||||
* @param environment the environment to modify
|
||||
* @param name the property source name
|
||||
* @param pairs the name:value pairs
|
||||
*/
|
||||
public static void addEnvironment(String name, ConfigurableEnvironment environment,
|
||||
String... pairs) {
|
||||
MutablePropertySources sources = environment.getPropertySources();
|
||||
Map<String, Object> map = getOrAdd(sources, name);
|
||||
for (String pair : pairs) {
|
||||
int index = getSeparatorIndex(pair);
|
||||
String key = (index > 0 ? pair.substring(0, index) : pair);
|
||||
String value = (index > 0 ? pair.substring(index + 1) : "");
|
||||
map.put(key.trim(), value.trim());
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static Map<String, Object> getOrAdd(MutablePropertySources sources,
|
||||
String name) {
|
||||
if (sources.contains(name)) {
|
||||
return (Map<String, Object>) sources.get(name).getSource();
|
||||
}
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
sources.addFirst(new MapPropertySource(name, map));
|
||||
return map;
|
||||
}
|
||||
|
||||
private static int getSeparatorIndex(String pair) {
|
||||
int colonIndex = pair.indexOf(':');
|
||||
int equalIndex = pair.indexOf('=');
|
||||
if (colonIndex == -1) {
|
||||
return equalIndex;
|
||||
}
|
||||
if (equalIndex == -1) {
|
||||
return colonIndex;
|
||||
}
|
||||
return Math.min(colonIndex, equalIndex);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,96 +0,0 @@
|
|||
/*
|
||||
* 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.test.util;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.core.env.ConfigurableEnvironment;
|
||||
import org.springframework.core.env.MapPropertySource;
|
||||
import org.springframework.core.env.StandardEnvironment;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link EnvironmentTestUtils}.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@Deprecated
|
||||
public class EnvironmentTestUtilsTests {
|
||||
|
||||
private final ConfigurableEnvironment environment = new StandardEnvironment();
|
||||
|
||||
@Test
|
||||
public void addSimplePairEqual() {
|
||||
testAddSimplePair("my.foo", "bar", "=");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addSimplePairColon() {
|
||||
testAddSimplePair("my.foo", "bar", ":");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addSimplePairEqualWithEqualInValue() {
|
||||
testAddSimplePair("my.foo", "b=ar", "=");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addSimplePairEqualWithColonInValue() {
|
||||
testAddSimplePair("my.foo", "b:ar", "=");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addSimplePairColonWithColonInValue() {
|
||||
testAddSimplePair("my.foo", "b:ar", ":");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addSimplePairColonWithEqualInValue() {
|
||||
testAddSimplePair("my.foo", "b=ar", ":");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addPairNoValue() {
|
||||
String propertyName = "my.foo+bar";
|
||||
assertThat(this.environment.containsProperty(propertyName)).isFalse();
|
||||
EnvironmentTestUtils.addEnvironment(this.environment, propertyName);
|
||||
assertThat(this.environment.containsProperty(propertyName)).isTrue();
|
||||
assertThat(this.environment.getProperty(propertyName)).isEqualTo("");
|
||||
}
|
||||
|
||||
private void testAddSimplePair(String key, String value, String delimiter) {
|
||||
assertThat(this.environment.containsProperty(key)).isFalse();
|
||||
EnvironmentTestUtils.addEnvironment(this.environment, key + delimiter + value);
|
||||
assertThat(this.environment.getProperty(key)).isEqualTo(value);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConfigHasHigherPrecedence() {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("my.foo", "bar");
|
||||
MapPropertySource source = new MapPropertySource("sample", map);
|
||||
this.environment.getPropertySources().addFirst(source);
|
||||
assertThat(this.environment.getProperty("my.foo")).isEqualTo("bar");
|
||||
EnvironmentTestUtils.addEnvironment(this.environment, "my.foo=bar2");
|
||||
assertThat(this.environment.getProperty("my.foo")).isEqualTo("bar2");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -932,17 +932,6 @@ public class SpringApplication {
|
|||
this.mainApplicationClass = mainApplicationClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this {@link SpringApplication} is running within a web environment.
|
||||
* @return {@code true} if running within a web environment, otherwise {@code false}.
|
||||
* @see #setWebEnvironment(boolean)
|
||||
* @deprecated since 2.0.0 in favor of {@link #getWebApplicationType()}
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean isWebEnvironment() {
|
||||
return this.webApplicationType == WebApplicationType.SERVLET;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type of web application that is being run.
|
||||
* @return the type of web application
|
||||
|
|
@ -952,19 +941,6 @@ public class SpringApplication {
|
|||
return this.webApplicationType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets if this application is running within a web environment. If not specified will
|
||||
* attempt to deduce the environment based on the classpath.
|
||||
* @param webEnvironment if the application is running in a web environment
|
||||
* @deprecated since 2.0.0 in favor of
|
||||
* {@link #setWebApplicationType(WebApplicationType)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void setWebEnvironment(boolean webEnvironment) {
|
||||
this.webApplicationType = (webEnvironment ? WebApplicationType.SERVLET
|
||||
: WebApplicationType.NONE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the type of web application to be run. If not explicitly set the type of web
|
||||
* application will be deduced based on the classpath.
|
||||
|
|
|
|||
|
|
@ -288,19 +288,6 @@ public class SpringApplicationBuilder {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Flag to explicitly request a web or non-web environment (auto detected based on
|
||||
* classpath if not set).
|
||||
* @param webEnvironment the flag to set
|
||||
* @return the current builder
|
||||
* @deprecated since 2.0.0 in favour of {@link #web(WebApplicationType)}
|
||||
*/
|
||||
@Deprecated
|
||||
public SpringApplicationBuilder web(boolean webEnvironment) {
|
||||
this.application.setWebEnvironment(webEnvironment);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Flag to explicitly request a specific type of web application. Auto-detected based
|
||||
* on the classpath if not set.
|
||||
|
|
|
|||
|
|
@ -17,9 +17,7 @@
|
|||
package org.springframework.boot.web.servlet.server;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URL;
|
||||
import java.net.URLDecoder;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
|
@ -282,23 +280,6 @@ public abstract class AbstractServletWebServerFactory
|
|||
return this.staticResourceJars.getUrls();
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the given {@code url} into a decoded file path.
|
||||
* @param url the url to convert
|
||||
* @return the file path
|
||||
* @deprecated Since 2.0.2 in favor of {@link File#File(java.net.URI)}
|
||||
*/
|
||||
@Deprecated
|
||||
protected final String getDecodedFile(URL url) {
|
||||
try {
|
||||
return URLDecoder.decode(url.getFile(), "UTF-8");
|
||||
}
|
||||
catch (UnsupportedEncodingException ex) {
|
||||
throw new IllegalStateException(
|
||||
"Failed to decode '" + url.getFile() + "' using UTF-8");
|
||||
}
|
||||
}
|
||||
|
||||
protected final File getValidSessionStoreDir() {
|
||||
return getValidSessionStoreDir(true);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue