Skip to content

Commit 9205718

Browse files
authored
Merge branch 'master' into flaky-test-fix
2 parents 6d7df2d + 5e49df6 commit 9205718

File tree

172 files changed

+3385
-861
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

172 files changed

+3385
-861
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
restore-keys: ${{ runner.os }}-m2
4545
- name: JDK 8
4646
if: matrix.jdk == '8'
47-
run: mvn -B clean package -P travis jacoco:report -Dmaven.gitcommitid.skip=true
47+
run: mvn -B clean package jacoco:report -Dmaven.gitcommitid.skip=true
4848
- name: JDK 11
4949
if: matrix.jdk == '11'
5050
run: mvn -B clean compile -Dmaven.gitcommitid.skip=true

.github/workflows/codeql.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: "CodeQL"
2+
3+
on:
4+
push:
5+
branches: [ 'master' ]
6+
pull_request:
7+
# The branches below must be a subset of the branches above
8+
branches: [ 'master' ]
9+
schedule:
10+
- cron: '25 18 * * 2'
11+
12+
jobs:
13+
analyze:
14+
name: Analyze
15+
runs-on: ubuntu-latest
16+
permissions:
17+
actions: read
18+
contents: read
19+
security-events: write
20+
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
language: [ 'javascript', 'java' ]
25+
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
26+
# Use only 'java' to analyze code written in Java, Kotlin or both
27+
# Use only 'javascript' to analyze code written in JavaScript, TypeScript or both
28+
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
29+
30+
steps:
31+
- name: Checkout repository
32+
uses: actions/checkout@v3
33+
34+
# Initializes the CodeQL tools for scanning.
35+
- name: Initialize CodeQL
36+
uses: github/codeql-action/init@v2
37+
with:
38+
languages: ${{ matrix.language }}
39+
# If you wish to specify custom queries, you can do so here or in a config file.
40+
# By default, queries listed here will override any specified in a config file.
41+
# Prefix the list here with "+" to use these queries and those in the config file.
42+
43+
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
44+
# queries: security-extended,security-and-quality
45+
46+
47+
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
48+
# If this step fails, then you should remove it and run the build manually (see below)
49+
- name: Autobuild
50+
uses: github/codeql-action/autobuild@v2
51+
52+
# ℹ️ Command-line programs to run using the OS shell.
53+
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
54+
55+
# If the Autobuild fails above, remove it and uncomment the following three lines.
56+
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
57+
58+
# - run: |
59+
# echo "Run, Build Application using script"
60+
# ./location_of_script_within_repo/buildscript.sh
61+
62+
- name: Perform CodeQL Analysis
63+
uses: github/codeql-action/analyze@v2
64+
with:
65+
category: "/language:${{matrix.language}}"

CHANGES.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,19 @@ Apollo 2.2.0
1818
* [[Multi-Database Support] Optimize column define case sensitivity](https://github.com/apolloconfig/apollo/pull/4776)
1919
* [[Multi-Database Support][pg] Where clause need escape, otherwise will request postgre use lowwer case](https://github.com/apolloconfig/apollo/pull/4780)
2020
* [Misc dependency updates](https://github.com/apolloconfig/apollo/pull/4784)
21+
* [Fix the problem that the deletion failure of the system rights management page does not prompt](https://github.com/apolloconfig/apollo/pull/4803)
22+
* [Fix the issue of the system permission management page retrieving non-existent users](https://github.com/apolloconfig/apollo/pull/4802)
23+
* [Add release history cleaning function](https://github.com/apolloconfig/apollo/pull/4813)
24+
* [[Multi-Database Support][pg] Make JdbcUserDetailsManager compat with postgre](https://github.com/apolloconfig/apollo/pull/4790)
25+
* [refactor(apollo logging): Simplify the default log path to `/opt/logs`](https://github.com/apolloconfig/apollo/pull/4833)
26+
* [Add a configuration config-service.cache.key.ignore-case to control whether the cache key is case-sensitive](https://github.com/apolloconfig/apollo/pull/4820)
27+
* [feat: check port use by another process or not when startup](https://github.com/apolloconfig/apollo/pull/4656)
28+
* [Bump springboot version from 2.7.9 to 2.7.11](https://github.com/apolloconfig/apollo/pull/4828)
29+
* [[Multi-Database Support][h2] Support run on h2](https://github.com/apolloconfig/apollo/pull/4851)
30+
* [Fix the issue that env special case handling is missing in some case](https://github.com/apolloconfig/apollo/pull/4887)
31+
* [Fix the issue that namespace content being cleared when identical content is pasted into the namespace](https://github.com/apolloconfig/apollo/pull/4922)
32+
* [feat(openapi): allow user create app via openapi](https://github.com/apolloconfig/apollo/pull/4954)
33+
* [Support grayscale feature for non-properties namespaces](https://github.com/apolloconfig/apollo/pull/4952)
2134

2235
------------------
2336
All issues and pull requests are [here](https://github.com/apolloconfig/apollo/milestone/13?closed=1)

apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/aop/NamespaceAcquireLockAspect.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public void requireLockAdvice(String appId, String clusterName, String namespace
8888
public void requireLockAdvice(long itemId, String operator) {
8989
Item item = itemService.findOne(itemId);
9090
if (item == null){
91-
throw new BadRequestException("item not exist.");
91+
throw BadRequestException.itemNotExists(itemId);
9292
}
9393
acquireLock(item.getNamespaceId(), operator);
9494
}
@@ -117,7 +117,7 @@ void acquireLock(long namespaceId, String currentUser) {
117117

118118
private void acquireLock(Namespace namespace, String currentUser) {
119119
if (namespace == null) {
120-
throw new BadRequestException("namespace not exist.");
120+
throw BadRequestException.namespaceNotExists();
121121
}
122122

123123
long namespaceId = namespace.getId();

apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/aop/NamespaceUnlockAspect.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public void requireLockAdvice(String appId, String clusterName, String namespace
101101
public void requireLockAdvice(long itemId, String operator) {
102102
Item item = itemService.findOne(itemId);
103103
if (item == null) {
104-
throw new BadRequestException("item not exist.");
104+
throw BadRequestException.itemNotExists(itemId);
105105
}
106106
tryUnlock(namespaceService.findOne(item.getNamespaceId()));
107107
}

apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/AppController.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public AppDTO create(@Valid @RequestBody AppDTO dto) {
5454
App entity = BeanUtils.transform(App.class, dto);
5555
App managedEntity = appService.findOne(entity.getAppId());
5656
if (managedEntity != null) {
57-
throw new BadRequestException("app already exist.");
57+
throw BadRequestException.appAlreadyExists(entity.getAppId());
5858
}
5959

6060
entity = adminService.createNewApp(entity);
@@ -66,7 +66,7 @@ public AppDTO create(@Valid @RequestBody AppDTO dto) {
6666
public void delete(@PathVariable("appId") String appId, @RequestParam String operator) {
6767
App entity = appService.findOne(appId);
6868
if (entity == null) {
69-
throw new NotFoundException("app not found for appId " + appId);
69+
throw NotFoundException.appNotFound(appId);
7070
}
7171
adminService.deleteApp(entity, operator);
7272
}
@@ -96,7 +96,7 @@ public List<AppDTO> find(@RequestParam(value = "name", required = false) String
9696
public AppDTO get(@PathVariable("appId") String appId) {
9797
App app = appService.findOne(appId);
9898
if (app == null) {
99-
throw new NotFoundException("app not found for appId " + appId);
99+
throw NotFoundException.appNotFound(appId);
100100
}
101101
return BeanUtils.transform(AppDTO.class, app);
102102
}

apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/AppNamespaceController.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public AppNamespaceDTO create(@RequestBody AppNamespaceDTO appNamespace,
6969

7070
entity = managedEntity;
7171
} else {
72-
throw new BadRequestException("app namespaces already exist.");
72+
throw BadRequestException.appNamespaceAlreadyExists(entity.getAppId(), entity.getName());
7373
}
7474

7575
return BeanUtils.transform(AppNamespaceDTO.class, entity);
@@ -80,7 +80,7 @@ public void delete(@PathVariable("appId") String appId, @PathVariable("namespace
8080
@RequestParam String operator) {
8181
AppNamespace entity = appNamespaceService.findOne(appId, namespaceName);
8282
if (entity == null) {
83-
throw new BadRequestException("app namespace not found for appId: " + appId + " namespace: " + namespaceName);
83+
throw BadRequestException.appNamespaceNotExists(appId, namespaceName);
8484
}
8585
appNamespaceService.deleteAppNamespace(entity, operator);
8686
}

apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/ClusterController.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public ClusterDTO create(@PathVariable("appId") String appId,
5050
Cluster entity = BeanUtils.transform(Cluster.class, dto);
5151
Cluster managedEntity = clusterService.findOne(appId, entity.getName());
5252
if (managedEntity != null) {
53-
throw new BadRequestException("cluster already exist.");
53+
throw BadRequestException.clusterAlreadyExists(entity.getName());
5454
}
5555

5656
if (autoCreatePrivateNamespace) {
@@ -69,7 +69,7 @@ public void delete(@PathVariable("appId") String appId,
6969
Cluster entity = clusterService.findOne(appId, clusterName);
7070

7171
if (entity == null) {
72-
throw new NotFoundException("cluster not found for clusterName " + clusterName);
72+
throw NotFoundException.clusterNotFound(appId, clusterName);
7373
}
7474

7575
if(ConfigConsts.CLUSTER_NAME_DEFAULT.equals(entity.getName())){
@@ -90,7 +90,7 @@ public ClusterDTO get(@PathVariable("appId") String appId,
9090
@PathVariable("clusterName") String clusterName) {
9191
Cluster cluster = clusterService.findOne(appId, clusterName);
9292
if (cluster == null) {
93-
throw new NotFoundException("cluster not found for name " + clusterName);
93+
throw NotFoundException.clusterNotFound(appId, clusterName);
9494
}
9595
return BeanUtils.transform(ClusterDTO.class, cluster);
9696
}

apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/InstanceConfigController.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public PageDTO<InstanceDTO> getByRelease(@RequestParam("releaseId") long release
7070
Pageable pageable) {
7171
Release release = releaseService.findOne(releaseId);
7272
if (release == null) {
73-
throw new NotFoundException("release not found for %s", releaseId);
73+
throw NotFoundException.releaseNotFound(releaseId);
7474
}
7575
Page<InstanceConfig> instanceConfigsPage = instanceService.findActiveInstanceConfigsByReleaseKey
7676
(release.getReleaseKey(), pageable);
@@ -123,7 +123,7 @@ public List<InstanceDTO> getByReleasesNotIn(@RequestParam("appId") String appId,
123123
List<Release> releases = releaseService.findByReleaseIds(releaseIdSet);
124124

125125
if (CollectionUtils.isEmpty(releases)) {
126-
throw new NotFoundException("releases not found for %s", releaseIds);
126+
throw NotFoundException.releaseNotFound(releaseIds);
127127
}
128128

129129
Set<String> releaseKeys = releases.stream().map(Release::getReleaseKey).collect(Collectors

apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/ItemController.java

Lines changed: 14 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -75,19 +75,13 @@ public ItemDTO create(@PathVariable("appId") String appId,
7575

7676
Item managedEntity = itemService.findOne(appId, clusterName, namespaceName, entity.getKey());
7777
if (managedEntity != null) {
78-
throw new BadRequestException("item already exists");
78+
throw BadRequestException.itemAlreadyExists(entity.getKey());
7979
}
8080
entity = itemService.save(entity);
8181
dto = BeanUtils.transform(ItemDTO.class, entity);
82-
83-
Commit commit = new Commit();
84-
commit.setAppId(appId);
85-
commit.setClusterName(clusterName);
86-
commit.setNamespaceName(namespaceName);
87-
commit.setChangeSets(new ConfigChangeContentBuilder().createItem(entity).build());
88-
commit.setDataChangeCreatedBy(dto.getDataChangeLastModifiedBy());
89-
commit.setDataChangeLastModifiedBy(dto.getDataChangeLastModifiedBy());
90-
commitService.save(commit);
82+
commitService.createCommit(appId, clusterName, namespaceName, new ConfigChangeContentBuilder().createItem(entity).build(),
83+
dto.getDataChangeLastModifiedBy()
84+
);
9185

9286
return dto;
9387
}
@@ -128,13 +122,13 @@ public ItemDTO update(@PathVariable("appId") String appId,
128122
@RequestBody ItemDTO itemDTO) {
129123
Item managedEntity = itemService.findOne(itemId);
130124
if (managedEntity == null) {
131-
throw new NotFoundException("item not found for itemId " + itemId);
125+
throw NotFoundException.itemNotFound(appId, clusterName, namespaceName, itemId);
132126
}
133127

134128
Namespace namespace = namespaceService.findOne(appId, clusterName, namespaceName);
135129
// In case someone constructs an attack scenario
136130
if (namespace == null || namespace.getId() != managedEntity.getNamespaceId()) {
137-
throw new BadRequestException("Invalid request, item and namespace do not match!");
131+
throw BadRequestException.namespaceNotMatch();
138132
}
139133

140134
Item entity = BeanUtils.transform(Item.class, itemDTO);
@@ -154,14 +148,7 @@ public ItemDTO update(@PathVariable("appId") String appId,
154148
itemDTO = BeanUtils.transform(ItemDTO.class, entity);
155149

156150
if (builder.hasContent()) {
157-
Commit commit = new Commit();
158-
commit.setAppId(appId);
159-
commit.setClusterName(clusterName);
160-
commit.setNamespaceName(namespaceName);
161-
commit.setChangeSets(builder.build());
162-
commit.setDataChangeCreatedBy(itemDTO.getDataChangeLastModifiedBy());
163-
commit.setDataChangeLastModifiedBy(itemDTO.getDataChangeLastModifiedBy());
164-
commitService.save(commit);
151+
commitService.createCommit(appId, clusterName, namespaceName, builder.build(), itemDTO.getDataChangeLastModifiedBy());
165152
}
166153

167154
return itemDTO;
@@ -172,20 +159,16 @@ public ItemDTO update(@PathVariable("appId") String appId,
172159
public void delete(@PathVariable("itemId") long itemId, @RequestParam String operator) {
173160
Item entity = itemService.findOne(itemId);
174161
if (entity == null) {
175-
throw new NotFoundException("item not found for itemId " + itemId);
162+
throw NotFoundException.itemNotFound(itemId);
176163
}
177164
itemService.delete(entity.getId(), operator);
178165

179166
Namespace namespace = namespaceService.findOne(entity.getNamespaceId());
180167

181-
Commit commit = new Commit();
182-
commit.setAppId(namespace.getAppId());
183-
commit.setClusterName(namespace.getClusterName());
184-
commit.setNamespaceName(namespace.getNamespaceName());
185-
commit.setChangeSets(new ConfigChangeContentBuilder().deleteItem(entity).build());
186-
commit.setDataChangeCreatedBy(operator);
187-
commit.setDataChangeLastModifiedBy(operator);
188-
commitService.save(commit);
168+
commitService.createCommit(namespace.getAppId(), namespace.getClusterName(), namespace.getNamespaceName(),
169+
new ConfigChangeContentBuilder().deleteItem(entity).build(), operator
170+
);
171+
189172
}
190173

191174
@GetMapping("/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items")
@@ -222,7 +205,7 @@ public List<ItemDTO> findDeletedItems(@PathVariable("appId") String appId,
222205
public ItemDTO get(@PathVariable("itemId") long itemId) {
223206
Item item = itemService.findOne(itemId);
224207
if (item == null) {
225-
throw new NotFoundException("item not found for itemId " + itemId);
208+
throw NotFoundException.itemNotFound(itemId);
226209
}
227210
return BeanUtils.transform(ItemDTO.class, item);
228211
}
@@ -233,8 +216,7 @@ public ItemDTO get(@PathVariable("appId") String appId,
233216
@PathVariable("namespaceName") String namespaceName, @PathVariable("key") String key) {
234217
Item item = itemService.findOne(appId, clusterName, namespaceName, key);
235218
if (item == null) {
236-
throw new NotFoundException("item not found for %s %s %s %s", appId, clusterName,
237-
namespaceName, key);
219+
throw NotFoundException.itemNotFound(appId, clusterName, namespaceName, key);
238220
}
239221
return BeanUtils.transform(ItemDTO.class, item);
240222
}

0 commit comments

Comments
 (0)