-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from exacaster/fix_submit_params_conversion_pr…
…oblem Fix property with minus sign conversion problem
- Loading branch information
Showing
4 changed files
with
35 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
30 changes: 30 additions & 0 deletions
30
server/src/main/java/com/exacaster/lighter/configuration/PermanentSessionTypeConverter.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,30 @@ | ||
package com.exacaster.lighter.configuration; | ||
|
||
import com.exacaster.lighter.configuration.AppConfiguration.PermanentSession; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import io.micronaut.core.convert.ConversionContext; | ||
import io.micronaut.core.convert.TypeConverter; | ||
import jakarta.inject.Singleton; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
|
||
@Singleton | ||
public class PermanentSessionTypeConverter implements TypeConverter<Map, PermanentSession> { | ||
|
||
private final ObjectMapper mapper; | ||
|
||
public PermanentSessionTypeConverter(ObjectMapper mapper) { | ||
this.mapper = mapper; | ||
} | ||
|
||
/** | ||
* When deserializing configuration, Micronaut by default converts config properties with minus (-) sign | ||
* to camel case values. In that case `spark.kubernetes.driver.secrets.spark-secret` key becomes | ||
* `spark.kubernetes.driver.secrets.sparkSecret` that is unexpected behaviour. | ||
* This converter is a workaround for this problem. | ||
*/ | ||
@Override | ||
public Optional<PermanentSession> convert(Map object, Class<PermanentSession> targetType, ConversionContext context) { | ||
return Optional.of(mapper.convertValue(object, PermanentSession.class)); | ||
} | ||
} |
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
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