Skip to content

Commit

Permalink
Remove JSR305 nullness annotations (Adobe-Consulting-Services#3268)
Browse files Browse the repository at this point in the history
Migrate to Jetbrains annotations
This closes Adobe-Consulting-Services#3267
  • Loading branch information
kwin authored Mar 1, 2024
1 parent 05c6196 commit 3e3d5e4
Show file tree
Hide file tree
Showing 40 changed files with 256 additions and 284 deletions.
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@ The format is based on [Keep a Changelog](http://keepachangelog.com)

## Unreleased ([details][unreleased changes details])

### Fix
### Changed

- #3267 - Remove JSR305 dependency

### Fixed

- Re-enable accidentally disabled unit tests
- #3270 - Re-enable accidentally disabled JUnit3/4 tests

## 6.4.0 - 2024-02-22

Expand Down
6 changes: 0 additions & 6 deletions bundle-cloud/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,6 @@ Fragment-Host: com.adobe.acs.acs-aem-commons-bundle
</build>

<dependencies>
<!-- annotations -->
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<scope>provided</scope><!-- should not transitively be exposed -->
</dependency>
<dependency>
<groupId>com.adobe.acs</groupId>
<artifactId>acs-aem-commons-bundle</artifactId>
Expand Down
5 changes: 0 additions & 5 deletions bundle/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -285,11 +285,6 @@
<artifactId>org.apache.sling.servlets.annotations</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import java.io.IOException;
import java.util.Collections;

import javax.annotation.Nonnull;
import javax.servlet.Servlet;

import org.apache.commons.lang3.StringUtils;
Expand All @@ -33,6 +32,7 @@
import org.apache.sling.api.servlets.SlingAllMethodsServlet;
import org.apache.sling.jcr.resource.api.JcrResourceConstants;
import org.apache.sling.servlets.post.HtmlResponse;
import org.jetbrains.annotations.NotNull;
import org.osgi.service.component.annotations.Component;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -50,7 +50,7 @@ public class CreateCloudConfigServlet extends SlingAllMethodsServlet {
private static final Logger log = LoggerFactory.getLogger(CreateCloudConfigServlet.class);

@Override
protected void doPost(@Nonnull SlingHttpServletRequest request, @Nonnull SlingHttpServletResponse response)
protected void doPost(@NotNull SlingHttpServletRequest request, @NotNull SlingHttpServletResponse response)
throws IOException {
ResourceResolver resolver = request.getResourceResolver();
PageManager pageManager = resolver.adaptTo(PageManager.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@
*/
package com.adobe.acs.commons.dam.impl;

import com.adobe.acs.commons.util.ParameterUtil;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import java.io.IOException;
import java.util.Map;

import javax.servlet.ServletException;

import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.ConfigurationPolicy;
Expand All @@ -29,11 +31,11 @@
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.servlets.SlingSafeMethodsServlet;
import org.apache.sling.commons.osgi.PropertiesUtil;
import org.jetbrains.annotations.NotNull;

import javax.annotation.Nonnull;
import javax.servlet.ServletException;
import java.io.IOException;
import java.util.Map;
import com.adobe.acs.commons.util.ParameterUtil;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;

@SlingServlet(paths = "/bin/acs-commons/dam/custom-components.json", generateComponent = false)
@Component(metatype = true, policy = ConfigurationPolicy.REQUIRE, label = "ACS AEM Commons - Custom DAM Component List Servlet",
Expand Down Expand Up @@ -72,7 +74,7 @@ protected void activate(Map<String, Object> config) {
}

@Override
protected void doGet(@Nonnull SlingHttpServletRequest request, @Nonnull SlingHttpServletResponse response) throws ServletException, IOException {
protected void doGet(@NotNull SlingHttpServletRequest request, @NotNull SlingHttpServletResponse response) throws ServletException, IOException {
response.setContentType("application/json");
response.setCharacterEncoding("UTF-8");
response.getWriter().print(json.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,22 @@
*/
package com.adobe.acs.commons.genericlists;

import com.adobe.acs.commons.mcp.form.FormField;
import com.adobe.acs.commons.mcp.form.MultifieldComponent;
import java.util.List;
import java.util.Locale;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;

import javax.inject.Inject;
import javax.inject.Named;

import org.apache.sling.api.resource.Resource;
import org.apache.sling.models.annotations.DefaultInjectionStrategy;
import org.apache.sling.models.annotations.Model;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.osgi.annotation.versioning.ProviderType;

import com.adobe.acs.commons.mcp.form.FormField;
import com.adobe.acs.commons.mcp.form.MultifieldComponent;

/**
* A generic list of title/value pairs.
*/
Expand All @@ -42,7 +45,7 @@ public interface GenericList {
*
* @return the item list
*/
@Nonnull
@NotNull
@Inject
@Named("list")
@FormField(name = "List", component = MultifieldComponent.class)
Expand All @@ -54,7 +57,7 @@ public interface GenericList {
* @param value the list item's value
* @return the title or null
*/
@CheckForNull
@Nullable
String lookupTitle(String value);

/**
Expand All @@ -64,7 +67,7 @@ public interface GenericList {
* @param locale the locale for localization
* @return the title or null
*/
@CheckForNull
@Nullable
String lookupTitle(String value, Locale locale);

/**
Expand All @@ -79,7 +82,7 @@ interface Item {
*
* @return the title
*/
@Nonnull
@NotNull
@Inject
@Named("jcr:title")
@FormField(name = "Title", localize = true)
Expand All @@ -92,15 +95,15 @@ interface Item {
*
* @return the title
*/
@Nonnull
@NotNull
String getTitle(Locale locale);

/**
* Get the item's value.
*
* @return the value
*/
@Nonnull
@NotNull
@Inject
@Named("value")
@FormField(name = "Value")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@
*/
package com.adobe.acs.commons.genericlists.impl;

import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;

import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Properties;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.api.adapter.AdapterFactory;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import com.adobe.acs.commons.genericlists.GenericList;
import com.day.cq.wcm.api.Page;
Expand All @@ -37,14 +36,14 @@ public class GenericListAdapterFactory implements AdapterFactory {

@SuppressWarnings("unchecked")
@Override
public final <AdapterType> AdapterType getAdapter(@CheckForNull Object obj, @Nonnull Class<AdapterType> clazz) {
public final <AdapterType> AdapterType getAdapter(@Nullable Object obj, @NotNull Class<AdapterType> clazz) {
if (clazz == GenericList.class) {
return (AdapterType) adaptToGenericList(obj);
}
return null;
}

private GenericList adaptToGenericList(@CheckForNull Object obj) {
private GenericList adaptToGenericList(@Nullable Object obj) {
if (obj == null) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@

import java.util.Map;

import javax.annotation.Nonnull;

import org.apache.sling.api.SlingHttpServletRequest;
import org.jetbrains.annotations.NotNull;
import org.osgi.annotation.versioning.ConsumerType;

import com.adobe.granite.ui.components.ExpressionCustomizer;
Expand All @@ -44,5 +43,5 @@ public interface ELVariableProvider {
* The name must not contain {@code .}
* Must never be {@code null}, but can be the empty map if no variable is provided.
*/
@Nonnull Map<String, Object> getVariables(SlingHttpServletRequest request);
@NotNull Map<String, Object> getVariables(SlingHttpServletRequest request);
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,31 @@
*/
package com.adobe.acs.commons.granite.ui.components.impl.include;

import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.function.Predicate;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

import org.apache.commons.collections.MapUtils;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ValueMap;
import org.apache.sling.engine.EngineConstants;
import org.jetbrains.annotations.Nullable;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.ConfigurationPolicy;
import org.osgi.service.component.annotations.Modified;
import org.osgi.service.metatype.annotations.Designate;
import org.osgi.service.metatype.annotations.ObjectClassDefinition;

import javax.annotation.CheckForNull;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;


import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.function.Predicate;

@Component(
service = Filter.class,
configurationPolicy = ConfigurationPolicy.OPTIONAL,
Expand Down Expand Up @@ -132,7 +131,7 @@ public void doFilter(ServletRequest servletRequest, ServletResponse servletRespo
}

private void performFilter(SlingHttpServletRequest request, ServletResponse servletResponse, FilterChain chain, ValueMap parameters) throws IOException, ServletException {
@CheckForNull Resource parameterResource = request.getResource().getChild(NN_PARAMETERS);
@Nullable Resource parameterResource = request.getResource().getChild(NN_PARAMETERS);
if(parameterResource != null){
parameters = parameterResource.getValueMap();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@
*/
package com.adobe.acs.commons.granite.ui.components.impl.include;

import com.adobe.granite.ui.components.ExpressionResolver;
import com.adobe.granite.ui.components.FilteringResourceWrapper;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Optional;

import org.apache.commons.collections.iterators.FilterIterator;
import org.apache.commons.collections.iterators.TransformIterator;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceUtil;
import org.apache.sling.api.resource.ValueMap;
import org.jetbrains.annotations.NotNull;

import javax.annotation.Nonnull;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Optional;
import com.adobe.granite.ui.components.ExpressionResolver;
import com.adobe.granite.ui.components.FilteringResourceWrapper;


public class NamespaceResourceWrapper extends FilteringResourceWrapper {
Expand All @@ -41,8 +41,8 @@ public class NamespaceResourceWrapper extends FilteringResourceWrapper {

private final ValueMap valueMap;

public NamespaceResourceWrapper(@Nonnull Resource resource, @Nonnull ExpressionResolver expressionResolver,
@Nonnull SlingHttpServletRequest request,
public NamespaceResourceWrapper(@NotNull Resource resource, @NotNull ExpressionResolver expressionResolver,
@NotNull SlingHttpServletRequest request,
String[] namespacedProperties) {
super(resource, expressionResolver, request);
this.expressionResolver = expressionResolver;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@
import java.io.IOException;
import java.util.List;

import javax.annotation.Nonnull;

import org.apache.http.impl.client.CloseableHttpClient;
import org.jetbrains.annotations.NotNull;

import com.adobe.acs.commons.marketo.MarketoClientConfiguration;

Expand All @@ -38,14 +37,14 @@ public interface MarketoClient {
* @return a valid Marketo API Token
* @throws IOException an error occurs retrieving the token
*/
public @Nonnull String getApiToken(@Nonnull MarketoClientConfiguration config) throws MarketoApiException;
public @NotNull String getApiToken(@NotNull MarketoClientConfiguration config) throws MarketoApiException;

/**
* Retrieve a HttpClient for interacting with the Marketo API
*
* @return the httpclient
*/
public @Nonnull CloseableHttpClient getHttpClient();
public @NotNull CloseableHttpClient getHttpClient();

/**
* Retrieve all of the available forms from the current organization in Marketo.
Expand All @@ -54,7 +53,7 @@ public interface MarketoClient {
* @return the full list of available forms
* @throws IOException an exception occurs interacting with the API
*/
public @Nonnull List<MarketoForm> getForms(@Nonnull MarketoClientConfiguration config) throws MarketoApiException;
public @NotNull List<MarketoForm> getForms(@NotNull MarketoClientConfiguration config) throws MarketoApiException;

/**
* Retrieve all of the available forms from the current organization in Marketo.
Expand All @@ -63,6 +62,6 @@ public interface MarketoClient {
* @return the full list of available forms
* @throws IOException an exception occurs interacting with the API
*/
public @Nonnull List<MarketoField> getFields(@Nonnull MarketoClientConfiguration config) throws MarketoApiException;
public @NotNull List<MarketoField> getFields(@NotNull MarketoClientConfiguration config) throws MarketoApiException;

}
Loading

0 comments on commit 3e3d5e4

Please sign in to comment.