Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception on 2024.2 EAP platform: call '#setLevel(LogLevel)' instead #283

Open
juherr opened this issue May 17, 2024 · 10 comments
Open

Exception on 2024.2 EAP platform: call '#setLevel(LogLevel)' instead #283

juherr opened this issue May 17, 2024 · 10 comments
Labels

Comments

@juherr
Copy link

juherr commented May 17, 2024

On 2024.2 EAP platform:

java.lang.Throwable: Do not use, call '#setLevel(LogLevel)' instead
	at com.intellij.openapi.diagnostic.Logger.error(Logger.java:376)
	at com.intellij.openapi.diagnostic.Logger.setLevel(Logger.java:484)
	at com.wakatime.intellij.plugin.WakaTime.setLoggingLevel(WakaTime.java:585)
	at com.wakatime.intellij.plugin.WakaTime.initComponent(WakaTime.java:96)
	at com.intellij.serviceContainer.ComponentInstanceInitializer.createInstance$suspendImpl(ComponentInstanceInitializer.kt:27)
	at com.intellij.serviceContainer.ComponentInstanceInitializer.createInstance(ComponentInstanceInitializer.kt)
	at com.intellij.platform.instanceContainer.internal.LazyInstanceHolder$initialize$1$1.invokeSuspend(LazyInstanceHolder.kt:162)
	at com.intellij.platform.instanceContainer.internal.LazyInstanceHolder$initialize$1$1.invoke(LazyInstanceHolder.kt)
	at com.intellij.platform.instanceContainer.internal.LazyInstanceHolder$initialize$1$1.invoke(LazyInstanceHolder.kt)
	at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:61)
	at kotlinx.coroutines.BuildersKt__Builders_commonKt.withContext(Builders.common.kt:163)
	at kotlinx.coroutines.BuildersKt.withContext(Unknown Source)
	at com.intellij.platform.instanceContainer.internal.LazyInstanceHolder$initialize$1.invokeSuspend(LazyInstanceHolder.kt:160)
	at com.intellij.platform.instanceContainer.internal.LazyInstanceHolder$initialize$1.invoke(LazyInstanceHolder.kt)
	at com.intellij.platform.instanceContainer.internal.LazyInstanceHolder$initialize$1.invoke(LazyInstanceHolder.kt)
	at kotlinx.coroutines.intrinsics.UndispatchedKt.startCoroutineUndispatched(Undispatched.kt:27)
	at kotlinx.coroutines.CoroutineStart.invoke(CoroutineStart.kt:90)
	at kotlinx.coroutines.AbstractCoroutine.start(AbstractCoroutine.kt:123)
	at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch(Builders.common.kt:52)
	at kotlinx.coroutines.BuildersKt.launch(Unknown Source)
	at com.intellij.platform.instanceContainer.internal.LazyInstanceHolder.initialize(LazyInstanceHolder.kt:145)
	at com.intellij.platform.instanceContainer.internal.LazyInstanceHolder.access$initialize(LazyInstanceHolder.kt:13)
	at com.intellij.platform.instanceContainer.internal.LazyInstanceHolder.tryInitialize(LazyInstanceHolder.kt:135)
	at com.intellij.platform.instanceContainer.internal.LazyInstanceHolder.getInstance(LazyInstanceHolder.kt:95)
	at com.intellij.platform.instanceContainer.internal.LazyInstanceHolder.getInstanceInCallerContext$suspendImpl(LazyInstanceHolder.kt:87)
	at com.intellij.platform.instanceContainer.internal.LazyInstanceHolder.getInstanceInCallerContext(LazyInstanceHolder.kt)
	at com.intellij.platform.instanceContainer.internal.UtilKt.preloadAllInstances(util.kt:47)
	at com.intellij.serviceContainer.ComponentManagerImpl$createInitOldComponentsTask$1.invokeSuspend(ComponentManagerImpl.kt:475)
	at com.intellij.serviceContainer.ComponentManagerImpl$createInitOldComponentsTask$1.invoke(ComponentManagerImpl.kt)
	at com.intellij.serviceContainer.ComponentManagerImpl$createInitOldComponentsTask$1.invoke(ComponentManagerImpl.kt)
	at com.intellij.platform.ide.bootstrap.AppServicePreloadingKt$postAppRegistered$3$1.invokeSuspend(appServicePreloading.kt:145)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104)
	at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:781)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:728)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:722)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:87)
	at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:750)
	at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.kt:322)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:207)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
	at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:92)

From
https://github.com/wakatime/jetbrains-wakatime/blob/master/src/com/wakatime/intellij/plugin/WakaTime.java#L581-L586

@juherr juherr added the bug label May 17, 2024
@alanhamlett
Copy link
Member

We can't use the new logging without dropping support for older Jetbrains IDE versions. For now, ignoring the logging exception with f9b81ea, released in v14.3.14.

The long term solution is creating a new legacy plugin repo and marketplace listing for older IDEs, then upgrading the SDK used by this plugin to support the newer IDEs.

@OndrejSpanel
Copy link

I still get this exception reported even with 14.3.14:

java.lang.Throwable: Do not use, call '#setLevel(LogLevel)' instead
	at com.intellij.openapi.diagnostic.Logger.error(Logger.java:376)
	at com.intellij.openapi.diagnostic.Logger.setLevel(Logger.java:484)
	at com.wakatime.intellij.plugin.WakaTime.setLoggingLevel(WakaTime.java:586)
	at com.wakatime.intellij.plugin.WakaTime.initComponent(WakaTime.java:96)

image

@alanhamlett alanhamlett reopened this May 22, 2024
@alanhamlett
Copy link
Member

Fixed with 821a9d8.

@OndrejSpanel
Copy link

OndrejSpanel commented May 23, 2024

Your fix looks fine, but I am sorry to report the issue persists:

java.lang.Throwable: Do not use, call '#setLevel(LogLevel)' instead
at com.intellij.openapi.diagnostic.Logger.error(Logger.java:376)
at com.intellij.openapi.diagnostic.Logger.setLevel(Logger.java:484)
at com.wakatime.intellij.plugin.WakaTime.setLoggingLevel(WakaTime.java:586)
at com.wakatime.intellij.plugin.WakaTime.initComponent(WakaTime.java:96)

image

I do not know how exactly IDEA decides what to report as a crash report.

Are you sure you want to call System.out.println(e.getStackTrace()); on the catched exception? Or perhaps the exception stack is already dumped inside of log.setLevel and it cannot be supressed this way?

@llTheBlankll
Copy link
Contributor

It seems like #setLevel(Level) is deprecated as of this code from intellij openapi logger
image

  /** @deprecated IntelliJ Platform no longer uses Log4j as the logging framework; please use {@link #setLevel(LogLevel)} instead */
  @Deprecated
  public void setLevel(@SuppressWarnings("unused") @NotNull Level level) {
    error("Do not use, call '#setLevel(LogLevel)' instead");
  }

  public void setLevel(@NotNull LogLevel level) {
    error(getClass() + " should override '#setLevel(LogLevel)'");
  }

And LogLevel Enum contains the following code:

public enum LogLevel {
  OFF(Level.OFF),
  ERROR(Level.SEVERE),
  WARNING(Level.WARNING),
  INFO(Level.INFO),
  DEBUG(Level.FINE),
  TRACE(Level.FINER),
  ALL(Level.ALL);

  private final Level myLevel;

  LogLevel(Level level) {
    myLevel = level;
  }

  Level getLevel() {
    return myLevel;
  }

  public String getLevelName() {
    return myLevel.getName();
  }

  public @NotNull String getPrettyLevelName() {
    return getPrettyLevelName(myLevel);
  }

  static @NotNull String getPrettyLevelName(@NotNull Level level) {
    return level == Level.WARNING ? "WARN" : level.getName();
  }
}

Using LogLevel instead of Level should theoretically fix it right...?

@llTheBlankll
Copy link
Contributor

But Log4j2 uses Level, no idea of how to fix this yet...

llTheBlankll added a commit to llTheBlankll/jetbrains-wakatime that referenced this issue Jun 25, 2024
alanhamlett added a commit that referenced this issue Jun 25, 2024
@alanhamlett
Copy link
Member

The SDK we currently target doesn't know about com.intellij.openapi.diagnostic so we need to update the plugin SDK first.

@vorburger
Copy link

FYI still seeing this with WakaTime 15.0.1 on IntelliJ IDEA 2024.2 (Ultimate Edition) Build #IU-242.20224.300, built on August 6, 2024.

@CrazyBoy49z
Copy link

CrazyBoy49z commented Aug 13, 2024

PhpStorm-2024.2
WakaTime 15.0.1

java.lang.Throwable: Do not use, call '#setLevel(LogLevel)' instead
	at com.intellij.openapi.diagnostic.Logger.error(Logger.java:376)
	at com.intellij.openapi.diagnostic.Logger.setLevel(Logger.java:484)
	at com.wakatime.intellij.plugin.WakaTime.setLoggingLevel(WakaTime.java:594)
	at com.wakatime.intellij.plugin.WakaTime.initComponent(WakaTime.java:98)
	at com.intellij.serviceContainer.ComponentInstanceInitializer.createInstance$suspendImpl(ComponentInstanceInitializer.kt:27)
	at com.intellij.serviceContainer.ComponentInstanceInitializer.createInstance(ComponentInstanceInitializer.kt)
	at com.intellij.platform.instanceContainer.internal.LazyInstanceHolder$initialize$1$1.invokeSuspend(LazyInstanceHolder.kt:162)
	at com.intellij.platform.instanceContainer.internal.LazyInstanceHolder$initialize$1$1.invoke(LazyInstanceHolder.kt)
	at com.intellij.platform.instanceContainer.internal.LazyInstanceHolder$initialize$1$1.invoke(LazyInstanceHolder.kt)
	at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:62)
	at kotlinx.coroutines.BuildersKt__Builders_commonKt.withContext(Builders.common.kt:163)
	at kotlinx.coroutines.BuildersKt.withContext(Unknown Source)
	at com.intellij.platform.instanceContainer.internal.LazyInstanceHolder$initialize$1.invokeSuspend(LazyInstanceHolder.kt:160)
	at com.intellij.platform.instanceContainer.internal.LazyInstanceHolder$initialize$1.invoke(LazyInstanceHolder.kt)
	at com.intellij.platform.instanceContainer.internal.LazyInstanceHolder$initialize$1.invoke(LazyInstanceHolder.kt)
	at kotlinx.coroutines.intrinsics.UndispatchedKt.startCoroutineUndispatched(Undispatched.kt:27)
	at kotlinx.coroutines.CoroutineStart.invoke(CoroutineStart.kt:90)
	at kotlinx.coroutines.AbstractCoroutine.start(AbstractCoroutine.kt:123)
	at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch(Builders.common.kt:52)
	at kotlinx.coroutines.BuildersKt.launch(Unknown Source)
	at com.intellij.platform.instanceContainer.internal.LazyInstanceHolder.initialize(LazyInstanceHolder.kt:145)
	at com.intellij.platform.instanceContainer.internal.LazyInstanceHolder.access$initialize(LazyInstanceHolder.kt:13)
	at com.intellij.platform.instanceContainer.internal.LazyInstanceHolder.tryInitialize(LazyInstanceHolder.kt:135)
	at com.intellij.platform.instanceContainer.internal.LazyInstanceHolder.getInstance(LazyInstanceHolder.kt:95)
	at com.intellij.platform.instanceContainer.internal.LazyInstanceHolder.getInstanceInCallerContext$suspendImpl(LazyInstanceHolder.kt:87)
	at com.intellij.platform.instanceContainer.internal.LazyInstanceHolder.getInstanceInCallerContext(LazyInstanceHolder.kt)
	at com.intellij.platform.instanceContainer.internal.UtilKt.preloadAllInstances(util.kt:47)
	at com.intellij.serviceContainer.ComponentManagerImpl$createInitOldComponentsTask$1.invokeSuspend(ComponentManagerImpl.kt:478)
	at com.intellij.serviceContainer.ComponentManagerImpl$createInitOldComponentsTask$1.invoke(ComponentManagerImpl.kt)
	at com.intellij.serviceContainer.ComponentManagerImpl$createInitOldComponentsTask$1.invoke(ComponentManagerImpl.kt)
	at com.intellij.platform.ide.bootstrap.AppServicePreloadingKt$postAppRegistered$3$1.invokeSuspend(appServicePreloading.kt:140)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104)
	at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:781)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:728)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:722)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:87)
	at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:750)
	at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.kt:320)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:207)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
	at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:92)

@alanhamlett
Copy link
Member

The refactor was taking too long so I just released a fix in v15.0.2 that removes setLevel, since it was only used when debugging logs in idea.log and not necessary for the plugin to function normally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants