Skip to content

Fix NPE in version check #333

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

Merged
merged 3 commits into from
Apr 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

# Axon Framework plugin Changelog

## [0.9.4]
- Fix NPE in version check when using a malformed version string for an Axon dependency

## [0.9.3]
- Remove build-until from plugin.xml, as we generally stay compatible with IDEA

Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ dependencies {
intellijIdeaCommunity(properties("platformVersion"))
bundledPlugin("com.intellij.java")
bundledPlugin("org.jetbrains.kotlin")
pluginVerifier()
pluginVerifier(version="1.383")
zipSigner()
instrumentationTools()

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# Basic plugin information
pluginGroup=io.axoniq.ide.intellij
pluginName=Axon Framework
pluginVersion=0.9.3
pluginVersion=0.9.4
axonVersion=4.10.1
javaVersion = 17

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package org.axonframework.intellij.ide.plugin.actions

import com.intellij.openapi.actionSystem.ActionUpdateThread
import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.application.ApplicationManager
Expand Down Expand Up @@ -47,4 +48,8 @@ class ReportFeedbackAction : AnAction(AxonIcons.Axon) {
service.reportFeedback(e.project, feedback)
}
}

override fun getActionUpdateThread(): ActionUpdateThread {
return ActionUpdateThread.BGT
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -156,24 +156,29 @@ class AxonVersionService(val project: Project) {
}

private fun extractVersion(properties: Properties): AxonDependencyVersion? {
val groupId = properties.getProperty("groupId")
val artifactId = properties.getProperty("artifactId")
val version = properties.getProperty("version")
if(groupId.isNullOrEmpty() || artifactId.isNullOrEmpty() || version.isNullOrEmpty()) {
return null
}
val dependency = AxonDependency.entries.firstOrNull { it.groupId == groupId && it.artifactId == artifactId }
if(dependency == null) {
try {
val groupId = properties.getProperty("groupId")
val artifactId = properties.getProperty("artifactId")
val version = properties.getProperty("version")
if (groupId.isNullOrEmpty() || artifactId.isNullOrEmpty() || version.isNullOrEmpty()) {
return null
}
val dependency = AxonDependency.entries.firstOrNull { it.groupId == groupId && it.artifactId == artifactId }
if (dependency == null) {
return null
}
val (majorVersion, minorVersion, patchVersion, remaining) = versionRegex.find(version)?.destructured ?: return null
return AxonDependencyVersion(
dependency,
Integer.parseInt(majorVersion),
Integer.parseInt(minorVersion),
Integer.parseInt(patchVersion),
remaining
)
} catch (e: Exception) {
// Ignore
return null
}
val (majorVersion, minorVersion, patchVersion, remaining) = versionRegex.find(version)!!.destructured
return AxonDependencyVersion(
dependency,
Integer.parseInt(majorVersion),
Integer.parseInt(minorVersion),
Integer.parseInt(patchVersion),
remaining
)
}

data class AxonDependencyVersion(
Expand Down
Loading