Skip to content

add the api usage check with de.thetaphi.forbiddenapis to #115#120

Merged
xiaowing merged 1 commit intoaliyun:masterfrom
xiaowing:master
Apr 22, 2021
Merged

add the api usage check with de.thetaphi.forbiddenapis to #115#120
xiaowing merged 1 commit intoaliyun:masterfrom
xiaowing:master

Conversation

@xiaowing
Copy link
Collaborator

add the plugin of de.thetaphi.forbiddenapis to prevent some unexpected api usages in future code contribution

@xiaowing xiaowing added build the changes for enhance the build of project enhancement labels Apr 22, 2021
@xiaowing xiaowing added this to the 0.3.6 milestone Apr 22, 2021
@xiaowing
Copy link
Collaborator Author

xiaowing commented Apr 22, 2021

it's very interesting to find that the travis-ci triggering a bug of de.thetaphi.forbiddenapis forbidden-api#178

this bug will cause the api check failed in the travis-ci platform reporting the java.util.Randorm usage, even if that not being declared as a forbidden one in the API black-list.

[ERROR] Forbidden method invocation: java.util.Random#() [Use ThreadLocalRandom.current() or the constructor with a seed (the latter in tests only!)]
[ERROR] in com.aliyun.hitsdb.client.error.TestHiTSDBClientBatchPutExceptionCallback (TestHiTSDBClientBatchPutExceptionCallback.java:81)
[ERROR] Forbidden method invocation: java.util.Random#() [Use ThreadLocalRandom.current() or the constructor with a seed (the latter in tests only!)]
[ERROR] in com.aliyun.hitsdb.client.error.TestHiTSDBClientBatchPutExceptionCallback (TestHiTSDBClientBatchPutExceptionCallback.java:97)
[ERROR] Forbidden method invocation: java.util.Random#() [Use ThreadLocalRandom.current() or the constructor with a seed (the latter in tests only!)]
......

since all the Randorm usage were all introduced in the test code, so currently we have to limit the execution of forbidden-api within the compile phase, like this

<executions>
    <execution>
        <id>compile</id>
	<phase>compile</phase>
	<goals>
	    <goal>check</goal>
	</goals>
	<configuration>
	    <bundledSignatures>
	        <!-- Check jdk-system-out only for production code, but not in test code -->
	        <!--<bundledSignature>jdk-unsafe</bundledSignature>-->
	        <!--<bundledSignature>jdk-system-out</bundledSignature>-->
	    </bundledSignatures>
	 </configuration>
    </execution>
    <!--
    <execution>
        <id>testCompile</id>
	<phase>test-compile</phase>
	<goals>
	    <goal>testCheck</goal>
	 </goals>
    </execution>
    -->
</executions>

As a result, the test-compile phase CANNOT be reopened until the release of de.thetaphi.forbiddenapis 3.2

@xiaowing xiaowing removed this from the 0.3.6 milestone Apr 22, 2021
@xiaowing xiaowing added this to the 0.3.6 milestone Apr 22, 2021
@xiaowing xiaowing merged commit 937e90a into aliyun:master Apr 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build the changes for enhance the build of project enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

it is necessary to introduce de.thetaphi.forbiddenapis plugin to prevent irregular API usage

1 participant