forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix config converter loading issue when arrays are used
We essentially use Class.forName to load the class instead of the ClassLoader directly, as the former knows how to deal with arrays Fixes: quarkusio#46170
- Loading branch information
Showing
4 changed files
with
43 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...xtension/extension/deployment/src/test/java/io/quarkus/config/ByteArrayConverterTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package io.quarkus.config; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import java.nio.charset.StandardCharsets; | ||
|
||
import org.eclipse.microprofile.config.inject.ConfigProperty; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class ByteArrayConverterTest { | ||
@RegisterExtension | ||
static final QuarkusUnitTest TEST = new QuarkusUnitTest() | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)) | ||
.overrideConfigKey("someapp.bytearray", "XyZ*123"); | ||
|
||
@ConfigProperty(name = "someapp.bytearray") | ||
protected byte[] bytearray; | ||
|
||
@Test | ||
void buildTimeConfigBuilder() { | ||
assertEquals("XyZ*123", new String(bytearray, StandardCharsets.UTF_8)); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...sion/runtime/src/main/java/io/quarkus/extest/runtime/config/ByteArrayConfigConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package io.quarkus.extest.runtime.config; | ||
|
||
import java.nio.charset.StandardCharsets; | ||
|
||
import org.eclipse.microprofile.config.spi.Converter; | ||
|
||
public class ByteArrayConfigConverter implements Converter<byte[]> { | ||
|
||
@Override | ||
public byte[] convert(final String s) { | ||
return s.getBytes(StandardCharsets.UTF_8); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...untime/src/main/resources/META-INF/services/org.eclipse.microprofile.config.spi.Converter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
io.quarkus.extest.runtime.config.ByteArrayConfigConverter |