avoid NPE when trying to find file storage mgmt service

This commit is contained in:
Fredrik Teschke committed 2015-01-25 16:22:30 +01:00
1 parent 88a21efc5e
commit fdb38874bd
2 files changed
+7

No files matched your search

@@ -583,5 +583,8 @@ public interface RacingEventService extends TrackedRegattaRegistry, RegattaFetch
*/
FileStorageService getActiveFileStorageService() throws NoCorrespondingServiceRegisteredException;
/**
* @return {@code null} if no service can be found in the OSGi registry
*/
FileStorageManagementService getFileStorageManagementService();
}
@@ -3001,6 +3001,10 @@ public class RacingEventServiceImpl implements RacingEventService, ClearStateTes
public FileStorageManagementService getFileStorageManagementService() {
ServiceReference<FileStorageManagementService> ref = bundleContext
.getServiceReference(FileStorageManagementService.class);
if (ref == null) {
logger.warning("No file storage management service registered");
return null;
}
return bundleContext.getService(ref);
}
}