SLING-7798 : Switch from JSR-305 annotations to Jetbrains Nullable/NotNull Annotations
diff --git a/pom.xml b/pom.xml
index 1d18f59..84e6ea9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -212,9 +212,9 @@
<!-- Findbugs annotations -->
<dependency>
- <groupId>com.google.code.findbugs</groupId>
- <artifactId>jsr305</artifactId>
- <version>3.0.0</version>
+ <groupId>org.jetbrains</groupId>
+ <artifactId>annotations</artifactId>
+ <version>16.0.2</version>
<scope>provided</scope>
</dependency>
diff --git a/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrProviderStateFactory.java b/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrProviderStateFactory.java
index 8767fa9..8cc6a55 100644
--- a/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrProviderStateFactory.java
+++ b/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrProviderStateFactory.java
@@ -24,9 +24,6 @@
import java.util.Map;
import java.util.concurrent.atomic.AtomicReference;
-import javax.annotation.CheckForNull;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
import javax.jcr.Credentials;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
@@ -41,6 +38,8 @@
import org.apache.sling.jcr.resource.api.JcrResourceConstants;
import org.apache.sling.jcr.resource.internal.HelperData;
import org.apache.sling.spi.resource.provider.ResourceProvider;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
@@ -71,8 +70,8 @@
/** Get the calling Bundle from auth info, fail if not provided
* @throws LoginException if no calling bundle info provided
*/
- @CheckForNull
- private Bundle extractCallingBundle(@Nonnull Map<String, Object> authenticationInfo) throws LoginException {
+ @Nullable
+ private Bundle extractCallingBundle(@NotNull Map<String, Object> authenticationInfo) throws LoginException {
final Object obj = authenticationInfo.get(ResourceProvider.AUTH_SERVICE_BUNDLE);
if(obj != null && !(obj instanceof Bundle)) {
throw new LoginException("Invalid calling bundle object in authentication info");
@@ -81,7 +80,7 @@
}
@SuppressWarnings("deprecation")
- JcrProviderState createProviderState(final @Nonnull Map<String, Object> authenticationInfo) throws LoginException {
+ JcrProviderState createProviderState(final @NotNull Map<String, Object> authenticationInfo) throws LoginException {
boolean isLoginAdministrative = Boolean.TRUE.equals(authenticationInfo.get(ResourceProvider.AUTH_ADMIN));
// check whether a session is provided in the authenticationInfo
@@ -140,9 +139,9 @@
}
private JcrProviderState createJcrProviderState(
- @Nonnull final Session session,
+ @NotNull final Session session,
final boolean logoutSession,
- @Nonnull final Map<String, Object> authenticationInfo,
+ @NotNull final Map<String, Object> authenticationInfo,
@Nullable final BundleContext ctx
) throws LoginException {
final Session impersonatedSession = handleImpersonation(session, authenticationInfo, logoutSession);
diff --git a/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProvider.java b/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProvider.java
index 0590435..4f69583 100644
--- a/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProvider.java
+++ b/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProvider.java
@@ -30,8 +30,8 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicReference;
-import javax.annotation.CheckForNull;
-import javax.annotation.Nonnull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.annotations.NotNull;
import javax.jcr.AccessDeniedException;
import javax.jcr.Item;
import javax.jcr.Node;
@@ -299,18 +299,18 @@
* authentication info in order to create a new resolver as needed.
*/
@Override
- @Nonnull public JcrProviderState authenticate(final @Nonnull Map<String, Object> authenticationInfo)
+ @NotNull public JcrProviderState authenticate(final @NotNull Map<String, Object> authenticationInfo)
throws LoginException {
return stateFactory.createProviderState(authenticationInfo);
}
@Override
- public void logout(final @Nonnull JcrProviderState state) {
+ public void logout(final @NotNull JcrProviderState state) {
state.logout();
}
@Override
- public boolean isLive(final @Nonnull ResolveContext<JcrProviderState> ctx) {
+ public boolean isLive(final @NotNull ResolveContext<JcrProviderState> ctx) {
return ctx.getProviderState().getSession().isLive();
}
@@ -349,7 +349,7 @@
}
@Override
- public @CheckForNull Resource getParent(final @Nonnull ResolveContext<JcrProviderState> ctx, final @Nonnull Resource child) {
+ public @Nullable Resource getParent(final @NotNull ResolveContext<JcrProviderState> ctx, final @NotNull Resource child) {
if (child instanceof JcrItemResource<?>) {
try {
String version = null;
@@ -380,7 +380,7 @@
}
@Override
- public Collection<String> getAttributeNames(final @Nonnull ResolveContext<JcrProviderState> ctx) {
+ public Collection<String> getAttributeNames(final @NotNull ResolveContext<JcrProviderState> ctx) {
final Set<String> names = new HashSet<String>();
final String[] sessionNames = ctx.getProviderState().getSession().getAttributeNames();
for(final String name : sessionNames) {
@@ -392,7 +392,7 @@
}
@Override
- public Object getAttribute(final @Nonnull ResolveContext<JcrProviderState> ctx, final @Nonnull String name) {
+ public Object getAttribute(final @NotNull ResolveContext<JcrProviderState> ctx, final @NotNull String name) {
if (isAttributeVisible(name)) {
if (ResourceResolverFactory.USER.equals(name)) {
return ctx.getProviderState().getSession().getUserID();
@@ -403,7 +403,7 @@
}
@Override
- public Resource create(final @Nonnull ResolveContext<JcrProviderState> ctx, final String path, final Map<String, Object> properties)
+ public Resource create(final @NotNull ResolveContext<JcrProviderState> ctx, final String path, final Map<String, Object> properties)
throws PersistenceException {
// check for node type
final Object nodeObj = (properties != null ? properties.get(NodeUtil.NODE_TYPE) : null);
@@ -482,7 +482,7 @@
}
@Override
- public void delete(final @Nonnull ResolveContext<JcrProviderState> ctx, final @Nonnull Resource resource)
+ public void delete(final @NotNull ResolveContext<JcrProviderState> ctx, final @NotNull Resource resource)
throws PersistenceException {
// try to adapt to Item
Item item = resource.adaptTo(Item.class);
@@ -502,7 +502,7 @@
}
@Override
- public void revert(final @Nonnull ResolveContext<JcrProviderState> ctx) {
+ public void revert(final @NotNull ResolveContext<JcrProviderState> ctx) {
try {
ctx.getProviderState().getSession().refresh(false);
} catch (final RepositoryException ignore) {
@@ -511,7 +511,7 @@
}
@Override
- public void commit(final @Nonnull ResolveContext<JcrProviderState> ctx)
+ public void commit(final @NotNull ResolveContext<JcrProviderState> ctx)
throws PersistenceException {
try {
ctx.getProviderState().getSession().save();
@@ -521,7 +521,7 @@
}
@Override
- public boolean hasChanges(final @Nonnull ResolveContext<JcrProviderState> ctx) {
+ public boolean hasChanges(final @NotNull ResolveContext<JcrProviderState> ctx) {
try {
return ctx.getProviderState().getSession().hasPendingChanges();
} catch (final RepositoryException ignore) {
@@ -531,7 +531,7 @@
}
@Override
- public void refresh(final @Nonnull ResolveContext<JcrProviderState> ctx) {
+ public void refresh(final @NotNull ResolveContext<JcrProviderState> ctx) {
try {
ctx.getProviderState().getSession().refresh(true);
} catch (final RepositoryException ignore) {
@@ -541,8 +541,8 @@
@SuppressWarnings("unchecked")
@Override
- public @CheckForNull <AdapterType> AdapterType adaptTo(final @Nonnull ResolveContext<JcrProviderState> ctx,
- final @Nonnull Class<AdapterType> type) {
+ public @Nullable <AdapterType> AdapterType adaptTo(final @NotNull ResolveContext<JcrProviderState> ctx,
+ final @NotNull Class<AdapterType> type) {
Session session = ctx.getProviderState().getSession();
if (type == Session.class) {
return (AdapterType) session;
@@ -567,14 +567,14 @@
}
@Override
- public boolean copy(final @Nonnull ResolveContext<JcrProviderState> ctx,
+ public boolean copy(final @NotNull ResolveContext<JcrProviderState> ctx,
final String srcAbsPath,
final String destAbsPath) throws PersistenceException {
return false;
}
@Override
- public boolean move(final @Nonnull ResolveContext<JcrProviderState> ctx,
+ public boolean move(final @NotNull ResolveContext<JcrProviderState> ctx,
final String srcAbsPath,
final String destAbsPath) throws PersistenceException {
final String srcNodePath = srcAbsPath;
@@ -588,7 +588,7 @@
}
@Override
- public @CheckForNull QueryLanguageProvider<JcrProviderState> getQueryLanguageProvider() {
+ public @Nullable QueryLanguageProvider<JcrProviderState> getQueryLanguageProvider() {
final ProviderContext ctx = this.getProviderContext();
if ( ctx != null ) {
return new BasicQueryLanguageProvider(ctx);