Created
December 13, 2016 09:40
-
-
Save secwang/095976ed0808a66c342f154639d2f66b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 105566fb27b04178cc0badda510566a8a147526e Mon Sep 17 00:00:00 2001 | |
From: secwang <monadic.io@gmail.com> | |
Date: Tue, 13 Dec 2016 17:39:14 +0800 | |
Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=811.6.?= | |
MIME-Version: 1.0 | |
Content-Type: text/plain; charset=UTF-8 | |
Content-Transfer-Encoding: 8bit | |
--- | |
apollo-client/pom.xml | 2 +- | |
.../ctrip/framework/apollo/build/ComponentConfigurator.java | 2 +- | |
.../ctrip/framework/apollo/internals/AbstractConfigFile.java | 2 +- | |
.../ctrip/framework/apollo/internals/ConfigServiceLocator.java | 2 +- | |
.../com/ctrip/framework/apollo/internals/DefaultConfig.java | 4 ++-- | |
.../ctrip/framework/apollo/internals/PropertiesConfigFile.java | 2 +- | |
.../framework/apollo/internals/RemoteConfigRepository.java | 10 ++++++---- | |
.../java/com/ctrip/framework/apollo/util/http/HttpUtil.java | 4 ++-- | |
apollo-common/pom.xml | 1 + | |
.../common/controller/GlobalDefaultExceptionHandler.java | 4 ++-- | |
.../framework/apollo/common/dto/GrayReleaseRuleItemDTO.java | 5 ++--- | |
.../com/ctrip/framework/apollo/common/dto/ItemChangeSets.java | 6 +++--- | |
.../framework/apollo/common/http/MultiResponseEntity.java | 6 +++--- | |
.../ctrip/framework/apollo/common/http/RichResponseEntity.java | 4 ++-- | |
.../com/ctrip/framework/apollo/common/utils/BeanUtils.java | 2 +- | |
15 files changed, 29 insertions(+), 27 deletions(-) | |
diff --git a/apollo-client/pom.xml b/apollo-client/pom.xml | |
index f2d9a3b0f..b32e980b5 100644 | |
--- a/apollo-client/pom.xml | |
+++ b/apollo-client/pom.xml | |
@@ -11,7 +11,7 @@ | |
<artifactId>apollo-client</artifactId> | |
<name>Apollo Client</name> | |
<properties> | |
- <java.version>1.7</java.version> | |
+ <java.version>1.6</java.version> | |
<github.path>${project.artifactId}</github.path> | |
</properties> | |
<dependencies> | |
diff --git a/apollo-client/src/main/java/com/ctrip/framework/apollo/build/ComponentConfigurator.java b/apollo-client/src/main/java/com/ctrip/framework/apollo/build/ComponentConfigurator.java | |
index fa50ec075..e42b58fea 100644 | |
--- a/apollo-client/src/main/java/com/ctrip/framework/apollo/build/ComponentConfigurator.java | |
+++ b/apollo-client/src/main/java/com/ctrip/framework/apollo/build/ComponentConfigurator.java | |
@@ -25,7 +25,7 @@ public class ComponentConfigurator extends AbstractResourceConfigurator { | |
@Override | |
public List<Component> defineComponents() { | |
- List<Component> all = new ArrayList<>(); | |
+ List<Component> all = new ArrayList<Component>(); | |
all.add(A(DefaultConfigManager.class)); | |
all.add(A(DefaultConfigFactory.class)); | |
diff --git a/apollo-client/src/main/java/com/ctrip/framework/apollo/internals/AbstractConfigFile.java b/apollo-client/src/main/java/com/ctrip/framework/apollo/internals/AbstractConfigFile.java | |
index 5b21165c7..d42a2fc24 100644 | |
--- a/apollo-client/src/main/java/com/ctrip/framework/apollo/internals/AbstractConfigFile.java | |
+++ b/apollo-client/src/main/java/com/ctrip/framework/apollo/internals/AbstractConfigFile.java | |
@@ -22,7 +22,7 @@ public abstract class AbstractConfigFile implements ConfigFile, RepositoryChange | |
public AbstractConfigFile(String namespace, ConfigRepository configRepository) { | |
m_configRepository = configRepository; | |
m_namespace = namespace; | |
- m_configProperties = new AtomicReference<>(); | |
+ m_configProperties = new AtomicReference<Properties>(); | |
initialize(); | |
} | |
diff --git a/apollo-client/src/main/java/com/ctrip/framework/apollo/internals/ConfigServiceLocator.java b/apollo-client/src/main/java/com/ctrip/framework/apollo/internals/ConfigServiceLocator.java | |
index eb46a507c..f9b4993d6 100644 | |
--- a/apollo-client/src/main/java/com/ctrip/framework/apollo/internals/ConfigServiceLocator.java | |
+++ b/apollo-client/src/main/java/com/ctrip/framework/apollo/internals/ConfigServiceLocator.java | |
@@ -51,7 +51,7 @@ public class ConfigServiceLocator implements Initializable { | |
*/ | |
public ConfigServiceLocator() { | |
List<ServiceDTO> initial = Lists.newArrayList(); | |
- m_configServices = new AtomicReference<>(initial); | |
+ m_configServices = new AtomicReference<List<ServiceDTO>>(initial); | |
m_responseType = new TypeToken<List<ServiceDTO>>() { | |
}.getType(); | |
this.m_executorService = Executors.newScheduledThreadPool(1, | |
diff --git a/apollo-client/src/main/java/com/ctrip/framework/apollo/internals/DefaultConfig.java b/apollo-client/src/main/java/com/ctrip/framework/apollo/internals/DefaultConfig.java | |
index 0867a045d..89c452a12 100644 | |
--- a/apollo-client/src/main/java/com/ctrip/framework/apollo/internals/DefaultConfig.java | |
+++ b/apollo-client/src/main/java/com/ctrip/framework/apollo/internals/DefaultConfig.java | |
@@ -43,7 +43,7 @@ public class DefaultConfig extends AbstractConfig implements RepositoryChangeLis | |
m_namespace = namespace; | |
m_resourceProperties = loadFromResource(m_namespace); | |
m_configRepository = configRepository; | |
- m_configProperties = new AtomicReference<>(); | |
+ m_configProperties = new AtomicReference<Properties>(); | |
initialize(); | |
} | |
@@ -127,7 +127,7 @@ public class DefaultConfig extends AbstractConfig implements RepositoryChangeLis | |
calcPropertyChanges(m_namespace, m_configProperties.get(), newConfigProperties); | |
ImmutableMap.Builder<String, ConfigChange> actualChanges = | |
- new ImmutableMap.Builder<>(); | |
+ new ImmutableMap.Builder<String,ConfigChange>(); | |
/** === Double check since DefaultConfig has multiple config sources ==== **/ | |
diff --git a/apollo-client/src/main/java/com/ctrip/framework/apollo/internals/PropertiesConfigFile.java b/apollo-client/src/main/java/com/ctrip/framework/apollo/internals/PropertiesConfigFile.java | |
index d3fcc2007..970522926 100644 | |
--- a/apollo-client/src/main/java/com/ctrip/framework/apollo/internals/PropertiesConfigFile.java | |
+++ b/apollo-client/src/main/java/com/ctrip/framework/apollo/internals/PropertiesConfigFile.java | |
@@ -22,7 +22,7 @@ public class PropertiesConfigFile extends AbstractConfigFile { | |
public PropertiesConfigFile(String namespace, | |
ConfigRepository configRepository) { | |
super(namespace, configRepository); | |
- m_contentCache = new AtomicReference<>(); | |
+ m_contentCache = new AtomicReference<String>(); | |
} | |
@Override | |
diff --git a/apollo-client/src/main/java/com/ctrip/framework/apollo/internals/RemoteConfigRepository.java b/apollo-client/src/main/java/com/ctrip/framework/apollo/internals/RemoteConfigRepository.java | |
index 63b78e3ff..321b4b453 100644 | |
--- a/apollo-client/src/main/java/com/ctrip/framework/apollo/internals/RemoteConfigRepository.java | |
+++ b/apollo-client/src/main/java/com/ctrip/framework/apollo/internals/RemoteConfigRepository.java | |
@@ -69,7 +69,7 @@ public class RemoteConfigRepository extends AbstractConfigRepository { | |
*/ | |
public RemoteConfigRepository(String namespace) { | |
m_namespace = namespace; | |
- m_configCache = new AtomicReference<>(); | |
+ m_configCache = new AtomicReference<ApolloConfig>(); | |
m_container = ContainerLoader.getDefaultContainer(); | |
try { | |
m_configUtil = m_container.lookup(ConfigUtil.class); | |
@@ -80,7 +80,7 @@ public class RemoteConfigRepository extends AbstractConfigRepository { | |
Tracer.logError(ex); | |
throw new ApolloConfigException("Unable to load component!", ex); | |
} | |
- m_longPollServiceDto = new AtomicReference<>(); | |
+ m_longPollServiceDto = new AtomicReference<ServiceDTO>(); | |
m_loadConfigRateLimiter = RateLimiter.create(m_configUtil.getLoadConfigQPS()); | |
this.trySync(); | |
this.schedulePeriodicRefresh(); | |
@@ -117,7 +117,7 @@ public class RemoteConfigRepository extends AbstractConfigRepository { | |
} | |
@Override | |
- protected synchronized void sync() { | |
+ protected synchronized void sync() throws ApolloConfigException{ | |
Transaction transaction = Tracer.newTransaction("Apollo.ConfigService", "syncRemoteConfig"); | |
try { | |
@@ -137,9 +137,11 @@ public class RemoteConfigRepository extends AbstractConfigRepository { | |
} | |
transaction.setStatus(Transaction.SUCCESS); | |
- } catch (Throwable ex) { | |
+ } catch (ApolloConfigException ex) { | |
transaction.setStatus(ex); | |
throw ex; | |
+ } catch (Throwable th){ | |
+ transaction.setStatus(th); | |
} finally { | |
transaction.complete(); | |
} | |
diff --git a/apollo-client/src/main/java/com/ctrip/framework/apollo/util/http/HttpUtil.java b/apollo-client/src/main/java/com/ctrip/framework/apollo/util/http/HttpUtil.java | |
index 13818aa37..686a433f4 100644 | |
--- a/apollo-client/src/main/java/com/ctrip/framework/apollo/util/http/HttpUtil.java | |
+++ b/apollo-client/src/main/java/com/ctrip/framework/apollo/util/http/HttpUtil.java | |
@@ -110,11 +110,11 @@ public class HttpUtil { | |
if (statusCode == 200) { | |
is = conn.getInputStream(); | |
String content = Files.IO.INSTANCE.readFrom(is, Charsets.UTF_8.name()); | |
- return new HttpResponse<>(statusCode, serializeFunction.apply(content)); | |
+ return new HttpResponse<T>(statusCode, serializeFunction.apply(content)); | |
} | |
if (statusCode == 304) { | |
- return new HttpResponse<>(statusCode, null); | |
+ return new HttpResponse<T>(statusCode, null); | |
} | |
} catch (Throwable ex) { | |
diff --git a/apollo-common/pom.xml b/apollo-common/pom.xml | |
index 6591aa52a..2ec3c3c8e 100644 | |
--- a/apollo-common/pom.xml | |
+++ b/apollo-common/pom.xml | |
@@ -11,6 +11,7 @@ | |
<artifactId>apollo-common</artifactId> | |
<name>Apollo Common</name> | |
<properties> | |
+ <java.version>1.6</java.version> | |
<github.path>${project.artifactId}</github.path> | |
</properties> | |
<dependencies> | |
diff --git a/apollo-common/src/main/java/com/ctrip/framework/apollo/common/controller/GlobalDefaultExceptionHandler.java b/apollo-common/src/main/java/com/ctrip/framework/apollo/common/controller/GlobalDefaultExceptionHandler.java | |
index 9e0e0e162..616233af7 100644 | |
--- a/apollo-common/src/main/java/com/ctrip/framework/apollo/common/controller/GlobalDefaultExceptionHandler.java | |
+++ b/apollo-common/src/main/java/com/ctrip/framework/apollo/common/controller/GlobalDefaultExceptionHandler.java | |
@@ -85,7 +85,7 @@ public class GlobalDefaultExceptionHandler { | |
Tracer.logError(ex); | |
- Map<String, Object> errorAttributes = new HashMap<>(); | |
+ Map<String, Object> errorAttributes = new HashMap<String,Object>(); | |
boolean errorHandled = false; | |
if (ex instanceof HttpStatusCodeException) { | |
@@ -110,7 +110,7 @@ public class GlobalDefaultExceptionHandler { | |
HttpHeaders headers = new HttpHeaders(); | |
headers.setContentType(APPLICATION_JSON); | |
- return new ResponseEntity<>(errorAttributes, headers, status); | |
+ return new ResponseEntity<Map<String, Object>>(errorAttributes, headers, status); | |
} | |
} | |
diff --git a/apollo-common/src/main/java/com/ctrip/framework/apollo/common/dto/GrayReleaseRuleItemDTO.java b/apollo-common/src/main/java/com/ctrip/framework/apollo/common/dto/GrayReleaseRuleItemDTO.java | |
index cbccede84..bc7e8d6c5 100644 | |
--- a/apollo-common/src/main/java/com/ctrip/framework/apollo/common/dto/GrayReleaseRuleItemDTO.java | |
+++ b/apollo-common/src/main/java/com/ctrip/framework/apollo/common/dto/GrayReleaseRuleItemDTO.java | |
@@ -1,7 +1,6 @@ | |
package com.ctrip.framework.apollo.common.dto; | |
-import com.google.common.collect.Sets; | |
- | |
+import java.util.HashSet; | |
import java.util.Set; | |
import static com.google.common.base.MoreObjects.toStringHelper; | |
@@ -16,7 +15,7 @@ public class GrayReleaseRuleItemDTO { | |
private Set<String> clientIpList; | |
public GrayReleaseRuleItemDTO(String clientAppId) { | |
- this(clientAppId, Sets.newHashSet()); | |
+ this(clientAppId, new HashSet<String>() ); | |
} | |
public GrayReleaseRuleItemDTO(String clientAppId, Set<String> clientIpList) { | |
diff --git a/apollo-common/src/main/java/com/ctrip/framework/apollo/common/dto/ItemChangeSets.java b/apollo-common/src/main/java/com/ctrip/framework/apollo/common/dto/ItemChangeSets.java | |
index 9573016fa..e1be4f755 100644 | |
--- a/apollo-common/src/main/java/com/ctrip/framework/apollo/common/dto/ItemChangeSets.java | |
+++ b/apollo-common/src/main/java/com/ctrip/framework/apollo/common/dto/ItemChangeSets.java | |
@@ -8,9 +8,9 @@ import java.util.List; | |
*/ | |
public class ItemChangeSets extends BaseDTO{ | |
- private List<ItemDTO> createItems = new LinkedList<>(); | |
- private List<ItemDTO> updateItems = new LinkedList<>(); | |
- private List<ItemDTO> deleteItems = new LinkedList<>(); | |
+ private List<ItemDTO> createItems = new LinkedList<ItemDTO>(); | |
+ private List<ItemDTO> updateItems = new LinkedList<ItemDTO>(); | |
+ private List<ItemDTO> deleteItems = new LinkedList<ItemDTO>(); | |
public void addCreateItem(ItemDTO item) { | |
createItems.add(item); | |
diff --git a/apollo-common/src/main/java/com/ctrip/framework/apollo/common/http/MultiResponseEntity.java b/apollo-common/src/main/java/com/ctrip/framework/apollo/common/http/MultiResponseEntity.java | |
index 957d18155..5a98319a1 100644 | |
--- a/apollo-common/src/main/java/com/ctrip/framework/apollo/common/http/MultiResponseEntity.java | |
+++ b/apollo-common/src/main/java/com/ctrip/framework/apollo/common/http/MultiResponseEntity.java | |
@@ -12,18 +12,18 @@ public class MultiResponseEntity<T> { | |
private int code; | |
- private List<RichResponseEntity<T>> entities = new LinkedList<>(); | |
+ private List<RichResponseEntity<T>> entities = new LinkedList<RichResponseEntity<T>>(); | |
private MultiResponseEntity(HttpStatus httpCode) { | |
this.code = httpCode.value(); | |
} | |
public static <T> MultiResponseEntity<T> instance(HttpStatus statusCode) { | |
- return new MultiResponseEntity<>(statusCode); | |
+ return new MultiResponseEntity<T>(statusCode); | |
} | |
public static <T> MultiResponseEntity<T> ok() { | |
- return new MultiResponseEntity<>(HttpStatus.OK); | |
+ return new MultiResponseEntity<T>(HttpStatus.OK); | |
} | |
public void addResponseEntity(RichResponseEntity<T> responseEntity) { | |
diff --git a/apollo-common/src/main/java/com/ctrip/framework/apollo/common/http/RichResponseEntity.java b/apollo-common/src/main/java/com/ctrip/framework/apollo/common/http/RichResponseEntity.java | |
index 1f6e4afdd..31b17a826 100644 | |
--- a/apollo-common/src/main/java/com/ctrip/framework/apollo/common/http/RichResponseEntity.java | |
+++ b/apollo-common/src/main/java/com/ctrip/framework/apollo/common/http/RichResponseEntity.java | |
@@ -9,7 +9,7 @@ public class RichResponseEntity<T>{ | |
private T body; | |
public static <T> RichResponseEntity<T> ok(T body){ | |
- RichResponseEntity<T> richResponseEntity = new RichResponseEntity<>(); | |
+ RichResponseEntity<T> richResponseEntity = new RichResponseEntity<T>(); | |
richResponseEntity.message = HttpStatus.OK.getReasonPhrase(); | |
richResponseEntity.code = HttpStatus.OK.value(); | |
richResponseEntity.body = body; | |
@@ -17,7 +17,7 @@ public class RichResponseEntity<T>{ | |
} | |
public static <T> RichResponseEntity<T> error(HttpStatus httpCode, Object message){ | |
- RichResponseEntity<T> richResponseEntity = new RichResponseEntity<>(); | |
+ RichResponseEntity<T> richResponseEntity = new RichResponseEntity<T>(); | |
richResponseEntity.message = message; | |
richResponseEntity.code = httpCode.value(); | |
return richResponseEntity; | |
diff --git a/apollo-common/src/main/java/com/ctrip/framework/apollo/common/utils/BeanUtils.java b/apollo-common/src/main/java/com/ctrip/framework/apollo/common/utils/BeanUtils.java | |
index 23e570ddb..1e2249f57 100644 | |
--- a/apollo-common/src/main/java/com/ctrip/framework/apollo/common/utils/BeanUtils.java | |
+++ b/apollo-common/src/main/java/com/ctrip/framework/apollo/common/utils/BeanUtils.java | |
@@ -30,7 +30,7 @@ public class BeanUtils { | |
return Collections.emptyList(); | |
} | |
- List<T> result = new ArrayList<>(srcList.size()); | |
+ List<T> result = new ArrayList<T>(srcList.size()); | |
for (Object srcObject : srcList) { | |
result.add(transfrom(clazz, srcObject)); | |
} | |
-- | |
2.11.0 | |
这样... apollo-core 是可以直接降下去的,没有问题
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
如果只是需要客户端支持1.6的话,应该只需要改apollo-client相关的代码就可以了。
apollo-common的代码应该可以不需要吧,因为apollo-common只是给服务端用的。不过apollo-core的可能需要看一下是否需要修改~