Skip to content

Commit 697d360

Browse files
Merge pull request #333 from AxonFramework/feature/fix-version-npe
Fix NPE in version check
2 parents 91a41ab + fef0c60 commit 697d360

File tree

5 files changed

+31
-18
lines changed

5 files changed

+31
-18
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
# Axon Framework plugin Changelog
44

5+
## [0.9.4]
6+
- Fix NPE in version check when using a malformed version string for an Axon dependency
7+
58
## [0.9.3]
69
- Remove build-until from plugin.xml, as we generally stay compatible with IDEA
710

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ dependencies {
141141
intellijIdeaCommunity(properties("platformVersion"))
142142
bundledPlugin("com.intellij.java")
143143
bundledPlugin("org.jetbrains.kotlin")
144-
pluginVerifier()
144+
pluginVerifier(version="1.383")
145145
zipSigner()
146146
instrumentationTools()
147147

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# Basic plugin information
1919
pluginGroup=io.axoniq.ide.intellij
2020
pluginName=Axon Framework
21-
pluginVersion=0.9.3
21+
pluginVersion=0.9.4
2222
axonVersion=4.10.1
2323
javaVersion = 17
2424

src/main/kotlin/org/axonframework/intellij/ide/plugin/actions/ReportFeedbackAction.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

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

19+
import com.intellij.openapi.actionSystem.ActionUpdateThread
1920
import com.intellij.openapi.actionSystem.AnAction
2021
import com.intellij.openapi.actionSystem.AnActionEvent
2122
import com.intellij.openapi.application.ApplicationManager
@@ -47,4 +48,8 @@ class ReportFeedbackAction : AnAction(AxonIcons.Axon) {
4748
service.reportFeedback(e.project, feedback)
4849
}
4950
}
51+
52+
override fun getActionUpdateThread(): ActionUpdateThread {
53+
return ActionUpdateThread.BGT
54+
}
5055
}

src/main/kotlin/org/axonframework/intellij/ide/plugin/usage/AxonVersionService.kt

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -156,24 +156,29 @@ class AxonVersionService(val project: Project) {
156156
}
157157

158158
private fun extractVersion(properties: Properties): AxonDependencyVersion? {
159-
val groupId = properties.getProperty("groupId")
160-
val artifactId = properties.getProperty("artifactId")
161-
val version = properties.getProperty("version")
162-
if(groupId.isNullOrEmpty() || artifactId.isNullOrEmpty() || version.isNullOrEmpty()) {
163-
return null
164-
}
165-
val dependency = AxonDependency.entries.firstOrNull { it.groupId == groupId && it.artifactId == artifactId }
166-
if(dependency == null) {
159+
try {
160+
val groupId = properties.getProperty("groupId")
161+
val artifactId = properties.getProperty("artifactId")
162+
val version = properties.getProperty("version")
163+
if (groupId.isNullOrEmpty() || artifactId.isNullOrEmpty() || version.isNullOrEmpty()) {
164+
return null
165+
}
166+
val dependency = AxonDependency.entries.firstOrNull { it.groupId == groupId && it.artifactId == artifactId }
167+
if (dependency == null) {
168+
return null
169+
}
170+
val (majorVersion, minorVersion, patchVersion, remaining) = versionRegex.find(version)?.destructured ?: return null
171+
return AxonDependencyVersion(
172+
dependency,
173+
Integer.parseInt(majorVersion),
174+
Integer.parseInt(minorVersion),
175+
Integer.parseInt(patchVersion),
176+
remaining
177+
)
178+
} catch (e: Exception) {
179+
// Ignore
167180
return null
168181
}
169-
val (majorVersion, minorVersion, patchVersion, remaining) = versionRegex.find(version)!!.destructured
170-
return AxonDependencyVersion(
171-
dependency,
172-
Integer.parseInt(majorVersion),
173-
Integer.parseInt(minorVersion),
174-
Integer.parseInt(patchVersion),
175-
remaining
176-
)
177182
}
178183

179184
data class AxonDependencyVersion(

0 commit comments

Comments
 (0)