Skip to content

Commit

Permalink
Merge branch 'apolloconfig:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
klboke authored Jul 1, 2022
2 parents e85d645 + 471f59d commit 347e07b
Show file tree
Hide file tree
Showing 24 changed files with 40 additions and 27 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ Apollo 2.1.0
* [fix:occur a 400 error request when openapi key's parameter contain "a[0]"](https://github.com/apolloconfig/apollo/pull/4424)
* [Upgrade mysql-connector-java version to fix possible transaction rollback failure issue](https://github.com/apolloconfig/apollo/pull/4425)
* [Remove database migration tool Flyway](https://github.com/apolloconfig/apollo/pull/4361)
* [Optimize Spring-Security Firewall Deny Request Response 400](https://github.com/apolloconfig/apollo/pull/4428)
------------------
All issues and pull requests are [here](https://github.com/apolloconfig/apollo/milestone/11?closed=1)
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import org.springframework.test.annotation.Rollback;

import static org.hamcrest.Matchers.hasSize;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;

/**
* Created by kezhenxu94 at 2019/1/18 15:33.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ public String[] getArrayProperty(String key, final String delimiter, String[] de
if (!m_arrayCache.containsKey(delimiter)) {
synchronized (this) {
if (!m_arrayCache.containsKey(delimiter)) {
m_arrayCache.put(delimiter, this.<String[]>newCache());
m_arrayCache.put(delimiter, this.newCache());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private void processPropertyValues(BeanDefinitionRegistry beanRegistry) {
}

if (!beanName2SpringValueDefinitions.containsKey(beanRegistry)) {
beanName2SpringValueDefinitions.put(beanRegistry, LinkedListMultimap.<String, SpringValueDefinition>create());
beanName2SpringValueDefinitions.put(beanRegistry, LinkedListMultimap.create());
}

Multimap<String, SpringValueDefinition> springValueDefinitions = beanName2SpringValueDefinitions.get(beanRegistry);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void register(BeanFactory beanFactory, String key, SpringValue springValu
if (!registry.containsKey(beanFactory)) {
synchronized (LOCK) {
if (!registry.containsKey(beanFactory)) {
registry.put(beanFactory, Multimaps.synchronizedListMultimap(LinkedListMultimap.<String, SpringValue>create()));
registry.put(beanFactory, Multimaps.synchronizedListMultimap(LinkedListMultimap.create()));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* @author Jason Song([email protected])
*/
public class HttpRequest {
private String m_url;
private final String m_url;
private Map<String, String> headers;
private int m_connectTimeout;
private int m_readTimeout;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertTrue;

import com.ctrip.framework.apollo.util.OrderedProperties;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.mockito.Mockito.mock;

import com.ctrip.framework.apollo.enums.ConfigSourceType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,7 @@ public void testGetPropertyWithFunction() throws Exception {
public List<String> apply(String s) {
return Splitter.on(",").trimResults().omitEmptyStrings().splitToList(s);
}
}, Lists.<String>newArrayList()), Lists.newArrayList("a", "b", "c"));
}, Lists.newArrayList()), Lists.newArrayList("a", "b", "c"));
assertEquals(defaultConfig.getProperty(someNullKey, new Function<String, List<String>>() {
@Override
public List<String> apply(String s) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import static org.hamcrest.core.IsEqual.equalTo;
import static org.hamcrest.core.IsInstanceOf.instanceOf;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;

import org.junit.After;
import org.junit.Before;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import static org.hamcrest.core.IsInstanceOf.instanceOf;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;

import org.junit.Before;
import org.junit.Test;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,25 @@
package com.ctrip.framework.apollo.common;

import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpStatus;
import org.springframework.security.web.firewall.HttpStatusRequestRejectedHandler;
import org.springframework.security.web.firewall.RequestRejectedHandler;

@EnableAutoConfiguration
@Configuration
@ComponentScan(basePackageClasses = ApolloCommonConfig.class)
public class ApolloCommonConfig {

/**
* Spring-Security Firewall Deny Request Response 400
* @return RequestRejectedHandler
*/
@Bean
public RequestRejectedHandler requestRejectedHandler() {
return new HttpStatusRequestRejectedHandler(HttpStatus.BAD_REQUEST.value());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@ public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata)
if (!StringUtils.isEmpty(context.getEnvironment().getProperty("uat.titan.url"))) {
return true;
}
if (!StringUtils.isEmpty(context.getEnvironment().getProperty("pro.titan.url"))) {
return true;
}
return false;
return !StringUtils.isEmpty(context.getEnvironment().getProperty("pro.titan.url"));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public TitanEntityManager(final TitanSettings settings) {
public DataSource datasource() throws Exception {
Class clazz = Class.forName("com.ctrip.datasource.configure.DalDataSourceFactory");
Object obj = clazz.newInstance();
Method method = clazz.getMethod("createDataSource", new Class[] {String.class, String.class});
Method method = clazz.getMethod("createDataSource", String.class, String.class);
DataSource ds = ((DataSource) method.invoke(obj,
new Object[] {settings.getTitanDbname(), settings.getTitanUrl()}));
Tracer.logEvent("Apollo.Datasource.Titan", settings.getTitanDbname());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class ApolloNotificationMessages {
private Map<String, Long> details;

public ApolloNotificationMessages() {
this(Maps.<String, Long>newTreeMap());
this(Maps.newTreeMap());
}

private ApolloNotificationMessages(Map<String, Long> details) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public static Properties readConfigFile(String configPath, Properties defaults)

}
if (sb.length() > 0) {
logger.debug("Reading properties: \n" + sb.toString());
logger.debug("Reading properties: \n" + sb);
} else {
logger.warn("No available properties: {}", configPath);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ private void load() {

try {
Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
List<NetworkInterface> nis = interfaces == null ? Collections.<NetworkInterface>emptyList()
List<NetworkInterface> nis = interfaces == null ? Collections.emptyList()
: Collections.list(interfaces);
//sort the network interfaces according to the index asc
Collections.sort(nis, new Comparator<NetworkInterface>() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static void main(String[] args) throws IOException {
System.exit(0);
}

System.out.println(annotatedBean.toString());
System.out.println(annotatedBean);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ public SpringBootApolloRefreshConfig(
public void onChange(ConfigChangeEvent changeEvent) {
logger.info("before refresh {}", sampleRedisConfig.toString());
refreshScope.refresh("sampleRedisConfig");
logger.info("after refresh {}", sampleRedisConfig.toString());
logger.info("after refresh {}", sampleRedisConfig);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static void main(String[] args) throws IOException {
System.exit(0);
}

System.out.println(xmlBean.toString());
System.out.println(xmlBean);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public ItemChangeSets resolve(long namespaceId, String configText, List<ItemDTO>
String[] newItems = configText.split(ITEM_SEPARATOR);
Set<String> repeatKeys = new HashSet<>();
if (isHasRepeatKey(newItems, repeatKeys)) {
throw new BadRequestException(String.format("Config text has repeated keys: %s, please check your input.", repeatKeys.toString()));
throw new BadRequestException(String.format("Config text has repeated keys: %s, please check your input.", repeatKeys));
}

ItemChangeSets changeSets = new ItemChangeSets();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@
package com.ctrip.framework.apollo.portal.controller;

import com.ctrip.framework.apollo.portal.AbstractIntegrationTest;
import java.util.List;
import org.junit.Test;
import org.springframework.web.client.HttpClientErrorException;

import java.util.List;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.StringContains.containsString;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;

/**
Expand All @@ -40,7 +42,7 @@ public void shouldFailWhenPageOrSiseIsNegative() {
);
fail("should throw");
} catch (final HttpClientErrorException e) {
assertThat(
assertThat(
new String(e.getResponseBodyAsByteArray()), containsString("page should be positive or 0")
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import org.springframework.web.client.HttpClientErrorException;
import static org.hamcrest.core.StringContains.containsString;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;

/**
* Created by kezhenxu at 2019/1/14 13:24.
Expand Down

0 comments on commit 347e07b

Please sign in to comment.