Skip to content

Commit 3086b57

Browse files
authored
[Ci]code formatter (#5485)
1 parent 7a920c0 commit 3086b57

File tree

677 files changed

+10164
-10016
lines changed

Some content is hidden

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

677 files changed

+10164
-10016
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,6 @@ Apollo 2.5.0
2020
* [Fix: the logical judgment for configuration addition, deletion, and modification.](https://github.com/apolloconfig/apollo/pull/5432)
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)
23+
* [CI: Add code and header formatter by spotless plugin](https://github.com/apolloconfig/apollo/pull/5485)
2324
------------------
2425
All issues and pull requests are [here](https://github.com/apolloconfig/apollo/milestone/16?closed=1)

CONTRIBUTING.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,5 @@ We provide template files [intellij-java-google-style.xml](https://github.com/ct
3535
* For commits, we adhere to the conventional commits format. For more details, refer to [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/).
3636

3737
* When crafting commit messages, please adhere to the following conventions: if your commit addresses an existing issue, append "Fixes #XXX" to the end of the commit message (where XXX is the issue number).
38+
39+
* Before submitting a pull request, you need to run `mvn spotless:apply` locally to format the code; this is important for maintaining good coding style in the project.

apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/AdminServiceApplication.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2024 Apollo Authors
2+
* Copyright 2025 Apollo Authors
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -27,15 +27,13 @@
2727
import org.springframework.context.annotation.EnableAspectJAutoProxy;
2828
import org.springframework.context.annotation.PropertySource;
2929
import org.springframework.transaction.annotation.EnableTransactionManagement;
30+
3031
@EnableAspectJAutoProxy
3132
@Configuration
3233
@PropertySource(value = {"classpath:adminservice.properties"})
33-
@EnableAutoConfiguration(exclude = {
34-
UserDetailsServiceAutoConfiguration.class,
35-
})
34+
@EnableAutoConfiguration(exclude = {UserDetailsServiceAutoConfiguration.class,})
3635
@EnableTransactionManagement
37-
@ComponentScan(basePackageClasses = {ApolloCommonConfig.class,
38-
ApolloBizConfig.class,
36+
@ComponentScan(basePackageClasses = {ApolloCommonConfig.class, ApolloBizConfig.class,
3937
AdminServiceApplication.class})
4038
public class AdminServiceApplication {
4139
public static void main(String[] args) {

apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/AdminServiceAssemblyConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2024 Apollo Authors
2+
* Copyright 2025 Apollo Authors
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/AdminServiceAutoConfiguration.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2024 Apollo Authors
2+
* Copyright 2025 Apollo Authors
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -33,7 +33,8 @@ public AdminServiceAutoConfiguration(final BizConfig bizConfig) {
3333

3434
@Bean
3535
public FilterRegistrationBean<AdminServiceAuthenticationFilter> adminServiceAuthenticationFilter() {
36-
FilterRegistrationBean<AdminServiceAuthenticationFilter> filterRegistrationBean = new FilterRegistrationBean<>();
36+
FilterRegistrationBean<AdminServiceAuthenticationFilter> filterRegistrationBean =
37+
new FilterRegistrationBean<>();
3738

3839
filterRegistrationBean.setFilter(new AdminServiceAuthenticationFilter(bizConfig));
3940
filterRegistrationBean.addUrlPatterns("/apollo/audit/*");

apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/AdminServiceHealthIndicator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2024 Apollo Authors
2+
* Copyright 2025 Apollo Authors
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/ServletInitializer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2024 Apollo Authors
2+
* Copyright 2025 Apollo Authors
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

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

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2024 Apollo Authors
2+
* Copyright 2025 Apollo Authors
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -50,10 +50,8 @@ public class NamespaceAcquireLockAspect {
5050
private final ItemService itemService;
5151
private final BizConfig bizConfig;
5252

53-
public NamespaceAcquireLockAspect(
54-
final NamespaceLockService namespaceLockService,
55-
final NamespaceService namespaceService,
56-
final ItemService itemService,
53+
public NamespaceAcquireLockAspect(final NamespaceLockService namespaceLockService,
54+
final NamespaceService namespaceService, final ItemService itemService,
5755
final BizConfig bizConfig) {
5856
this.namespaceLockService = namespaceLockService;
5957
this.namespaceService = namespaceService;
@@ -62,39 +60,38 @@ public NamespaceAcquireLockAspect(
6260
}
6361

6462

65-
//create item
63+
// create item
6664
@Before("@annotation(PreAcquireNamespaceLock) && args(appId, clusterName, namespaceName, item, ..)")
6765
public void requireLockAdvice(String appId, String clusterName, String namespaceName,
68-
ItemDTO item) {
66+
ItemDTO item) {
6967
acquireLock(appId, clusterName, namespaceName, item.getDataChangeLastModifiedBy());
7068
}
7169

72-
//update item
70+
// update item
7371
@Before("@annotation(PreAcquireNamespaceLock) && args(appId, clusterName, namespaceName, itemId, item, ..)")
7472
public void requireLockAdvice(String appId, String clusterName, String namespaceName, long itemId,
75-
ItemDTO item) {
73+
ItemDTO item) {
7674
acquireLock(appId, clusterName, namespaceName, item.getDataChangeLastModifiedBy());
7775
}
7876

79-
//update by change set
77+
// update by change set
8078
@Before("@annotation(PreAcquireNamespaceLock) && args(appId, clusterName, namespaceName, changeSet, ..)")
8179
public void requireLockAdvice(String appId, String clusterName, String namespaceName,
82-
ItemChangeSets changeSet) {
80+
ItemChangeSets changeSet) {
8381
acquireLock(appId, clusterName, namespaceName, changeSet.getDataChangeLastModifiedBy());
8482
}
8583

86-
//delete item
84+
// delete item
8785
@Before("@annotation(PreAcquireNamespaceLock) && args(itemId, operator, ..)")
8886
public void requireLockAdvice(long itemId, String operator) {
8987
Item item = itemService.findOne(itemId);
90-
if (item == null){
88+
if (item == null) {
9189
throw BadRequestException.itemNotExists(itemId);
9290
}
9391
acquireLock(item.getNamespaceId(), operator);
9492
}
9593

96-
void acquireLock(String appId, String clusterName, String namespaceName,
97-
String currentUser) {
94+
void acquireLock(String appId, String clusterName, String namespaceName, String currentUser) {
9895
if (bizConfig.isNamespaceLockSwitchOff()) {
9996
return;
10097
}
@@ -126,17 +123,17 @@ private void acquireLock(Namespace namespace, String currentUser) {
126123
if (namespaceLock == null) {
127124
try {
128125
tryLock(namespaceId, currentUser);
129-
//lock success
126+
// lock success
130127
} catch (DataIntegrityViolationException e) {
131-
//lock fail
128+
// lock fail
132129
namespaceLock = namespaceLockService.findLock(namespaceId);
133130
checkLock(namespace, namespaceLock, currentUser);
134131
} catch (Exception e) {
135132
logger.error("try lock error", e);
136133
throw e;
137134
}
138135
} else {
139-
//check lock owner is current user
136+
// check lock owner is current user
140137
checkLock(namespace, namespaceLock, currentUser);
141138
}
142139
}
@@ -149,8 +146,7 @@ private void tryLock(long namespaceId, String user) {
149146
namespaceLockService.tryLock(lock);
150147
}
151148

152-
private void checkLock(Namespace namespace, NamespaceLock namespaceLock,
153-
String currentUser) {
149+
private void checkLock(Namespace namespace, NamespaceLock namespaceLock, String currentUser) {
154150
if (namespaceLock == null) {
155151
throw new ServiceException(
156152
String.format("Check lock for %s failed, please retry.", namespace.getNamespaceName()));

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

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2024 Apollo Authors
2+
* Copyright 2025 Apollo Authors
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -61,12 +61,9 @@ public class NamespaceUnlockAspect {
6161
private final ReleaseService releaseService;
6262
private final BizConfig bizConfig;
6363

64-
public NamespaceUnlockAspect(
65-
final NamespaceLockService namespaceLockService,
66-
final NamespaceService namespaceService,
67-
final ItemService itemService,
68-
final ReleaseService releaseService,
69-
final BizConfig bizConfig) {
64+
public NamespaceUnlockAspect(final NamespaceLockService namespaceLockService,
65+
final NamespaceService namespaceService, final ItemService itemService,
66+
final ReleaseService releaseService, final BizConfig bizConfig) {
7067
this.namespaceLockService = namespaceLockService;
7168
this.namespaceService = namespaceService;
7269
this.itemService = itemService;
@@ -75,28 +72,28 @@ public NamespaceUnlockAspect(
7572
}
7673

7774

78-
//create item
75+
// create item
7976
@After("@annotation(PreAcquireNamespaceLock) && args(appId, clusterName, namespaceName, item, ..)")
8077
public void requireLockAdvice(String appId, String clusterName, String namespaceName,
81-
ItemDTO item) {
78+
ItemDTO item) {
8279
tryUnlock(namespaceService.findOne(appId, clusterName, namespaceName));
8380
}
8481

85-
//update item
82+
// update item
8683
@After("@annotation(PreAcquireNamespaceLock) && args(appId, clusterName, namespaceName, itemId, item, ..)")
8784
public void requireLockAdvice(String appId, String clusterName, String namespaceName, long itemId,
88-
ItemDTO item) {
85+
ItemDTO item) {
8986
tryUnlock(namespaceService.findOne(appId, clusterName, namespaceName));
9087
}
9188

92-
//update by change set
89+
// update by change set
9390
@After("@annotation(PreAcquireNamespaceLock) && args(appId, clusterName, namespaceName, changeSet, ..)")
9491
public void requireLockAdvice(String appId, String clusterName, String namespaceName,
95-
ItemChangeSets changeSet) {
92+
ItemChangeSets changeSet) {
9693
tryUnlock(namespaceService.findOne(appId, clusterName, namespaceName));
9794
}
9895

99-
//delete item
96+
// delete item
10097
@After("@annotation(PreAcquireNamespaceLock) && args(itemId, operator, ..)")
10198
public void requireLockAdvice(long itemId, String operator) {
10299
Item item = itemService.findOne(itemId);
@@ -125,10 +122,12 @@ boolean isModified(Namespace namespace) {
125122
return hasNormalItems(items);
126123
}
127124

128-
Map<String, String> releasedConfiguration = GSON.fromJson(release.getConfigurations(), GsonType.CONFIG);
125+
Map<String, String> releasedConfiguration =
126+
GSON.fromJson(release.getConfigurations(), GsonType.CONFIG);
129127
Map<String, String> configurationFromItems = generateConfigurationFromItems(namespace, items);
130128

131-
MapDifference<String, String> difference = Maps.difference(releasedConfiguration, configurationFromItems);
129+
MapDifference<String, String> difference =
130+
Maps.difference(releasedConfiguration, configurationFromItems);
132131

133132
return !difference.areEqual();
134133

@@ -144,15 +143,16 @@ private boolean hasNormalItems(List<Item> items) {
144143
return false;
145144
}
146145

147-
private Map<String, String> generateConfigurationFromItems(Namespace namespace, List<Item> namespaceItems) {
146+
private Map<String, String> generateConfigurationFromItems(Namespace namespace,
147+
List<Item> namespaceItems) {
148148

149149
Map<String, String> configurationFromItems = Maps.newHashMap();
150150

151151
Namespace parentNamespace = namespaceService.findParentNamespace(namespace);
152-
//parent namespace
152+
// parent namespace
153153
if (parentNamespace == null) {
154154
generateMapFromItems(namespaceItems, configurationFromItems);
155-
} else {//child namespace
155+
} else {// child namespace
156156
Release parentRelease = releaseService.findLatestActiveRelease(parentNamespace);
157157
if (parentRelease != null) {
158158
configurationFromItems = GSON.fromJson(parentRelease.getConfigurations(), GsonType.CONFIG);
@@ -163,7 +163,8 @@ private Map<String, String> generateConfigurationFromItems(Namespace namespace,
163163
return configurationFromItems;
164164
}
165165

166-
private Map<String, String> generateMapFromItems(List<Item> items, Map<String, String> configurationFromItems) {
166+
private Map<String, String> generateMapFromItems(List<Item> items,
167+
Map<String, String> configurationFromItems) {
167168
for (Item item : items) {
168169
String key = item.getKey();
169170
if (StringUtils.isBlank(key)) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2024 Apollo Authors
2+
* Copyright 2025 Apollo Authors
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)