Skip to content

Commit

Permalink
refactor: move default QA annotations to package 📝
Browse files Browse the repository at this point in the history
  • Loading branch information
oldratlee committed Sep 9, 2024
1 parent a233619 commit e617026
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 27 deletions.
4 changes: 0 additions & 4 deletions library/src/main/java/com/alibaba/dcm/DnsCache.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package com.alibaba.dcm;

import edu.umd.cs.findbugs.annotations.ReturnValuesAreNonnullByDefault;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;

import javax.annotation.ParametersAreNonnullByDefault;
import javax.annotation.concurrent.Immutable;
import java.io.Serializable;
import java.util.ArrayList;
Expand All @@ -17,8 +15,6 @@
* @since 1.2.0
*/
@Immutable
@ParametersAreNonnullByDefault
@ReturnValuesAreNonnullByDefault
public final class DnsCache implements Serializable {
private static final long serialVersionUID = -8614746635950970028L;

Expand Down
5 changes: 1 addition & 4 deletions library/src/main/java/com/alibaba/dcm/DnsCacheEntry.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package com.alibaba.dcm;

import edu.umd.cs.findbugs.annotations.ReturnValuesAreNonnullByDefault;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;

import javax.annotation.ParametersAreNonnullByDefault;
import javax.annotation.concurrent.Immutable;
import java.io.Serializable;
import java.text.SimpleDateFormat;
Expand All @@ -18,8 +16,6 @@
* @see DnsCache
*/
@Immutable
@ParametersAreNonnullByDefault
@ReturnValuesAreNonnullByDefault
public final class DnsCacheEntry implements Serializable {
private static final long serialVersionUID = -7476648934387757732L;

Expand Down Expand Up @@ -114,6 +110,7 @@ public boolean equals(Object o) {
* {@inheritDoc}
*/
@Override
@SuppressFBWarnings("RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE")
public int hashCode() {
int result = host != null ? host.hashCode() : 0;
result = 31 * result + Arrays.hashCode(ips);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package com.alibaba.dcm;

import com.alibaba.dcm.internal.InetAddressCacheUtilCommons;
import com.alibaba.dcm.internal.InetAddressCacheUtilForOld;
import com.alibaba.dcm.internal.InetAddressCacheUtilForNew;
import edu.umd.cs.findbugs.annotations.ReturnValuesAreNonnullByDefault;
import com.alibaba.dcm.internal.InetAddressCacheUtilForOld;
import sun.net.InetAddressCachePolicy;

import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Arrays;
Expand All @@ -30,8 +28,6 @@
* @see DnsCacheEntry
* @see DnsCacheManipulatorException
*/
@ParametersAreNonnullByDefault
@ReturnValuesAreNonnullByDefault
@SuppressWarnings("JavadocReference")
public final class DnsCacheManipulator {
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package com.alibaba.dcm.internal;

import edu.umd.cs.findbugs.annotations.ReturnValuesAreNonnullByDefault;
import org.jetbrains.annotations.ApiStatus;
import sun.net.InetAddressCachePolicy;

import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import java.lang.reflect.Field;
import java.net.InetAddress;
import java.net.UnknownHostException;
Expand All @@ -16,8 +14,6 @@
* @author Jerry Lee (oldratlee at gmail dot com)
* @since 1.6.0
*/
@ParametersAreNonnullByDefault
@ReturnValuesAreNonnullByDefault
@ApiStatus.Internal
@SuppressWarnings("JavadocReference")
public final class InetAddressCacheUtilCommons {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

import com.alibaba.dcm.DnsCache;
import com.alibaba.dcm.DnsCacheEntry;
import edu.umd.cs.findbugs.annotations.ReturnValuesAreNonnullByDefault;
import org.jetbrains.annotations.ApiStatus;

import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
Expand All @@ -19,7 +17,9 @@
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ConcurrentSkipListSet;

import static com.alibaba.dcm.internal.InetAddressCacheUtilCommons.*;
import static com.alibaba.dcm.internal.InetAddressCacheUtilCommons.NEVER_EXPIRATION;
import static com.alibaba.dcm.internal.InetAddressCacheUtilCommons.getIpFromInetAddress;
import static com.alibaba.dcm.internal.InetAddressCacheUtilCommons.toInetAddressArray;
import static com.alibaba.dcm.internal.TimeUtil.convertNanoTimeToTimeMillis;
import static com.alibaba.dcm.internal.TimeUtil.getNanoTimeAfterMs;

Expand All @@ -32,8 +32,6 @@
* @author Jerry Lee (oldratlee at gmail dot com)
* @since 1.6.0
*/
@ParametersAreNonnullByDefault
@ReturnValuesAreNonnullByDefault
@ApiStatus.Internal
@SuppressWarnings("JavadocReference")
public final class InetAddressCacheUtilForNew {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

import com.alibaba.dcm.DnsCache;
import com.alibaba.dcm.DnsCacheEntry;
import edu.umd.cs.findbugs.annotations.ReturnValuesAreNonnullByDefault;
import org.jetbrains.annotations.ApiStatus;

import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import javax.annotation.concurrent.GuardedBy;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
Expand All @@ -18,7 +16,9 @@
import java.util.List;
import java.util.Map;

import static com.alibaba.dcm.internal.InetAddressCacheUtilCommons.*;
import static com.alibaba.dcm.internal.InetAddressCacheUtilCommons.NEVER_EXPIRATION;
import static com.alibaba.dcm.internal.InetAddressCacheUtilCommons.getIpFromInetAddress;
import static com.alibaba.dcm.internal.InetAddressCacheUtilCommons.toInetAddressArray;

/**
* Util class to manipulate dns cache for old {@code JDK 8-}.
Expand All @@ -38,8 +38,6 @@
* @see InetAddress#cacheInitIfNeeded()
* @see InetAddress#cacheAddresses(String, InetAddress[], boolean)
*/
@ParametersAreNonnullByDefault
@ReturnValuesAreNonnullByDefault
@ApiStatus.Internal
@SuppressWarnings("JavadocReference")
public final class InetAddressCacheUtilForOld {
Expand Down
9 changes: 9 additions & 0 deletions library/src/main/java/com/alibaba/dcm/package-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,13 @@
* @author Jerry Lee (oldratlee at gmail dot com)
* @see com.alibaba.dcm.DnsCacheManipulator
*/
@DefaultAnnotation(NonNull.class)
@ParametersAreNonnullByDefault
@ReturnValuesAreNonnullByDefault
package com.alibaba.dcm;

import edu.umd.cs.findbugs.annotations.DefaultAnnotation;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.ReturnValuesAreNonnullByDefault;

import javax.annotation.ParametersAreNonnullByDefault;

0 comments on commit e617026

Please sign in to comment.