Skip to content

Commit

Permalink
Animal Sniffer Custom Annotation
Browse files Browse the repository at this point in the history
Branch adding custom annotation and demonstration of functionality in Azure core class ReferenceManagerImpl.java
Potential workaround for Azure#36275
  • Loading branch information
jr1000000 committed Aug 8, 2023
1 parent 5028fea commit 036184b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.azure.core.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import static java.lang.annotation.RetentionPolicy.CLASS;
import java.lang.annotation.Target;

/**
* Annotation to annotate an Android api 26+ compatible method to be ignored by animal-sniffer.
**/

@Retention(CLASS)
@Target({ElementType.METHOD, ElementType.CONSTRUCTOR, ElementType.TYPE, ElementType.FIELD})
public @interface Android
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.azure.core.util.ReferenceManager;
import com.azure.core.util.logging.ClientLogger;
import com.azure.core.util.logging.LogLevel;
import com.azure.core.annotation.Android;

import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
Expand Down Expand Up @@ -85,6 +86,7 @@ public ReferenceManagerImpl() {
}

@Override
@Android
public void register(Object object, Runnable cleanupAction) {
Objects.requireNonNull(object, "'object' cannot be null.");
Objects.requireNonNull(cleanupAction, "'cleanupAction' cannot be null.");
Expand Down
1 change: 1 addition & 0 deletions sdk/parents/azure-client-sdk-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@
<goal>check</goal>
</goals>
<configuration>
<annotations>com.azure.core.annotation.Android</annotations>
<signature>
<groupId>com.toasttab.android</groupId>
<artifactId>gummy-bears-api-26</artifactId>
Expand Down

0 comments on commit 036184b

Please sign in to comment.