Skip to content

Commit

Permalink
Handle case where resource sharing service is null
Browse files Browse the repository at this point in the history
Signed-off-by: Craig Perkins <[email protected]>
  • Loading branch information
cwperks committed Dec 30, 2024
1 parent e066f6a commit 1c51afd
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
import org.opensearch.security.sampleextension.resource.SampleResource;
import org.opensearch.security.sampleextension.resource.SampleResourceParser;
import org.opensearch.security.sampleextension.resource.SampleResourceSharingServiceProvider;
import org.opensearch.security.spi.DefaultResourceSharingService;
import org.opensearch.security.spi.Resource;
import org.opensearch.security.spi.ResourceParser;
import org.opensearch.security.spi.ResourceSharingExtension;
Expand Down Expand Up @@ -89,10 +88,6 @@ public Collection<Object> createComponents(
Supplier<RepositoriesService> repositoriesServiceSupplier
) {
this.client = client;
if (SampleResourceSharingServiceProvider.getInstance().get() == null) {
System.out.println("Using DefaultResourceSharingService");
SampleResourceSharingServiceProvider.getInstance().set(new DefaultResourceSharingService<>());
}
System.out.println(
"SampleResourceSharingServiceProvider.getInstance(): " + SampleResourceSharingServiceProvider.getInstance().get()
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.opensearch.index.query.MatchAllQueryBuilder;
import org.opensearch.search.SearchHit;
import org.opensearch.search.builder.SearchSourceBuilder;
import org.opensearch.security.spi.DefaultResourceSharingService;
import org.opensearch.security.spi.Resource;
import org.opensearch.security.spi.ResourceParser;
import org.opensearch.security.spi.ResourceSharingService;
Expand Down Expand Up @@ -61,7 +62,7 @@ public ListResourceTransportAction(
) {
super(actionName, transportService, actionFilters, ListResourceRequest::new);
this.client = client;
this.resourceSharingService = resourceSharingService;
this.resourceSharingService = resourceSharingService != null ? resourceSharingService : new DefaultResourceSharingService<>();
this.resourceIndex = resourceIndex;
this.xContentRegistry = xContentRegistry;
this.resourceParser = resourceParser;
Expand Down

0 comments on commit 1c51afd

Please sign in to comment.