Skip to content

Commit 266a3a6

Browse files
authored
Merge pull request #42 from TrueNine/dev
πŸš€ [release] 0.0.32
2 parents 948d610 + 8d7e544 commit 266a3a6

File tree

8 files changed

+40
-37
lines changed

8 files changed

+40
-37
lines changed

β€Žbuild-logic/src/main/kotlin/buildlogic.java-conventions.gradle.ktsβ€Ž

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -77,34 +77,6 @@ afterEvaluate {
7777

7878
dependsOn(configurations.testRuntimeClasspath)
7979

80-
// Configure JVM args to suppress warnings
81-
jvmArgs(
82-
"-XX:+EnableDynamicAgentLoading",
83-
"-Djdk.instrument.traceUsage=false",
84-
"-Xshare:off",
85-
"--add-opens=java.base/sun.misc=ALL-UNNAMED",
86-
"--add-opens=java.base/java.lang=ALL-UNNAMED",
87-
"--add-opens=java.base/java.nio=ALL-UNNAMED",
88-
"--add-opens=java.base/jdk.internal.misc=ALL-UNNAMED",
89-
"--add-opens=java.base/java.lang.reflect=ALL-UNNAMED",
90-
"--add-opens=java.base/java.util=ALL-UNNAMED",
91-
"--enable-native-access=ALL-UNNAMED",
92-
"-Dio.netty.tryReflectionSetAccessible=true",
93-
"-Dio.netty.noUnsafe=false",
94-
"-Dnet.bytebuddy.experimental=true",
95-
"-Dnet.bytebuddy.dump=${System.getProperty("java.io.tmpdir")}",
96-
"--add-exports=java.base/sun.nio.ch=ALL-UNNAMED",
97-
"--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED",
98-
"--add-exports=java.base/sun.misc=ALL-UNNAMED"
99-
)
100-
101-
// Suppress specific warnings by redirecting stderr for test processes
102-
systemProperty("java.util.logging.config.file", "")
103-
systemProperty("sun.misc.unsafe.disableWarnings", "true")
104-
105-
// Redirect stderr to filter out ByteBuddy warnings
106-
environment("JAVA_TOOL_OPTIONS", "-XX:+EnableDynamicAgentLoading -Djdk.instrument.traceUsage=false")
107-
10880
// Configure test output to suppress warnings
10981
testLogging {
11082
showStandardStreams = false

β€Ždepend/depend-jackson/src/main/kotlin/io/github/truenine/composeserver/depend/jackson/autoconfig/JacksonAutoConfiguration.ktβ€Ž

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties
3030
import org.springframework.context.ApplicationContext
3131
import org.springframework.context.annotation.Bean
3232
import org.springframework.context.annotation.Configuration
33-
import org.springframework.context.annotation.Primary
3433
import org.springframework.context.annotation.Scope
3534
import org.springframework.core.Ordered
3635
import org.springframework.core.annotation.Order
@@ -73,9 +72,10 @@ class JacksonAutoConfiguration(private val jacksonProperties: JacksonProperties)
7372
return builder
7473
}
7574

76-
@Primary
7775
@Bean(name = [DEFAULT_OBJECT_MAPPER_BEAN_NAME])
78-
@ConditionalOnMissingBean(name = [DEFAULT_OBJECT_MAPPER_BEAN_NAME])
76+
@ConditionalOnMissingBean(value = [ObjectMapper::class])
77+
@org.springframework.context.annotation.Primary
78+
@org.springframework.beans.factory.annotation.Qualifier("primary")
7979
fun jacksonObjectMapper(builder: Jackson2ObjectMapperBuilder): ObjectMapper {
8080
log.debug("create jackson objectMapper, builder: {}", builder)
8181
return builder.createXmlMapper(false).build()
@@ -155,7 +155,8 @@ class JacksonAutoConfiguration(private val jacksonProperties: JacksonProperties)
155155

156156
@Order(Ordered.LOWEST_PRECEDENCE)
157157
@Bean(name = [NON_IGNORE_OBJECT_MAPPER_BEAN_NAME])
158-
fun nonIgnoreObjectMapper(mapper: ObjectMapper): ObjectMapper {
158+
@org.springframework.beans.factory.annotation.Qualifier("nonIgnoreObjectMapper")
159+
fun nonIgnoreObjectMapper(@org.springframework.beans.factory.annotation.Qualifier("primary") mapper: ObjectMapper): ObjectMapper {
159160
log.debug("register non-ignore objectMapper, defaultMapper = {}", mapper)
160161
return mapper.copy().apply {
161162
disable(SerializationFeature.FAIL_ON_EMPTY_BEANS)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
spring:
2+
output:
3+
ansi:
4+
enabled: always
5+
test:
6+
print-condition-evaluation-report: false

β€Žgradle/libs.versions.tomlβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ org-springframework-modulith = "2.0.0-M1"
5454
org-springframework-security = "6.5.3"
5555
org-testcontainers = "1.21.3"
5656
org-testng = "7.11.0"
57-
project = "0.0.31"
57+
project = "0.0.32"
5858

5959
[libraries]
6060
ch-qos-logback-logback-classic = { module = "ch.qos.logback:logback-classic", version.ref = "ch-qos-logback" }

β€Žintegrate-test/depend/jackson/build.gradle.ktsβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ dependencies {
88

99
testImplementation(projects.testtoolkit.testtoolkitSpringmvc)
1010
testImplementation(libs.org.springframework.boot.spring.boot.starter.web)
11+
testImplementation(libs.org.springframework.boot.spring.boot.starter.json)
1112
}

β€Žintegrate-test/depend/jackson/src/test/kotlin/itest/integrate/depend/jackson/NonInternalObjectMapperIntegrationTest.ktβ€Ž

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
package itest.integrate.depend.jackson
22

3+
import com.fasterxml.jackson.databind.ObjectMapper
34
import io.github.truenine.composeserver.depend.jackson.autoconfig.JacksonAutoConfiguration
45
import jakarta.annotation.Resource
5-
import org.springframework.boot.test.context.SpringBootTest
6-
import com.fasterxml.jackson.databind.ObjectMapper
76
import kotlin.test.BeforeTest
87
import kotlin.test.Test
98
import kotlin.test.assertNotNull
9+
import org.springframework.boot.test.context.SpringBootTest
1010

1111
@SpringBootTest
1212
class NonInternalObjectMapperIntegrationTest {
13-
@Resource(name = JacksonAutoConfiguration.NON_IGNORE_OBJECT_MAPPER_BEAN_NAME)
14-
private lateinit var mapper: ObjectMapper
13+
@Resource(name = JacksonAutoConfiguration.NON_IGNORE_OBJECT_MAPPER_BEAN_NAME) private lateinit var mapper: ObjectMapper
1514

1615
@BeforeTest
1716
fun setup() {
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package itest.integrate.depend.jackson
2+
3+
import com.fasterxml.jackson.databind.ObjectMapper
4+
import io.github.truenine.composeserver.depend.jackson.autoconfig.JacksonAutoConfiguration
5+
import io.github.truenine.composeserver.testtoolkit.log
6+
import jakarta.annotation.Resource
7+
import kotlin.test.Test
8+
import kotlin.test.assertEquals
9+
import org.springframework.boot.test.context.SpringBootTest
10+
11+
@SpringBootTest(classes = [TestEntrance::class])
12+
class TypedJacksonTest {
13+
@Resource(name = JacksonAutoConfiguration.NON_IGNORE_OBJECT_MAPPER_BEAN_NAME) lateinit var mapper: ObjectMapper
14+
15+
@Test
16+
fun inject_test() {
17+
val a = mapOf("a" to "b")
18+
val json = mapper.writeValueAsString(a)
19+
log.info("json: {}", json)
20+
assertEquals($$"""{"@class":"java.util.Collections$SingletonMap","a":"b"}""", json)
21+
}
22+
}

β€Žintegrate-test/depend/jackson/src/test/resources/application.yamlβ€Ž

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ spring:
22
output:
33
ansi:
44
enabled: always
5+
test:
6+
print-condition-evaluation-report: false

0 commit comments

Comments
Β (0)