33import com .alibaba .dcm .internal .InetAddressCacheUtilCommons ;
44import com .alibaba .dcm .internal .InetAddressCacheUtilForJava8Minus ;
55import com .alibaba .dcm .internal .InetAddressCacheUtilForJava9Plus ;
6+ import edu .umd .cs .findbugs .annotations .ReturnValuesAreNonnullByDefault ;
67import sun .net .InetAddressCachePolicy ;
78
8- import javax .annotation .Nonnull ;
99import javax .annotation .Nullable ;
10+ import javax .annotation .ParametersAreNonnullByDefault ;
1011import java .io .InputStream ;
1112import java .util .Arrays ;
1213import java .util .List ;
2829 * @see DnsCacheEntry
2930 * @see DnsCacheManipulatorException
3031 */
32+ @ ParametersAreNonnullByDefault
33+ @ ReturnValuesAreNonnullByDefault
3134public class DnsCacheManipulator {
3235 /**
3336 * Set a <b>never expired</b> dns cache entry.
@@ -37,7 +40,7 @@ public class DnsCacheManipulator {
3740 * @throws DnsCacheManipulatorException Operation fail
3841 * @see DnsCacheManipulator#setDnsCache(long, java.lang.String, java.lang.String...)
3942 */
40- public static void setDnsCache (@ Nonnull String host , @ Nonnull String ... ips ) {
43+ public static void setDnsCache (String host , String ... ips ) {
4144 try {
4245 if (isJdkAtMost8 ()) {
4346 InetAddressCacheUtilForJava8Minus .setInetAddressCache (host , ips , NEVER_EXPIRATION );
@@ -59,7 +62,7 @@ public static void setDnsCache(@Nonnull String host, @Nonnull String... ips) {
5962 * @param ips ips
6063 * @throws DnsCacheManipulatorException Operation fail
6164 */
62- public static void setDnsCache (long expireMillis , @ Nonnull String host , @ Nonnull String ... ips ) {
65+ public static void setDnsCache (long expireMillis , String host , String ... ips ) {
6366 try {
6467 if (isJdkAtMost8 ()) {
6568 InetAddressCacheUtilForJava8Minus .setInetAddressCache (host , ips , expireMillis );
@@ -84,7 +87,7 @@ public static void setDnsCache(long expireMillis, @Nonnull String host, @Nonnull
8487 * {@code www.example.com=42.42.42.42,43.43.43.43}
8588 * @throws DnsCacheManipulatorException Operation fail
8689 */
87- public static void setDnsCache (@ Nonnull Properties properties ) {
90+ public static void setDnsCache (Properties properties ) {
8891 for (Map .Entry <Object , Object > entry : properties .entrySet ()) {
8992 final String host = (String ) entry .getKey ();
9093 String ipList = (String ) entry .getValue ();
@@ -119,7 +122,7 @@ public static void loadDnsCacheConfig() {
119122 * @throws DnsCacheManipulatorException Operation fail
120123 * @see DnsCacheManipulator#setDnsCache(java.util.Properties)
121124 */
122- public static void loadDnsCacheConfig (@ Nonnull String propertiesFileName ) {
125+ public static void loadDnsCacheConfig (String propertiesFileName ) {
123126 InputStream inputStream = Thread .currentThread ().getContextClassLoader ().getResourceAsStream (propertiesFileName );
124127 if (inputStream == null ) {
125128 inputStream = DnsCacheManipulator .class .getClassLoader ().getResourceAsStream (propertiesFileName );
@@ -147,7 +150,7 @@ public static void loadDnsCacheConfig(@Nonnull String propertiesFileName) {
147150 * @throws DnsCacheManipulatorException Operation fail
148151 */
149152 @ Nullable
150- public static DnsCacheEntry getDnsCache (@ Nonnull String host ) {
153+ public static DnsCacheEntry getDnsCache (String host ) {
151154 try {
152155 if (isJdkAtMost8 ()) {
153156 return InetAddressCacheUtilForJava8Minus .getInetAddressCache (host );
@@ -169,7 +172,6 @@ public static DnsCacheEntry getDnsCache(@Nonnull String host) {
169172 * @see #listDnsCache()
170173 * @since 1.2.0
171174 */
172- @ Nonnull
173175 public static DnsCache getWholeDnsCache () {
174176 try {
175177 if (isJdkAtMost8 ()) {
@@ -192,7 +194,6 @@ public static DnsCache getWholeDnsCache() {
192194 * @see #getWholeDnsCache()
193195 * @since 1.2.0
194196 */
195- @ Nonnull
196197 public static List <DnsCacheEntry > listDnsCache () {
197198 return getWholeDnsCache ().getCache ();
198199 }
@@ -205,7 +206,6 @@ public static List<DnsCacheEntry> listDnsCache() {
205206 * @deprecated this method name is confused: method name is "all" but without negative cache.
206207 * use {@link #listDnsCache} instead.
207208 */
208- @ Nonnull
209209 @ Deprecated
210210 public static List <DnsCacheEntry > getAllDnsCache () {
211211 return listDnsCache ();
@@ -221,7 +221,6 @@ public static List<DnsCacheEntry> getAllDnsCache() {
221221 * @see #getWholeDnsCache()
222222 * @since 1.6.0
223223 */
224- @ Nonnull
225224 public static List <DnsCacheEntry > listDnsNegativeCache () {
226225 return getWholeDnsCache ().getNegativeCache ();
227226 }
@@ -233,7 +232,7 @@ public static List<DnsCacheEntry> listDnsNegativeCache() {
233232 * @throws DnsCacheManipulatorException Operation fail
234233 * @see DnsCacheManipulator#clearDnsCache
235234 */
236- public static void removeDnsCache (@ Nonnull String host ) {
235+ public static void removeDnsCache (String host ) {
237236 try {
238237 if (isJdkAtMost8 ()) {
239238 InetAddressCacheUtilForJava8Minus .removeInetAddressCache (host );
0 commit comments