How can I utilize `JBCefCookieManager` in version 2023.2 (232.8660.185) and beyond?

Answered

Hi there,

I'm currently developing and maintaining a plugin that utilizes JCEF and its cookie functionalities. In my code, I have the following line:

JBCefCookieManager jbCefCookieManager = new JBCefCookieManager();

However, after upgrading to IDEA version 232.8660.185, I encountered an error when starting the plugin:

Caused by: java.lang.IllegalArgumentException: Argument for @NotNull parameter 'cefCookieManager' of com/intellij/ui/jcef/JBCefCookieManager.<init> must not be null
   at com.intellij.ui.jcef.JBCefCookieManager.$$$reportNull$$$0(JBCefCookieManager.java)
   at com.intellij.ui.jcef.JBCefCookieManager.<init>(JBCefCookieManager.java)
   at com.intellij.ui.jcef.JBCefCookieManager.<init>(JBCefCookieManager.java:57)
   at com.lilittlecat.chatgpt.window.ChatGPTToolWindow.setCookieForOfficialWebsite(ChatGPTToolWindow.java:141)
   at com.lilittlecat.chatgpt.window.ChatGPTToolWindow.<init>(ChatGPTToolWindow.java:98)
   at com.lilittlecat.chatgpt.window.ChatGPTToolWindowFactory.createToolWindowContent(ChatGPTToolWindowFactory.java:29)
   at com.intellij.openapi.wm.impl.ToolWindowImpl.createContentIfNeeded(ToolWindowImpl.kt:554)
Caused by: java.lang.IllegalArgumentException: Argument for @NotNull parameter 'cefCookieManager' of com/intellij/ui/jcef/JBCefCookieManager.<init> must not be null
   at com.intellij.openapi.wm.impl.ToolWindowImpl.scheduleContentInitializationIfNeeded$intellij_platform_ide_impl(ToolWindowImpl.kt:533)
   at com.intellij.openapi.wm.impl.ToolWindowManagerImpl.doShowWindow(ToolWindowManagerImpl.kt:1013)
   at com.intellij.openapi.wm.impl.ToolWindowManagerImpl.showToolWindowImpl(ToolWindowManagerImpl.kt:950)
   at com.intellij.openapi.wm.impl.ToolWindowManagerImpl.showToolWindowImpl$default(ToolWindowManagerImpl.kt:936)
   at com.intellij.openapi.wm.impl.ToolWindowManagerImpl.registerToolWindow$intellij_platform_ide_impl(ToolWindowManagerImpl.kt:1120)
   at com.intellij.toolWindow.ToolWindowSetInitializerKt.registerToolWindows(ToolWindowSetInitializer.kt:181)
   ... 43 more

I investigated the constructor method of JBCefCookieManager and found that the @NotNull parameter is being passed from a static method:

public JBCefCookieManager() {
    this(CefCookieManager.getGlobalManager());
}

The static method is as follows:

public static final CefCookieManager getGlobalManager() {
    return CefCookieManager_N.getGlobalManagerNative();
}

The real method that gets called is:

private final static native CefCookieManager_N N_GetGlobalManager();

This method used to return a non-null object in versions prior to 2023.1. Since it's a native method, I'm not sure what's happening inside it in versions 2023.2 and later.

Could you provide me with some information regarding this issue?

Thank you very much.

0
3 comments

Please see https://youtrack.jetbrains.com/issue/JBR-5674 , it is fixed in 2023.3 release (included in latest JBR builds with version >= 1087.1).

0

Thank you for your response, but when I access this link, it prompts me that it is not found or I don't have permission.

0

It contains internal information from crash reports, and thus is not public, sorry.

0

Please sign in to leave a comment.