Commit 86b6ed05 by Jason Song Committed by GitHub

Merge pull request #340 from lepdou/rollback

bugfix release 兼容性问题
parents 26234224 8776edc8
...@@ -64,8 +64,10 @@ public class ReleaseController { ...@@ -64,8 +64,10 @@ public class ReleaseController {
@PathVariable("clusterName") String clusterName, @PathVariable("clusterName") String clusterName,
@PathVariable("namespaceName") String namespaceName) { @PathVariable("namespaceName") String namespaceName) {
Release release = configService.findRelease(appId, clusterName, namespaceName); Release release = configService.findRelease(appId, clusterName, namespaceName);
//// TODO: 16/7/22 返回null
if (release == null) { if (release == null) {
return null; throw new NotFoundException(String.format("latest release not found for %s %s %s", appId,
clusterName, namespaceName));
} else { } else {
return BeanUtils.transfrom(ReleaseDTO.class, release); return BeanUtils.transfrom(ReleaseDTO.class, release);
} }
......
...@@ -4,6 +4,7 @@ import com.google.gson.Gson; ...@@ -4,6 +4,7 @@ import com.google.gson.Gson;
import com.ctrip.framework.apollo.common.entity.AppNamespace; import com.ctrip.framework.apollo.common.entity.AppNamespace;
import com.ctrip.framework.apollo.common.utils.BeanUtils; import com.ctrip.framework.apollo.common.utils.BeanUtils;
import com.ctrip.framework.apollo.common.utils.ExceptionUtils;
import com.ctrip.framework.apollo.core.dto.ItemDTO; import com.ctrip.framework.apollo.core.dto.ItemDTO;
import com.ctrip.framework.apollo.core.dto.NamespaceDTO; import com.ctrip.framework.apollo.core.dto.NamespaceDTO;
import com.ctrip.framework.apollo.core.dto.ReleaseDTO; import com.ctrip.framework.apollo.core.dto.ReleaseDTO;
...@@ -19,7 +20,9 @@ import com.dianping.cat.Cat; ...@@ -19,7 +20,9 @@ import com.dianping.cat.Cat;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.client.HttpClientErrorException;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
...@@ -101,9 +104,17 @@ public class NamespaceService { ...@@ -101,9 +104,17 @@ public class NamespaceService {
//latest Release //latest Release
ReleaseDTO latestRelease = null; ReleaseDTO latestRelease = null;
Map<String, String> releaseItems = new HashMap<>(); Map<String, String> releaseItems = new HashMap<>();
latestRelease = releaseAPI.loadLatestRelease(appId, env, clusterName, namespaceName); try {
if (latestRelease != null){ latestRelease = releaseAPI.loadLatestRelease(appId, env, clusterName, namespaceName);
releaseItems = gson.fromJson(latestRelease.getConfigurations(), Map.class); if (latestRelease != null) {
releaseItems = gson.fromJson(latestRelease.getConfigurations(), Map.class);
}
} catch (HttpClientErrorException e) {
if (e.getStatusCode() == HttpStatus.NOT_FOUND) {
logger.warn(ExceptionUtils.toString(e));
} else {
throw e;
}
} }
//not Release config items //not Release config items
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment