This is an automated email from the ASF dual-hosted git repository. guangning pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/pulsar-manager.git
The following commit(s) were added to refs/heads/master by this push: new f4bcc76 Remove redundant local variables from services' implementation (#229) f4bcc76 is described below commit f4bcc76db12f6f55562ffb02fe6056d27eae344a Author: Sergii Zhevzhyk <vzhiks...@users.noreply.github.com> AuthorDate: Sat Dec 7 01:37:26 2019 +0100 Remove redundant local variables from services' implementation (#229) --- .../apache/pulsar/manager/controller/TopicsController.java | 6 ++---- .../pulsar/manager/dao/ConsumersStatsRepositoryImpl.java | 11 +++-------- .../pulsar/manager/dao/PublishersStatsRepositoryImpl.java | 3 +-- .../pulsar/manager/dao/ReplicationsStatsRepositoryImpl.java | 4 +--- .../pulsar/manager/dao/SubscriptionsStatsRepositoryImpl.java | 3 +-- .../apache/pulsar/manager/dao/TopicsStatsRepositoryImpl.java | 12 +++--------- .../org/apache/pulsar/manager/dao/UsersRepositoryImpl.java | 3 +-- .../pulsar/manager/service/impl/BrokerStatsServiceImpl.java | 3 +-- .../manager/service/impl/EnvironmentCacheServiceImpl.java | 3 +-- .../apache/pulsar/manager/service/impl/JwtServiceImpl.java | 9 +++------ 10 files changed, 17 insertions(+), 40 deletions(-) diff --git a/src/main/java/org/apache/pulsar/manager/controller/TopicsController.java b/src/main/java/org/apache/pulsar/manager/controller/TopicsController.java index 93aaa02..3075076 100644 --- a/src/main/java/org/apache/pulsar/manager/controller/TopicsController.java +++ b/src/main/java/org/apache/pulsar/manager/controller/TopicsController.java @@ -74,8 +74,7 @@ public class TopicsController { @Size(min = 1, max = 255) @PathVariable String namespace) { String requestHost = environmentCacheService.getServiceUrl(request); - Map<String, Object> result = topicsService.getTopicsList(pageNum, pageSize, tenant, namespace, requestHost); - return result; + return topicsService.getTopicsList(pageNum, pageSize, tenant, namespace, requestHost); } @ApiOperation(value = "Query topic stats info by tenant and namespace") @@ -101,10 +100,9 @@ public class TopicsController { @PathVariable String namespace) { String env = request.getHeader("environment"); String serviceUrl = environmentCacheService.getServiceUrl(request); - Map<String, Object> result = topicsService.getTopicStats( + return topicsService.getTopicStats( pageNum, pageSize, tenant, namespace, env, serviceUrl); - return result; } } \ No newline at end of file diff --git a/src/main/java/org/apache/pulsar/manager/dao/ConsumersStatsRepositoryImpl.java b/src/main/java/org/apache/pulsar/manager/dao/ConsumersStatsRepositoryImpl.java index a59bfe9..64c17c2 100644 --- a/src/main/java/org/apache/pulsar/manager/dao/ConsumersStatsRepositoryImpl.java +++ b/src/main/java/org/apache/pulsar/manager/dao/ConsumersStatsRepositoryImpl.java @@ -40,24 +40,19 @@ public class ConsumersStatsRepositoryImpl implements ConsumersStatsRepository { public Page<ConsumerStatsEntity> findByTopicStatsId(Integer pageNum, Integer pageSize, long topicStatsId, long timestamp) { PageHelper.startPage(pageNum, pageSize); - Page<ConsumerStatsEntity> consumerStatsEntities = consumerStatsMapper.findByTopicStatsId( - topicStatsId, timestamp); - return consumerStatsEntities; + return consumerStatsMapper.findByTopicStatsId(topicStatsId, timestamp); } public Page<ConsumerStatsEntity> findBySubscriptionStatsId(Integer pageNum, Integer pageSize, long subscriptionStatsId, long timestamp) { PageHelper.startPage(pageNum, pageSize); - Page<ConsumerStatsEntity> consumerStatsEntities = consumerStatsMapper.findBySubscriptionStatsId(subscriptionStatsId, timestamp); - return consumerStatsEntities; + return consumerStatsMapper.findBySubscriptionStatsId(subscriptionStatsId, timestamp); } public Page<ConsumerStatsEntity> findByReplicationStatsId(Integer pageNum, Integer pageSize, long replicationStatsId, long timestamp) { PageHelper.startPage(pageNum, pageSize); - Page<ConsumerStatsEntity> consumerStatsEntities = consumerStatsMapper.findByReplicationStatsId( - replicationStatsId, timestamp); - return consumerStatsEntities; + return consumerStatsMapper.findByReplicationStatsId(replicationStatsId, timestamp); } public void remove(long timestamp, long timeInterval) { diff --git a/src/main/java/org/apache/pulsar/manager/dao/PublishersStatsRepositoryImpl.java b/src/main/java/org/apache/pulsar/manager/dao/PublishersStatsRepositoryImpl.java index 6c40efe..62d3343 100644 --- a/src/main/java/org/apache/pulsar/manager/dao/PublishersStatsRepositoryImpl.java +++ b/src/main/java/org/apache/pulsar/manager/dao/PublishersStatsRepositoryImpl.java @@ -39,8 +39,7 @@ public class PublishersStatsRepositoryImpl implements PublishersStatsRepository public Page<PublisherStatsEntity> findByTopicStatsId(Integer pageNum, Integer pageSize, long topicStatsId, long timestamp) { PageHelper.startPage(pageNum, pageSize); - Page<PublisherStatsEntity> publisherStatsEntities = publishersStatsMapper.findByTopicStatsId(topicStatsId, timestamp); - return publisherStatsEntities; + return publishersStatsMapper.findByTopicStatsId(topicStatsId, timestamp); } public void remove(long timestamp, long timeInterval) { diff --git a/src/main/java/org/apache/pulsar/manager/dao/ReplicationsStatsRepositoryImpl.java b/src/main/java/org/apache/pulsar/manager/dao/ReplicationsStatsRepositoryImpl.java index 393e451..ab6b10e 100644 --- a/src/main/java/org/apache/pulsar/manager/dao/ReplicationsStatsRepositoryImpl.java +++ b/src/main/java/org/apache/pulsar/manager/dao/ReplicationsStatsRepositoryImpl.java @@ -39,9 +39,7 @@ public class ReplicationsStatsRepositoryImpl implements ReplicationsStatsReposit public Page<ReplicationStatsEntity> findByTopicStatsId(Integer pageNum, Integer pageSize, long topicStatsId, long timestamp) { PageHelper.startPage(pageNum, pageSize); - Page<ReplicationStatsEntity> replicationStatsEntities = replicationsStatsMapper.findByTopicStatsId( - topicStatsId, timestamp); - return replicationStatsEntities; + return replicationsStatsMapper.findByTopicStatsId(topicStatsId, timestamp); } public void remove(long timestamp, long timeInterval) { diff --git a/src/main/java/org/apache/pulsar/manager/dao/SubscriptionsStatsRepositoryImpl.java b/src/main/java/org/apache/pulsar/manager/dao/SubscriptionsStatsRepositoryImpl.java index 06b70a0..1b30f72 100644 --- a/src/main/java/org/apache/pulsar/manager/dao/SubscriptionsStatsRepositoryImpl.java +++ b/src/main/java/org/apache/pulsar/manager/dao/SubscriptionsStatsRepositoryImpl.java @@ -39,8 +39,7 @@ public class SubscriptionsStatsRepositoryImpl implements SubscriptionsStatsRepos public Page<SubscriptionStatsEntity> findByTopicStatsId(Integer pageNum, Integer pageSize, long topicStatsId, long timestamp) { PageHelper.startPage(pageNum, pageSize); - Page<SubscriptionStatsEntity> subscriptionStatsEntities = subscriptionsStatsMapper.findByTopicStatsId(topicStatsId, timestamp); - return subscriptionStatsEntities; + return subscriptionsStatsMapper.findByTopicStatsId(topicStatsId, timestamp); } public void remove(long timestamp, long timeInterval) { diff --git a/src/main/java/org/apache/pulsar/manager/dao/TopicsStatsRepositoryImpl.java b/src/main/java/org/apache/pulsar/manager/dao/TopicsStatsRepositoryImpl.java index a5990b1..79d8932 100644 --- a/src/main/java/org/apache/pulsar/manager/dao/TopicsStatsRepositoryImpl.java +++ b/src/main/java/org/apache/pulsar/manager/dao/TopicsStatsRepositoryImpl.java @@ -48,9 +48,7 @@ public class TopicsStatsRepositoryImpl implements TopicsStatsRepository { String broker, long timestamp) { PageHelper.startPage(pageNum, pageSize); - Page<TopicStatsEntity> topicStatsEntities = - topicsStatsMapper.findByClusterBroker(environment, cluster, broker, timestamp); - return topicStatsEntities; + return topicsStatsMapper.findByClusterBroker(environment, cluster, broker, timestamp); } public Page<TopicStatsEntity> findByNamespace(Integer pageNum, @@ -60,9 +58,7 @@ public class TopicsStatsRepositoryImpl implements TopicsStatsRepository { String namespace, long timestamp) { PageHelper.startPage(pageNum, pageSize); - Page<TopicStatsEntity> topicStatsEntities = - topicsStatsMapper.findByNamespace(environment, tenant, namespace, timestamp); - return topicStatsEntities; + return topicsStatsMapper.findByNamespace(environment, tenant, namespace, timestamp); } public Page<TopicStatsEntity> findByMultiTopic(Integer pageNum, @@ -73,9 +69,7 @@ public class TopicsStatsRepositoryImpl implements TopicsStatsRepository { String persistent, List<String> topicList, long timestamp) { PageHelper.startPage(pageNum, pageSize); - Page<TopicStatsEntity> topicStatsEntities = topicsStatsMapper.findByMultiTopic( - environment, tenant, namespace, persistent, topicList, timestamp); - return topicStatsEntities; + return topicsStatsMapper.findByMultiTopic(environment, tenant, namespace, persistent, topicList, timestamp); } public void remove(long timestamp, long timeInterval) { diff --git a/src/main/java/org/apache/pulsar/manager/dao/UsersRepositoryImpl.java b/src/main/java/org/apache/pulsar/manager/dao/UsersRepositoryImpl.java index 410c5f1..bc1848f 100644 --- a/src/main/java/org/apache/pulsar/manager/dao/UsersRepositoryImpl.java +++ b/src/main/java/org/apache/pulsar/manager/dao/UsersRepositoryImpl.java @@ -35,8 +35,7 @@ public class UsersRepositoryImpl implements UsersRepository { @Override public long save(UserInfoEntity userInfoEntity) { - long userId = this.usersMapper.save(userInfoEntity); - return userId; + return this.usersMapper.save(userInfoEntity); } @Override diff --git a/src/main/java/org/apache/pulsar/manager/service/impl/BrokerStatsServiceImpl.java b/src/main/java/org/apache/pulsar/manager/service/impl/BrokerStatsServiceImpl.java index ed78b08..258d924 100644 --- a/src/main/java/org/apache/pulsar/manager/service/impl/BrokerStatsServiceImpl.java +++ b/src/main/java/org/apache/pulsar/manager/service/impl/BrokerStatsServiceImpl.java @@ -288,7 +288,6 @@ public class BrokerStatsServiceImpl implements BrokerStatsService { private String[] parseTopic(String topic) { String tntPath = topic.split("://")[1]; - String[] topicPath = tntPath.split("/"); - return topicPath; + return tntPath.split("/"); } } diff --git a/src/main/java/org/apache/pulsar/manager/service/impl/EnvironmentCacheServiceImpl.java b/src/main/java/org/apache/pulsar/manager/service/impl/EnvironmentCacheServiceImpl.java index b5fcaa5..40bf894 100644 --- a/src/main/java/org/apache/pulsar/manager/service/impl/EnvironmentCacheServiceImpl.java +++ b/src/main/java/org/apache/pulsar/manager/service/impl/EnvironmentCacheServiceImpl.java @@ -73,8 +73,7 @@ public class EnvironmentCacheServiceImpl implements EnvironmentCacheService { // if there is no cluster is specified, forward the request to environment service url Optional<EnvironmentEntity> environmentEntityOptional = environmentsRepository.findByName(environment); EnvironmentEntity environmentEntity = environmentEntityOptional.get(); - String directRequestHost = environmentEntity.getBroker(); - return directRequestHost; + return environmentEntity.getBroker(); } else { return getServiceUrl(environment, cluster, 0); } diff --git a/src/main/java/org/apache/pulsar/manager/service/impl/JwtServiceImpl.java b/src/main/java/org/apache/pulsar/manager/service/impl/JwtServiceImpl.java index ce2cbe7..fa460e5 100644 --- a/src/main/java/org/apache/pulsar/manager/service/impl/JwtServiceImpl.java +++ b/src/main/java/org/apache/pulsar/manager/service/impl/JwtServiceImpl.java @@ -104,8 +104,7 @@ public class JwtServiceImpl implements JwtService { private Key decodeBySecretKey() { try { byte[] encodedKey = AuthTokenUtils.readKeyFromUrl(jwtBrokerSecretKey); - Key signingKey = AuthTokenUtils.decodeSecretKey(encodedKey); - return signingKey; + return AuthTokenUtils.decodeSecretKey(encodedKey); } catch (IOException e) { log.error("Decode failed by secrete key, error: {}", e.getMessage()); return null; @@ -132,16 +131,14 @@ public class JwtServiceImpl implements JwtService { .toMillis(RelativeTimeUtil.parseRelativeTimeInSeconds(expiryTime)); optExpiryTime = Optional.of(new Date(System.currentTimeMillis() + relativeTimeMillis)); } - String token = AuthTokenUtils.createToken(signingKey, role, optExpiryTime); - return token; + return AuthTokenUtils.createToken(signingKey, role, optExpiryTime); } private Key decodeByPrivateKey() { try { byte[] encodedKey = AuthTokenUtils.readKeyFromUrl(jwtBrokerPrivateKey); SignatureAlgorithm algorithm = SignatureAlgorithm.RS256; - Key signingKey = AuthTokenUtils.decodePrivateKey(encodedKey, algorithm); - return signingKey; + return AuthTokenUtils.decodePrivateKey(encodedKey, algorithm); } catch (IOException e) { log.error("Decode failed by private key, error: {}", e.getMessage()); return null;