Merge pull request #1374 from zhaoyuguang/study

All overriding methods must be preceded by @Override annotations.
This commit is contained in:
Fury Zhu 2019-06-18 11:33:02 +08:00 committed by GitHub
commit d5873a21e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 55 additions and 1 deletions

View File

@ -193,6 +193,7 @@ public abstract class AbstractHealthChecker implements Cloneable {
} }
@Override
public Tcp clone() throws CloneNotSupportedException { public Tcp clone() throws CloneNotSupportedException {
Tcp config = new Tcp(); Tcp config = new Tcp();
config.setType(this.type); config.setType(this.type);

View File

@ -426,6 +426,7 @@ public class ServerHttpAgent implements HttpAgent {
return code; return code;
} }
@Override
public String toString() { public String toString() {
return "STSCredential{" + return "STSCredential{" +
"accessKeyId='" + accessKeyId + '\'' + "accessKeyId='" + accessKeyId + '\'' +

View File

@ -168,7 +168,6 @@ public class CacheData {
final Listener listener = listenerWrap.listener; final Listener listener = listenerWrap.listener;
Runnable job = new Runnable() { Runnable job = new Runnable() {
@Override @Override
public void run() { public void run() {
ClassLoader myClassLoader = Thread.currentThread().getContextClassLoader(); ClassLoader myClassLoader = Thread.currentThread().getContextClassLoader();

View File

@ -36,6 +36,7 @@ public class TimerService {
@SuppressWarnings("PMD.ThreadPoolCreationRule") @SuppressWarnings("PMD.ThreadPoolCreationRule")
static ScheduledExecutorService scheduledExecutor = Executors static ScheduledExecutorService scheduledExecutor = Executors
.newSingleThreadScheduledExecutor(new ThreadFactory() { .newSingleThreadScheduledExecutor(new ThreadFactory() {
@Override
public Thread newThread(Runnable r) { public Thread newThread(Runnable r) {
Thread t = new Thread(r); Thread t = new Thread(r);
t.setName("com.alibaba.nacos.client.Timer"); t.setName("com.alibaba.nacos.client.Timer");

View File

@ -85,6 +85,7 @@ public final class CredentialService implements SpasCredentialLoader {
LOGGER.info("[{}] {} is freed", appName, this.getClass().getSimpleName()); LOGGER.info("[{}] {} is freed", appName, this.getClass().getSimpleName());
} }
@Override
public Credentials getCredential() { public Credentials getCredential() {
Credentials localCredential = credentials; Credentials localCredential = credentials;
if (localCredential.valid()) { if (localCredential.valid()) {

View File

@ -38,6 +38,7 @@ public class Credentials implements SpasCredential {
this(null, null, null); this(null, null, null);
} }
@Override
public String getAccessKey() { public String getAccessKey() {
return accessKey; return accessKey;
} }
@ -46,6 +47,7 @@ public class Credentials implements SpasCredential {
this.accessKey = accessKey; this.accessKey = accessKey;
} }
@Override
public String getSecretKey() { public String getSecretKey() {
return secretKey; return secretKey;
} }

View File

@ -212,6 +212,7 @@ public class FailoverReactor {
} }
class DiskFileWriter extends TimerTask { class DiskFileWriter extends TimerTask {
@Override
public void run() { public void run() {
Map<String, ServiceInfo> map = hostReactor.getServiceInfoMap(); Map<String, ServiceInfo> map = hostReactor.getServiceInfoMap();
for (Map.Entry<String, ServiceInfo> entry : map.entrySet()) { for (Map.Entry<String, ServiceInfo> entry : map.entrySet()) {

View File

@ -31,10 +31,12 @@ public class GenericPoller<T> implements Poller<T> {
this.items = items; this.items = items;
} }
@Override
public T next() { public T next() {
return items.get(Math.abs(index.getAndIncrement() % items.size())); return items.get(Math.abs(index.getAndIncrement() % items.size()));
} }
@Override
public Poller<T> refresh(List<T> items) { public Poller<T> refresh(List<T> items) {
return new GenericPoller<T>(items); return new GenericPoller<T>(items);
} }

View File

@ -63,6 +63,7 @@ public final class JvmRandom extends Random {
* @param seed ignored * @param seed ignored
* @throws UnsupportedOperationException * @throws UnsupportedOperationException
*/ */
@Override
public synchronized void setSeed(long seed) { public synchronized void setSeed(long seed) {
if (this.constructed) { if (this.constructed) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
@ -75,6 +76,7 @@ public final class JvmRandom extends Random {
* @return Nothing, this method always throws an UnsupportedOperationException. * @return Nothing, this method always throws an UnsupportedOperationException.
* @throws UnsupportedOperationException * @throws UnsupportedOperationException
*/ */
@Override
public synchronized double nextGaussian() { public synchronized double nextGaussian() {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@ -85,6 +87,7 @@ public final class JvmRandom extends Random {
* @param byteArray ignored * @param byteArray ignored
* @throws UnsupportedOperationException * @throws UnsupportedOperationException
*/ */
@Override
public void nextBytes(byte[] byteArray) { public void nextBytes(byte[] byteArray) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@ -95,6 +98,7 @@ public final class JvmRandom extends Random {
* *
* @return the random int * @return the random int
*/ */
@Override
public int nextInt() { public int nextInt() {
return nextInt(Integer.MAX_VALUE); return nextInt(Integer.MAX_VALUE);
} }
@ -107,6 +111,7 @@ public final class JvmRandom extends Random {
* @return the random int * @return the random int
* @throws IllegalArgumentException when <code>n &lt;= 0</code> * @throws IllegalArgumentException when <code>n &lt;= 0</code>
*/ */
@Override
public int nextInt(int n) { public int nextInt(int n) {
return SHARED_RANDOM.nextInt(n); return SHARED_RANDOM.nextInt(n);
} }
@ -117,6 +122,7 @@ public final class JvmRandom extends Random {
* *
* @return the random long * @return the random long
*/ */
@Override
public long nextLong() { public long nextLong() {
return nextLong(Long.MAX_VALUE); return nextLong(Long.MAX_VALUE);
} }
@ -158,6 +164,7 @@ public final class JvmRandom extends Random {
* *
* @return the random boolean * @return the random boolean
*/ */
@Override
public boolean nextBoolean() { public boolean nextBoolean() {
return SHARED_RANDOM.nextBoolean(); return SHARED_RANDOM.nextBoolean();
} }
@ -168,6 +175,7 @@ public final class JvmRandom extends Random {
* *
* @return the random float * @return the random float
*/ */
@Override
public float nextFloat() { public float nextFloat() {
return SHARED_RANDOM.nextFloat(); return SHARED_RANDOM.nextFloat();
} }
@ -177,6 +185,7 @@ public final class JvmRandom extends Random {
* *
* @return the random double * @return the random double
*/ */
@Override
public double nextDouble() { public double nextDouble() {
return SHARED_RANDOM.nextDouble(); return SHARED_RANDOM.nextDouble();
} }

View File

@ -146,6 +146,7 @@ public class ThreadLocalRandom extends Random {
* The actual ThreadLocal * The actual ThreadLocal
*/ */
private static final ThreadLocal<ThreadLocalRandom> localRandom = new ThreadLocal<ThreadLocalRandom>() { private static final ThreadLocal<ThreadLocalRandom> localRandom = new ThreadLocal<ThreadLocalRandom>() {
@Override
protected ThreadLocalRandom initialValue() { protected ThreadLocalRandom initialValue() {
return new ThreadLocalRandom(); return new ThreadLocalRandom();
} }
@ -165,6 +166,7 @@ public class ThreadLocalRandom extends Random {
* *
* @throws UnsupportedOperationException always * @throws UnsupportedOperationException always
*/ */
@Override
public void setSeed(long seed) { public void setSeed(long seed) {
if (initialized) { if (initialized) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
@ -172,6 +174,7 @@ public class ThreadLocalRandom extends Random {
rnd = (seed ^ multiplier) & mask; rnd = (seed ^ multiplier) & mask;
} }
@Override
protected int next(int bits) { protected int next(int bits) {
rnd = (rnd * multiplier + addend) & mask; rnd = (rnd * multiplier + addend) & mask;
return (int)(rnd >>> (48 - bits)); return (int)(rnd >>> (48 - bits));

View File

@ -55,6 +55,7 @@ public final class TaskManager implements TaskManagerMBean {
class ProcessRunnable implements Runnable { class ProcessRunnable implements Runnable {
@Override
public void run() { public void run() {
while (!TaskManager.this.closed.get()) { while (!TaskManager.this.closed.get()) {
try { try {
@ -248,6 +249,7 @@ public final class TaskManager implements TaskManagerMBean {
} }
} }
@Override
public String getTaskInfos() { public String getTaskInfos() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
for (String taskType : this.taskProcessors.keySet()) { for (String taskType : this.taskProcessors.keySet()) {

View File

@ -94,6 +94,7 @@ public class ConfigInfoBase implements Serializable, Comparable<ConfigInfoBase>
writer.write(this.content); writer.write(this.content);
} }
@Override
public int compareTo(ConfigInfoBase o) { public int compareTo(ConfigInfoBase o) {
if (o == null) { if (o == null) {
return 1; return 1;

View File

@ -54,6 +54,7 @@ public class GroupKey extends GroupKey2 {
this.group = group; this.group = group;
} }
@Override
public String toString() { public String toString() {
return dataId + "+" + group; return dataId + "+" + group;
} }

View File

@ -32,6 +32,7 @@ public class DynamicDataSource implements ApplicationContextAware {
private ApplicationContext applicationContext; private ApplicationContext applicationContext;
@Override
public void setApplicationContext(ApplicationContext applicationContext) { public void setApplicationContext(ApplicationContext applicationContext) {
this.applicationContext = applicationContext; this.applicationContext = applicationContext;
} }

View File

@ -371,6 +371,7 @@ public class LongPollingService extends AbstractEventListener {
@Override @Override
public void run() { public void run() {
asyncTimeoutFuture = scheduler.schedule(new Runnable() { asyncTimeoutFuture = scheduler.schedule(new Runnable() {
@Override
public void run() { public void run() {
try { try {
getRetainIps().put(ClientLongPolling.this.ip, System.currentTimeMillis()); getRetainIps().put(ClientLongPolling.this.ip, System.currentTimeMillis());

View File

@ -94,6 +94,7 @@ public class PersistService {
static final class ConfigInfoWrapperRowMapper implements static final class ConfigInfoWrapperRowMapper implements
RowMapper<ConfigInfoWrapper> { RowMapper<ConfigInfoWrapper> {
@Override
public ConfigInfoWrapper mapRow(ResultSet rs, int rowNum) public ConfigInfoWrapper mapRow(ResultSet rs, int rowNum)
throws SQLException { throws SQLException {
ConfigInfoWrapper info = new ConfigInfoWrapper(); ConfigInfoWrapper info = new ConfigInfoWrapper();
@ -128,6 +129,7 @@ public class PersistService {
static final class ConfigInfoBetaWrapperRowMapper implements static final class ConfigInfoBetaWrapperRowMapper implements
RowMapper<ConfigInfoBetaWrapper> { RowMapper<ConfigInfoBetaWrapper> {
@Override
public ConfigInfoBetaWrapper mapRow(ResultSet rs, int rowNum) public ConfigInfoBetaWrapper mapRow(ResultSet rs, int rowNum)
throws SQLException { throws SQLException {
ConfigInfoBetaWrapper info = new ConfigInfoBetaWrapper(); ConfigInfoBetaWrapper info = new ConfigInfoBetaWrapper();
@ -163,6 +165,7 @@ public class PersistService {
static final class ConfigInfoTagWrapperRowMapper implements static final class ConfigInfoTagWrapperRowMapper implements
RowMapper<ConfigInfoTagWrapper> { RowMapper<ConfigInfoTagWrapper> {
@Override
public ConfigInfoTagWrapper mapRow(ResultSet rs, int rowNum) public ConfigInfoTagWrapper mapRow(ResultSet rs, int rowNum)
throws SQLException { throws SQLException {
ConfigInfoTagWrapper info = new ConfigInfoTagWrapper(); ConfigInfoTagWrapper info = new ConfigInfoTagWrapper();
@ -198,6 +201,7 @@ public class PersistService {
static final class ConfigInfoRowMapper implements static final class ConfigInfoRowMapper implements
RowMapper<ConfigInfo> { RowMapper<ConfigInfo> {
@Override
public ConfigInfo mapRow(ResultSet rs, int rowNum) throws SQLException { public ConfigInfo mapRow(ResultSet rs, int rowNum) throws SQLException {
ConfigInfo info = new ConfigInfo(); ConfigInfo info = new ConfigInfo();
@ -227,6 +231,7 @@ public class PersistService {
static final class ConfigKeyRowMapper implements static final class ConfigKeyRowMapper implements
RowMapper<ConfigKey> { RowMapper<ConfigKey> {
@Override
public ConfigKey mapRow(ResultSet rs, int rowNum) throws SQLException { public ConfigKey mapRow(ResultSet rs, int rowNum) throws SQLException {
ConfigKey info = new ConfigKey(); ConfigKey info = new ConfigKey();
@ -239,6 +244,7 @@ public class PersistService {
} }
static final class ConfigAdvanceInfoRowMapper implements RowMapper<ConfigAdvanceInfo> { static final class ConfigAdvanceInfoRowMapper implements RowMapper<ConfigAdvanceInfo> {
@Override
public ConfigAdvanceInfo mapRow(ResultSet rs, int rowNum) throws SQLException { public ConfigAdvanceInfo mapRow(ResultSet rs, int rowNum) throws SQLException {
ConfigAdvanceInfo info = new ConfigAdvanceInfo(); ConfigAdvanceInfo info = new ConfigAdvanceInfo();
info.setCreateTime(rs.getTimestamp("gmt_modified").getTime()); info.setCreateTime(rs.getTimestamp("gmt_modified").getTime());
@ -255,6 +261,7 @@ public class PersistService {
} }
static final class ConfigAllInfoRowMapper implements RowMapper<ConfigAllInfo> { static final class ConfigAllInfoRowMapper implements RowMapper<ConfigAllInfo> {
@Override
public ConfigAllInfo mapRow(ResultSet rs, int rowNum) throws SQLException { public ConfigAllInfo mapRow(ResultSet rs, int rowNum) throws SQLException {
ConfigAllInfo info = new ConfigAllInfo(); ConfigAllInfo info = new ConfigAllInfo();
info.setDataId(rs.getString("data_id")); info.setDataId(rs.getString("data_id"));
@ -291,6 +298,7 @@ public class PersistService {
static final class ConfigInfo4BetaRowMapper implements static final class ConfigInfo4BetaRowMapper implements
RowMapper<ConfigInfo4Beta> { RowMapper<ConfigInfo4Beta> {
@Override
public ConfigInfo4Beta mapRow(ResultSet rs, int rowNum) throws SQLException { public ConfigInfo4Beta mapRow(ResultSet rs, int rowNum) throws SQLException {
ConfigInfo4Beta info = new ConfigInfo4Beta(); ConfigInfo4Beta info = new ConfigInfo4Beta();
@ -320,6 +328,7 @@ public class PersistService {
static final class ConfigInfo4TagRowMapper implements static final class ConfigInfo4TagRowMapper implements
RowMapper<ConfigInfo4Tag> { RowMapper<ConfigInfo4Tag> {
@Override
public ConfigInfo4Tag mapRow(ResultSet rs, int rowNum) throws SQLException { public ConfigInfo4Tag mapRow(ResultSet rs, int rowNum) throws SQLException {
ConfigInfo4Tag info = new ConfigInfo4Tag(); ConfigInfo4Tag info = new ConfigInfo4Tag();
@ -349,6 +358,7 @@ public class PersistService {
static final class ConfigInfoBaseRowMapper implements static final class ConfigInfoBaseRowMapper implements
RowMapper<ConfigInfoBase> { RowMapper<ConfigInfoBase> {
@Override
public ConfigInfoBase mapRow(ResultSet rs, int rowNum) throws SQLException { public ConfigInfoBase mapRow(ResultSet rs, int rowNum) throws SQLException {
ConfigInfoBase info = new ConfigInfoBase(); ConfigInfoBase info = new ConfigInfoBase();
@ -371,6 +381,7 @@ public class PersistService {
static final class ConfigInfoAggrRowMapper implements static final class ConfigInfoAggrRowMapper implements
RowMapper<ConfigInfoAggr> { RowMapper<ConfigInfoAggr> {
@Override
public ConfigInfoAggr mapRow(ResultSet rs, int rowNum) public ConfigInfoAggr mapRow(ResultSet rs, int rowNum)
throws SQLException { throws SQLException {
ConfigInfoAggr info = new ConfigInfoAggr(); ConfigInfoAggr info = new ConfigInfoAggr();
@ -385,6 +396,7 @@ public class PersistService {
} }
static final class ConfigInfoChangedRowMapper implements RowMapper<ConfigInfoChanged> { static final class ConfigInfoChangedRowMapper implements RowMapper<ConfigInfoChanged> {
@Override
public ConfigInfoChanged mapRow(ResultSet rs, int rowNum) throws SQLException { public ConfigInfoChanged mapRow(ResultSet rs, int rowNum) throws SQLException {
ConfigInfoChanged info = new ConfigInfoChanged(); ConfigInfoChanged info = new ConfigInfoChanged();
info.setDataId(rs.getString("data_id")); info.setDataId(rs.getString("data_id"));
@ -395,6 +407,7 @@ public class PersistService {
} }
static final class ConfigHistoryRowMapper implements RowMapper<ConfigHistoryInfo> { static final class ConfigHistoryRowMapper implements RowMapper<ConfigHistoryInfo> {
@Override
public ConfigHistoryInfo mapRow(ResultSet rs, int rowNum) throws SQLException { public ConfigHistoryInfo mapRow(ResultSet rs, int rowNum) throws SQLException {
ConfigHistoryInfo configHistoryInfo = new ConfigHistoryInfo(); ConfigHistoryInfo configHistoryInfo = new ConfigHistoryInfo();
configHistoryInfo.setId(rs.getLong("nid")); configHistoryInfo.setId(rs.getLong("nid"));
@ -411,6 +424,7 @@ public class PersistService {
} }
static final class ConfigHistoryDetailRowMapper implements RowMapper<ConfigHistoryInfo> { static final class ConfigHistoryDetailRowMapper implements RowMapper<ConfigHistoryInfo> {
@Override
public ConfigHistoryInfo mapRow(ResultSet rs, int rowNum) throws SQLException { public ConfigHistoryInfo mapRow(ResultSet rs, int rowNum) throws SQLException {
ConfigHistoryInfo configHistoryInfo = new ConfigHistoryInfo(); ConfigHistoryInfo configHistoryInfo = new ConfigHistoryInfo();
configHistoryInfo.setId(rs.getLong("nid")); configHistoryInfo.setId(rs.getLong("nid"));
@ -432,6 +446,7 @@ public class PersistService {
; ;
static final class TenantInfoRowMapper implements RowMapper<TenantInfo> { static final class TenantInfoRowMapper implements RowMapper<TenantInfo> {
@Override
public TenantInfo mapRow(ResultSet rs, int rowNum) throws SQLException { public TenantInfo mapRow(ResultSet rs, int rowNum) throws SQLException {
TenantInfo info = new TenantInfo(); TenantInfo info = new TenantInfo();
info.setTenantId(rs.getString("tenant_id")); info.setTenantId(rs.getString("tenant_id"));
@ -442,6 +457,7 @@ public class PersistService {
} }
static final class UserRowMapper implements RowMapper<User> { static final class UserRowMapper implements RowMapper<User> {
@Override
public User mapRow(ResultSet rs, int rowNum) throws SQLException { public User mapRow(ResultSet rs, int rowNum) throws SQLException {
User user = new User(); User user = new User();
user.setUsername(rs.getString("username")); user.setUsername(rs.getString("username"));
@ -799,6 +815,7 @@ public class PersistService {
try { try {
this.jt.update(sql, new PreparedStatementSetter() { this.jt.update(sql, new PreparedStatementSetter() {
@Override
public void setValues(PreparedStatement ps) throws SQLException { public void setValues(PreparedStatement ps) throws SQLException {
int index = 1; int index = 1;
ps.setString(index++, dataId); ps.setString(index++, dataId);
@ -822,6 +839,7 @@ public class PersistService {
try { try {
this.jt.update(sql, new PreparedStatementSetter() { this.jt.update(sql, new PreparedStatementSetter() {
@Override
public void setValues(PreparedStatement ps) throws SQLException { public void setValues(PreparedStatement ps) throws SQLException {
int index = 1; int index = 1;
ps.setString(index++, dataId); ps.setString(index++, dataId);
@ -2637,6 +2655,7 @@ public class PersistService {
try { try {
jt.update(new PreparedStatementCreator() { jt.update(new PreparedStatementCreator() {
@Override
public PreparedStatement createPreparedStatement(Connection connection) throws SQLException { public PreparedStatement createPreparedStatement(Connection connection) throws SQLException {
PreparedStatement ps = connection.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS); PreparedStatement ps = connection.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
ps.setString(1, configInfo.getDataId()); ps.setString(1, configInfo.getDataId());

View File

@ -319,10 +319,12 @@ public class AsyncNotifyService extends AbstractEventListener {
// this.executor = executor; // this.executor = executor;
} }
@Override
public void setFailCount(int count) { public void setFailCount(int count) {
this.failCount = count; this.failCount = count;
} }
@Override
public int getFailCount() { public int getFailCount() {
return failCount; return failCount;
} }

View File

@ -35,6 +35,7 @@ public class SimpleFlowData {
@SuppressWarnings("PMD.ThreadPoolCreationRule") @SuppressWarnings("PMD.ThreadPoolCreationRule")
private ScheduledExecutorService timer = Executors.newSingleThreadScheduledExecutor(new ThreadFactory() { private ScheduledExecutorService timer = Executors.newSingleThreadScheduledExecutor(new ThreadFactory() {
@Override
public Thread newThread(Runnable r) { public Thread newThread(Runnable r) {
Thread t = new Thread(r); Thread t = new Thread(r);
t.setName("nacos flow control thread"); t.setName("nacos flow control thread");
@ -52,6 +53,7 @@ public class SimpleFlowData {
} }
timer.scheduleAtFixedRate(new Runnable() { timer.scheduleAtFixedRate(new Runnable() {
@Override
public void run() { public void run() {
rotateSlot(); rotateSlot();
} }

View File

@ -38,6 +38,7 @@ public class SimpleIPFlowData {
@SuppressWarnings("PMD.ThreadPoolCreationRule") @SuppressWarnings("PMD.ThreadPoolCreationRule")
private ScheduledExecutorService timer = Executors.newSingleThreadScheduledExecutor(new ThreadFactory() { private ScheduledExecutorService timer = Executors.newSingleThreadScheduledExecutor(new ThreadFactory() {
@Override
public Thread newThread(Runnable r) { public Thread newThread(Runnable r) {
Thread t = new Thread(r); Thread t = new Thread(r);
t.setName("nacos ip flow control thread"); t.setName("nacos ip flow control thread");
@ -49,6 +50,7 @@ public class SimpleIPFlowData {
class DefaultIPFlowDataManagerTask implements Runnable { class DefaultIPFlowDataManagerTask implements Runnable {
@Override
public void run() { public void run() {
rotateSlot(); rotateSlot();
} }

View File

@ -427,6 +427,7 @@ public class Service extends com.alibaba.nacos.api.naming.pojo.Service implement
recalculateChecksum(); recalculateChecksum();
} }
@Override
public String getChecksum() { public String getChecksum() {
if (StringUtils.isEmpty(checksum)) { if (StringUtils.isEmpty(checksum)) {
recalculateChecksum(); recalculateChecksum();

View File

@ -143,6 +143,7 @@ public class RsInfo {
this.metadata = metadata; this.metadata = metadata;
} }
@Override
public String toString() { public String toString() {
return JSON.toJSONString(this); return JSON.toJSONString(this);
} }

View File

@ -73,6 +73,7 @@ public class OverrideParameterRequestWrapper extends HttpServletRequestWrapper {
return params; return params;
} }
@Override
public String[] getParameterValues(String name) { public String[] getParameterValues(String name) {
return params.get(name); return params.get(name);
} }