From d86102e8a462a6acbacc27d66a3690dfeb9e8fd8 Mon Sep 17 00:00:00 2001 From: Jochen Schalanda Date: Tue, 13 Oct 2015 11:36:08 +0200 Subject: [PATCH] Add additional forbidden APIs --- config/forbidden-apis/signatures.txt | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/config/forbidden-apis/signatures.txt b/config/forbidden-apis/signatures.txt index ca9c9c62f4..a1d88f5944 100644 --- a/config/forbidden-apis/signatures.txt +++ b/config/forbidden-apis/signatures.txt @@ -7,13 +7,14 @@ java.util.concurrent.Executors#newSingleThreadExecutor() java.util.concurrent.Executors#newSingleThreadScheduledExecutor() java.util.concurrent.Executors#privilegedThreadFactory() -@defaultMessage Do not create a DateTime without an explicit time zone. +@defaultMessage Constructing a DateTime without a time zone is dangerous org.joda.time.DateTime#() org.joda.time.DateTime#(long) org.joda.time.DateTime#(int, int, int, int, int) org.joda.time.DateTime#(int, int, int, int, int, int) org.joda.time.DateTime#(int, int, int, int, int, int, int) org.joda.time.DateTime#now() +org.joda.time.DateTimeZone#getDefault() @defaultMessage Please do not try to stop the world java.lang.System#gc() @@ -68,4 +69,17 @@ com.google.common.collect.Iterators#emptyIterator() @ Use Collections.emptyItera java.io.ObjectOutputStream java.io.ObjectOutput java.io.ObjectInputStream -java.io.ObjectInput \ No newline at end of file +java.io.ObjectInput + +@defaultMessage avoid DNS lookups by accident: if you have a valid reason, then @SuppressWarnings with that reason so its completely clear +java.net.InetAddress#getHostName() +java.net.InetAddress#getCanonicalHostName() + +java.net.InetSocketAddress#getHostName() @ Use getHostString() instead, which avoids a DNS lookup + +@defaultMessage use NetworkAddress format/formatAddress to print IP or IP+ports +java.net.InetAddress#toString() +java.net.InetAddress#getHostAddress() +java.net.Inet4Address#getHostAddress() +java.net.Inet6Address#getHostAddress() +java.net.InetSocketAddress#toString() \ No newline at end of file