From a0fb854a568e2154ec7403d71bf04e8624278b64 Mon Sep 17 00:00:00 2001 From: Egor Ushakov Date: Thu, 13 Mar 2025 15:16:06 +0100 Subject: [PATCH] IDEA-368449 Modify NPE message in console for Java 30th anniversary - fixes for review IJ-CR-157699 (cherry picked from commit 7d4bedd084b8e0f4ea21f2d604f42303fdc08513) (cherry picked from commit cf7435633522f9d259608c07869f4fb56dbe41c3) GitOrigin-RevId: 3bb18fafc723bfe841fc5f3e28e96011f12ad153 --- .../execution/filters/JavaExceptionFilter.kt | 12 ++++++++++++ java/java-impl/src/META-INF/JavaPlugin.xml | 1 + platform/util/resources/misc/registry.properties | 3 --- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/java/execution/impl/src/com/intellij/execution/filters/JavaExceptionFilter.kt b/java/execution/impl/src/com/intellij/execution/filters/JavaExceptionFilter.kt index 104e47ea836f..df46dee89b73 100644 --- a/java/execution/impl/src/com/intellij/execution/filters/JavaExceptionFilter.kt +++ b/java/execution/impl/src/com/intellij/execution/filters/JavaExceptionFilter.kt @@ -6,19 +6,26 @@ import com.intellij.codeInsight.hints.presentation.PresentationRenderer import com.intellij.execution.filters.Filter.ResultItem import com.intellij.execution.impl.InlayProvider import com.intellij.icons.AllIcons +import com.intellij.ide.util.PropertiesComponent import com.intellij.openapi.editor.Editor import com.intellij.openapi.editor.EditorCustomElementRenderer import com.intellij.openapi.editor.Inlay import com.intellij.openapi.util.registry.Registry +import com.intellij.psi.CommonClassNames import com.intellij.psi.PsiClass import java.time.LocalDate +private const val JAVA_EXCEPTIONS_ANNIVERSARY_BANNER_SHOWN = "java.exceptions.anniversary.banner.shown" + class JavaExceptionFilter : JvmExceptionOccurrenceFilter { override fun applyFilter( exceptionClassName: String, classes: MutableList, exceptionStartOffset: Int, ): ResultItem? { + if (exceptionClassName != CommonClassNames.JAVA_LANG_NULL_POINTER_EXCEPTION) { + return null + } with(Registry.get("java.exceptions.anniversary.banner")) { if (isOptionEnabled("off")) { return null @@ -29,6 +36,11 @@ class JavaExceptionFilter : JvmExceptionOccurrenceFilter { if (LocalDate.now() !in startDate..endDate) { return null } + val counter = PropertiesComponent.getInstance().getInt(JAVA_EXCEPTIONS_ANNIVERSARY_BANNER_SHOWN, 0) + if (counter > 2) { + return null + } + PropertiesComponent.getInstance().setValue(JAVA_EXCEPTIONS_ANNIVERSARY_BANNER_SHOWN, counter + 1, 0) } } return CreateExceptionBreakpointResult(exceptionStartOffset, exceptionStartOffset + exceptionClassName.length) diff --git a/java/java-impl/src/META-INF/JavaPlugin.xml b/java/java-impl/src/META-INF/JavaPlugin.xml index b225c1c7b136..d923e511a03d 100644 --- a/java/java-impl/src/META-INF/JavaPlugin.xml +++ b/java/java-impl/src/META-INF/JavaPlugin.xml @@ -427,6 +427,7 @@ + diff --git a/platform/util/resources/misc/registry.properties b/platform/util/resources/misc/registry.properties index 63db04adf8d9..3974745f1e90 100644 --- a/platform/util/resources/misc/registry.properties +++ b/platform/util/resources/misc/registry.properties @@ -701,9 +701,6 @@ debugger.hotswap.floating.toolbar.description=Show a floating toolbar with a hot debugger.hotswap.show.ide.popup=false debugger.hotswap.show.ide.popup.description=Show hot swap successful notification as a popup, or regular notification otherwise -java.exceptions.anniversary.banner=[on*|off|force] -java.exceptions.anniversary.banner.description=Show the java anniversary banner in the console - index.run.configuration.jre=false index.run.configuration.jre.restartRequired=true index.run.configuration.jre.description=Index jre specified in run configuration for goto navigation etc.