diff --git a/platform/platform-api/src/com/intellij/internal/statistic/eventLog/FeatureUsageUiEvents.kt b/platform/platform-api/src/com/intellij/internal/statistic/eventLog/FeatureUsageUiEvents.kt index f08f960ee386..6f789872c497 100644 --- a/platform/platform-api/src/com/intellij/internal/statistic/eventLog/FeatureUsageUiEvents.kt +++ b/platform/platform-api/src/com/intellij/internal/statistic/eventLog/FeatureUsageUiEvents.kt @@ -1,15 +1,15 @@ // Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.internal.statistic.eventLog +import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.components.ServiceManager fun getUiEventLogger(): FeatureUsageUiEvents { - return try { - ServiceManager.getService(FeatureUsageUiEvents::class.java) ?: EmptyFeatureUsageUiEvents - } - catch (e : Exception) { - EmptyFeatureUsageUiEvents + if (ApplicationManager.getApplication() != null) { + return ServiceManager.getService(FeatureUsageUiEvents::class.java) ?: EmptyFeatureUsageUiEvents } + // cannot load service if application is not initialized + return EmptyFeatureUsageUiEvents } interface FeatureUsageUiEvents {