Fix issue that the forbidden-apis check do not always work (#6371)

* Fix the forbidden apis check do not work issue

* use SuppressForbidden annotation
This commit is contained in:
QiuMM 2018-09-27 00:39:39 +08:00 committed by Roman Leventov
parent 8978d3751b
commit 6843cbba1d
7 changed files with 18 additions and 8 deletions

View File

@ -19,6 +19,7 @@
package org.apache.druid.java.util.common;
import io.netty.util.SuppressForbidden;
import org.joda.time.Chronology;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
@ -40,6 +41,7 @@ public final class DateTimes
ISODateTimeFormat.dateTimeParser().withOffsetParsed()
);
@SuppressForbidden(reason = "DateTimeZone#forID")
public static DateTimeZone inferTzfromString(String tzId)
{
try {
@ -65,6 +67,7 @@ public final class DateTimes
this.innerFormatter = innerFormatter.withChronology(ISOChronology.getInstanceUTC());
}
@SuppressForbidden(reason = "DateTimeFormatter#parseDateTime")
public DateTime parse(final String instant)
{
return innerFormatter.parseDateTime(instant);

13
pom.xml
View File

@ -931,15 +931,12 @@
<signaturesFile>${session.executionRootDirectory}/codestyle/joda-time-forbidden-apis.txt</signaturesFile>
<signaturesFile>${session.executionRootDirectory}/codestyle/druid-forbidden-apis.txt</signaturesFile>
</signaturesFiles>
<excludes>
<exclude>org/apache/druid/java/util/common/DateTimes$UtcFormatter.class</exclude>
<exclude>org/apache/druid/java/util/common/DateTimes.class</exclude>
</excludes>
<suppressAnnotations><annotation>**.SuppressForbidden</annotation></suppressAnnotations>
</configuration>
<executions>
<execution>
<id>validate</id>
<phase>validate</phase>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>check</goal>
</goals>
@ -952,8 +949,8 @@
</configuration>
</execution>
<execution>
<id>testValidate</id>
<phase>validate</phase>
<id>testCompile</id>
<phase>test-compile</phase>
<goals>
<goal>testCheck</goal>
</goals>

View File

@ -36,6 +36,7 @@ import com.google.inject.Module;
import com.google.inject.name.Names;
import io.airlift.airline.Command;
import io.airlift.airline.Option;
import io.netty.util.SuppressForbidden;
import org.apache.druid.collections.bitmap.BitmapFactory;
import org.apache.druid.collections.bitmap.ConciseBitmapFactory;
import org.apache.druid.collections.bitmap.ImmutableBitmap;
@ -417,6 +418,7 @@ public class DumpSegment extends GuiceRunnable
return ImmutableList.copyOf(columnNames);
}
@SuppressForbidden(reason = "System#out")
private <T> T withOutputStream(Function<OutputStream, T> f) throws IOException
{
if (outputFileName == null) {

View File

@ -23,6 +23,7 @@ import com.google.inject.Injector;
import io.airlift.airline.Cli;
import io.airlift.airline.Help;
import io.airlift.airline.ParseException;
import io.netty.util.SuppressForbidden;
import org.apache.druid.cli.validate.DruidJsonValidator;
import org.apache.druid.guice.ExtensionsConfig;
import org.apache.druid.guice.GuiceInjectors;
@ -45,6 +46,7 @@ public class Main
}
@SuppressWarnings("unchecked")
@SuppressForbidden(reason = "System#out")
public static void main(String[] args)
{
final Cli.CliBuilder<Runnable> builder = Cli.builder("druid");

View File

@ -27,6 +27,7 @@ import com.google.common.collect.Sets;
import com.google.inject.Inject;
import io.airlift.airline.Command;
import io.airlift.airline.Option;
import io.netty.util.SuppressForbidden;
import org.apache.druid.guice.ExtensionsConfig;
import org.apache.druid.indexing.common.config.TaskConfig;
import org.apache.druid.java.util.common.ISE;
@ -414,6 +415,7 @@ public class PullDependencies implements Runnable
log.info("Finish downloading extension [%s]", versionedArtifact);
}
@SuppressForbidden(reason = "System#out")
private DefaultTeslaAether getAetherClient()
{
/*

View File

@ -20,6 +20,7 @@
package org.apache.druid.cli;
import io.airlift.airline.Command;
import io.netty.util.SuppressForbidden;
import org.apache.druid.initialization.DruidModule;
import org.apache.druid.initialization.Initialization;
import org.apache.druid.server.StatusResource;
@ -31,6 +32,7 @@ import org.apache.druid.server.StatusResource;
public class Version implements Runnable
{
@Override
@SuppressForbidden(reason = "System#out")
public void run()
{
System.out.println(new StatusResource.Status(Initialization.getLoadedImplementations(DruidModule.class)));

View File

@ -32,6 +32,7 @@ import com.google.inject.Injector;
import com.google.inject.name.Names;
import io.airlift.airline.Command;
import io.airlift.airline.Option;
import io.netty.util.SuppressForbidden;
import org.apache.druid.cli.GuiceRunnable;
import org.apache.druid.data.input.InputRow;
import org.apache.druid.data.input.impl.StringInputRowParser;
@ -69,6 +70,7 @@ import java.util.List;
name = "validator",
description = "Validates that a given Druid JSON object is correctly formatted"
)
@SuppressForbidden(reason = "System#out")
public class DruidJsonValidator extends GuiceRunnable
{
private static final Logger LOG = new Logger(DruidJsonValidator.class);