Skip to content

Commit

Permalink
[type: refactor] Use Collections.emptyList() replace Collections.EMPT…
Browse files Browse the repository at this point in the history
…Y_LIST. (apache#3881) (apache#3882)
  • Loading branch information
ousinka authored Aug 27, 2022
1 parent 7e944fc commit b471b4d
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public String handler(final String handle, final List<CommonUpstream> aliveList)
@Override
public <T extends CommonUpstream> List<T> updateStatusAndFilter(final List<T> existList, final List<? extends CommonUpstream> aliveList) {
if (aliveList == null) {
return Collections.EMPTY_LIST;
return Collections.emptyList();
}
long currentTimeMillis = System.currentTimeMillis();
List<T> validExistList = existList.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,10 @@ private boolean isEnabledLoad() {
return false;
}

@SuppressWarnings("unchecked")
private List<UpstreamInstance> getLastUpdateInstanceList(final List<SelectorData> changedList) {
if (CollectionUtils.isEmpty(changedList)) {
LOG.info("getLastUpdateInstanceList, changedList is empty.");
return Collections.EMPTY_LIST;
return Collections.emptyList();
}
return changedList.parallelStream()
.map(this::getClusterLastUpdateInstance)
Expand All @@ -143,13 +142,12 @@ private List<UpstreamInstance> getLastUpdateInstanceList(final List<SelectorData
*
* @return List
*/
@SuppressWarnings("unchecked")
private List<UpstreamInstance> getAllClusterLastUpdateInstanceList() {
List<String> pluginNames = new ArrayList<>();
RpcTypeEnum.acquireSupportSwaggers().forEach(rpcTypeEnum -> pluginNames.add(PluginNameAdapter.rpcTypeAdapter(rpcTypeEnum.getName())));
final List<PluginDO> pluginDOList = pluginMapper.selectByNames(pluginNames);
if (CollectionUtils.isEmpty(pluginDOList)) {
return Collections.EMPTY_LIST;
return Collections.emptyList();
}
supportSwaggerPluginMap = pluginDOList.stream().filter(Objects::nonNull)
.collect(Collectors.toMap(PluginDO::getId, PluginDO::getName, (value1, value2) -> value1));
Expand All @@ -158,7 +156,7 @@ private List<UpstreamInstance> getAllClusterLastUpdateInstanceList() {
List<SelectorVO> clusterList = commonPager.getDataList();
if (CollectionUtils.isEmpty(clusterList)) {
LOG.info("getAllClusterLastUpdateInstanceList, Not loaded into available backend services.");
return Collections.EMPTY_LIST;
return Collections.emptyList();
}
return clusterList.parallelStream()
.map(this::getClusterLastUpdateInstance)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ protected List<DocParameter> buildDocParameters(final String ref, final JsonObje

private List<String> jsonArrayToStringList(final JsonArray jsonArray) {
if (Objects.isNull(jsonArray)) {
return Collections.EMPTY_LIST;
return Collections.emptyList();
}
List<String> list = new ArrayList<>(jsonArray.size());
for (JsonElement jsonElement : jsonArray) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public void setUp() {

@Test
public void testSelectAll() throws Exception {
given(roleService.selectAll()).willReturn(Collections.EMPTY_LIST);
given(roleService.selectAll()).willReturn(Collections.emptyList());
this.mockMvc.perform(MockMvcRequestBuilders.get("/role/getAllRoles"))
.andExpect(status().isOk())
.andExpect(jsonPath("$.message", is(ShenyuResultMessage.QUERY_SUCCESS)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void testToString() {
ConfigData<Object> configData = new ConfigData<>();
configData.setLastModifyTime(LAST_MODIFY_TIME);
configData.setMd5(MD5);
configData.setData(Collections.EMPTY_LIST);
configData.setData(Collections.emptyList());
assertNotNull(configData.toString());
}

Expand All @@ -48,8 +48,8 @@ public void testToString() {
*/
@Test
public void testGetterSetter() {
ConfigData<Object> configData = new ConfigData<>(MD5, LAST_MODIFY_TIME, Collections.EMPTY_LIST);
assertEquals(configData.getData(), Collections.EMPTY_LIST);
ConfigData<Object> configData = new ConfigData<>(MD5, LAST_MODIFY_TIME, Collections.emptyList());
assertEquals(configData.getData(), Collections.emptyList());
assertEquals(configData.getMd5(), MD5);
assertEquals(configData.getLastModifyTime(), LAST_MODIFY_TIME);
}
Expand Down

0 comments on commit b471b4d

Please sign in to comment.