Skip to content

Commit ab018f2

Browse files
Merge branch 'master' into master
2 parents 013d205 + 840d919 commit ab018f2

File tree

16 files changed

+108
-95
lines changed

16 files changed

+108
-95
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ Follow this checklist to help us incorporate your contribution quickly and easil
1515
- [ ] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
1616
- [ ] Write necessary unit tests to verify the code.
1717
- [ ] Run `mvn clean test` to make sure this pull request doesn't break anything.
18+
- [ ] Run `mvn spotless:apply` to format your code.
1819
- [ ] Update the [`CHANGES` log](https://github.com/apolloconfig/apollo/blob/master/CHANGES.md).
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#
2+
# Copyright 2025 Apollo Authors
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
# This workflow checks code style using Spotless
17+
18+
name: code style check
19+
20+
on:
21+
push:
22+
branches: [ master ]
23+
pull_request:
24+
branches: [ master ]
25+
26+
jobs:
27+
code-style-check:
28+
runs-on: ubuntu-latest
29+
permissions:
30+
contents: read
31+
steps:
32+
- uses: actions/checkout@v4
33+
- name: Set up JDK 17
34+
uses: actions/setup-java@v1
35+
with:
36+
java-version: 17
37+
- name: Cache Maven packages
38+
uses: actions/cache@v4
39+
with:
40+
path: ~/.m2/repository
41+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
42+
restore-keys: |
43+
${{ runner.os }}-maven-
44+
- name: Code Style Check
45+
run: mvn spotless:check

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,6 @@ Apollo 2.5.0
2121
* [Feature support incremental configuration synchronization client](https://github.com/apolloconfig/apollo/pull/5288)
2222
* [optimize: Implement unified permission verification logic and Optimize the implementation of permission verification](https://github.com/apolloconfig/apollo/pull/5456)
2323
* [CI: Add code and header formatter by spotless plugin](https://github.com/apolloconfig/apollo/pull/5485)
24+
* [Fix: Operate the AccessKey multiple times within one second](https://github.com/apolloconfig/apollo/pull/5490)
2425
------------------
2526
All issues and pull requests are [here](https://github.com/apolloconfig/apollo/milestone/16?closed=1)

apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/aop/ApolloAuditSpanAspect.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,7 @@ Method findMethod(ProceedingJoinPoint pjp) {
9999
parameterTypes = ((MethodSignature) pjpSignature).getParameterTypes();
100100
}
101101
try {
102-
Method method = ReflectUtils.findDeclaredMethod(clazz, methodName, parameterTypes);
103-
return method;
102+
return ReflectUtils.findDeclaredMethod(clazz, methodName, parameterTypes);
104103
} catch (NoSuchMethodException e) {
105104
return null;
106105
}

apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/component/ApolloAuditHttpInterceptor.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ public ClientHttpResponse intercept(HttpRequest request, byte[] body,
3737
if (traceContext.tracer() != null) {
3838
request = traceContext.tracer().inject(request);
3939
}
40-
ClientHttpResponse response = execution.execute(request, body);
41-
return response;
40+
return execution.execute(request, body);
4241
}
4342
}

apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/controller/ApolloAuditController.java

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,13 @@ public ApolloAuditProperties getProperties() {
5555
@GetMapping("/logs")
5656
@PreAuthorize(value = "@apolloAuditLogQueryApiPreAuthorizer.hasQueryPermission()")
5757
public List<ApolloAuditLogDTO> findAllAuditLogs(int page, int size) {
58-
List<ApolloAuditLogDTO> logDTOList = api.queryLogs(page, size);
59-
return logDTOList;
58+
return api.queryLogs(page, size);
6059
}
6160

6261
@GetMapping("/trace")
6362
@PreAuthorize(value = "@apolloAuditLogQueryApiPreAuthorizer.hasQueryPermission()")
6463
public List<ApolloAuditLogDetailsDTO> findTraceDetails(@RequestParam String traceId) {
65-
List<ApolloAuditLogDetailsDTO> detailsDTOList = api.queryTraceDetails(traceId);
66-
return detailsDTOList;
64+
return api.queryTraceDetails(traceId);
6765
}
6866

6967
@GetMapping("/logs/opName")
@@ -74,27 +72,22 @@ public List<ApolloAuditLogDTO> findAllAuditLogsByOpNameAndTime(@RequestParam Str
7472
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss.S") Date startDate,
7573
@RequestParam(value = "endDate", required = false)
7674
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss.S") Date endDate) {
77-
List<ApolloAuditLogDTO> logDTOList =
78-
api.queryLogsByOpName(opName, startDate, endDate, page, size);
79-
return logDTOList;
75+
return api.queryLogsByOpName(opName, startDate, endDate, page, size);
8076
}
8177

8278
@GetMapping("/logs/dataInfluences/field")
8379
@PreAuthorize(value = "@apolloAuditLogQueryApiPreAuthorizer.hasQueryPermission()")
8480
public List<ApolloAuditLogDataInfluenceDTO> findDataInfluencesByField(
8581
@RequestParam String entityName, @RequestParam String entityId,
8682
@RequestParam String fieldName, int page, int size) {
87-
List<ApolloAuditLogDataInfluenceDTO> dataInfluenceDTOList =
88-
api.queryDataInfluencesByField(entityName, entityId, fieldName, page, size);
89-
return dataInfluenceDTOList;
83+
return api.queryDataInfluencesByField(entityName, entityId, fieldName, page, size);
9084
}
9185

9286
@GetMapping("/logs/by-name-or-type-or-operator")
9387
@PreAuthorize(value = "@apolloAuditLogQueryApiPreAuthorizer.hasQueryPermission()")
9488
public List<ApolloAuditLogDTO> findAuditLogsByNameOrTypeOrOperator(@RequestParam String query,
9589
int page, int size) {
96-
List<ApolloAuditLogDTO> logDTOList = api.searchLogByNameOrTypeOrOperator(query, page, size);
97-
return logDTOList;
90+
return api.searchLogByNameOrTypeOrOperator(query, page, size);
9891
}
9992

10093
}

apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/grayReleaseRule/GrayReleaseRulesHolder.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -283,13 +283,9 @@ private GrayReleaseRuleCache transformRuleToRuleCache(GrayReleaseRule grayReleas
283283
Tracer.logError(ex);
284284
logger.error("parse rule for gray release rule {} failed", grayReleaseRule.getId(), ex);
285285
}
286-
287-
GrayReleaseRuleCache ruleCache =
288-
new GrayReleaseRuleCache(grayReleaseRule.getId(), grayReleaseRule.getBranchName(),
289-
grayReleaseRule.getNamespaceName(), grayReleaseRule.getReleaseId(),
290-
grayReleaseRule.getBranchStatus(), loadVersion.get(), ruleItems);
291-
292-
return ruleCache;
286+
return new GrayReleaseRuleCache(grayReleaseRule.getId(), grayReleaseRule.getBranchName(),
287+
grayReleaseRule.getNamespaceName(), grayReleaseRule.getReleaseId(),
288+
grayReleaseRule.getBranchStatus(), loadVersion.get(), ruleItems);
293289
}
294290

295291
private void populateDataBaseInterval() {

apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/AccessKeyRepository.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,8 @@ public interface AccessKeyRepository extends PagingAndSortingRepository<AccessKe
3333
List<AccessKey> findFirst500ByDataChangeLastModifiedTimeGreaterThanOrderByDataChangeLastModifiedTimeAsc(
3434
Date date);
3535

36+
List<AccessKey> findFirst500ByDataChangeLastModifiedTimeGreaterThanEqualAndDataChangeLastModifiedTimeLessThanOrderByDataChangeLastModifiedTimeAsc(
37+
Date start, Date end);
38+
3639
List<AccessKey> findByDataChangeLastModifiedTime(Date date);
3740
}

apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/grayReleaseRule/GrayReleaseRulesHolderTest.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,6 @@ private GrayReleaseRuleItemDTO assembleRuleItem(String clientAppId, Set<String>
198198
private ReleaseMessage assembleReleaseMessage(String appId, String clusterName,
199199
String namespaceName) {
200200
String message = STRING_JOINER.join(appId, clusterName, namespaceName);
201-
ReleaseMessage releaseMessage = new ReleaseMessage(message);
202-
203-
return releaseMessage;
201+
return new ReleaseMessage(message);
204202
}
205203
}

apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/repository/AccessKeyRepositoryTest.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,25 @@ public void testFindFirst500ByDataChangeLastModifiedTimeGreaterThanOrderByDataCh
8484
assertThat(accessKeyList.get(1).getSecret()).isEqualTo("c715cbc80fc44171b43732c3119c9456");
8585
}
8686

87+
@Test
88+
@Sql(scripts = "/sql/accesskey-test.sql", executionPhase = ExecutionPhase.BEFORE_TEST_METHOD)
89+
@Sql(scripts = "/sql/clean.sql", executionPhase = ExecutionPhase.AFTER_TEST_METHOD)
90+
public void testFindFirst500ByDataChangeLastModifiedTimeGreaterThanEqualAndDataChangeLastModifiedTimeLessThanOrderByDataChangeLastModifiedTime() {
91+
Instant instantStart =
92+
LocalDateTime.of(2019, 12, 19, 13, 44, 21).atZone(ZoneId.systemDefault()).toInstant();
93+
Date dateStart = Date.from(instantStart);
94+
95+
Instant instantEnd =
96+
LocalDateTime.of(2019, 12, 19, 13, 44, 22).atZone(ZoneId.systemDefault()).toInstant();
97+
Date dateEnd = Date.from(instantEnd);
98+
99+
100+
List<AccessKey> accessKeyList = accessKeyRepository
101+
.findFirst500ByDataChangeLastModifiedTimeGreaterThanEqualAndDataChangeLastModifiedTimeLessThanOrderByDataChangeLastModifiedTimeAsc(
102+
dateStart, dateEnd);
103+
104+
assertThat(accessKeyList).hasSize(1);
105+
assertThat(accessKeyList.get(0).getAppId()).isEqualTo("100004458");
106+
assertThat(accessKeyList.get(0).getSecret()).isEqualTo("4003c4d7783443dc9870932bebf3b7fe");
107+
}
87108
}

0 commit comments

Comments
 (0)