Skip to content

Commit

Permalink
KSP: Do not store default empty string annotation value (#10284)
Browse files Browse the repository at this point in the history
  • Loading branch information
dstepanov authored Dec 18, 2023
1 parent 1087107 commit 7423f83
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import io.micronaut.core.annotation.AnnotationClassValue
import io.micronaut.core.annotation.AnnotationUtil
import io.micronaut.core.annotation.AnnotationValue
import io.micronaut.core.util.ArrayUtils
import io.micronaut.core.util.clhm.ConcurrentLinkedHashMap
import io.micronaut.core.util.StringUtils
import io.micronaut.inject.annotation.AbstractAnnotationMetadataBuilder
import io.micronaut.inject.annotation.MutableAnnotationMetadata
import io.micronaut.inject.visitor.VisitorContext
Expand Down Expand Up @@ -400,7 +400,9 @@ internal class KotlinAnnotationMetadataBuilder(private val symbolProcessorEnviro
val argument = annotationType.mirror.defaultArguments.find { it.name == prop.simpleName }
if (argument?.value != null && argument.isDefault()) {
val value = argument.value!!
map[prop] = value
if (value !is String || !StringUtils.isEmpty(value)) {
map[prop] = value
}
}
}
map
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@ class Test
then:
defaults["num"] == 10
defaults["bool"] == false
defaults["value"] == null
defaults["intArray1"] == new int[] {}
defaults["intArray2"] == new int[] {1, 2, 3}
defaults["intArray3"] == null
Expand Down

0 comments on commit 7423f83

Please sign in to comment.