-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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 #34262 from quarkusio/dependabot/maven/flyway.vers…
…ion-9.20.0
- Loading branch information
Showing
5 changed files
with
93 additions
and
5 deletions.
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
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
66 changes: 66 additions & 0 deletions
66
...time/src/main/java/io/quarkus/flyway/runtime/graal/ClassicConfigurationSubstitutions.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,66 @@ | ||
package io.quarkus.flyway.runtime.graal; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.regex.Matcher; | ||
import java.util.regex.Pattern; | ||
|
||
import org.flywaydb.core.extensibility.ConfigurationExtension; | ||
import org.flywaydb.core.internal.plugin.PluginRegister; | ||
import org.flywaydb.core.internal.util.MergeUtils; | ||
|
||
import com.google.gson.Gson; | ||
import com.oracle.svm.core.annotate.Alias; | ||
import com.oracle.svm.core.annotate.RecomputeFieldValue; | ||
import com.oracle.svm.core.annotate.Substitute; | ||
import com.oracle.svm.core.annotate.TargetClass; | ||
|
||
@TargetClass(className = "org.flywaydb.core.api.configuration.ClassicConfiguration") | ||
public final class ClassicConfigurationSubstitutions { | ||
|
||
@Alias | ||
@RecomputeFieldValue(kind = RecomputeFieldValue.Kind.FromAlias) | ||
private static Pattern ANY_WORD_BETWEEN_TWO_QUOTES_PATTERN = Pattern.compile("\"([^\"]*)\""); | ||
|
||
@Alias | ||
PluginRegister pluginRegister; | ||
|
||
@Substitute | ||
private void determineKeysToRemoveAndRemoveFromProps(HashMap<String, Map<String, Object>> configExtensionsPropertyMap, | ||
List<String> keysToRemove, Map<String, String> props) { | ||
for (Map.Entry<String, Map<String, Object>> property : configExtensionsPropertyMap.entrySet()) { | ||
ConfigurationExtension cfg = null; | ||
for (ConfigurationExtension c : pluginRegister.getPlugins(ConfigurationExtension.class)) { | ||
if (c.getClass().toString().equals(property.getKey())) { | ||
cfg = c; | ||
break; | ||
} | ||
} | ||
if (cfg != null) { | ||
Map<String, Object> mp = property.getValue(); | ||
try { | ||
Gson gson = new Gson(); | ||
ConfigurationExtension newConfigurationExtension = gson.fromJson(gson.toJson(mp), cfg.getClass()); | ||
MergeUtils.mergeModel(newConfigurationExtension, cfg); | ||
} catch (Exception e) { | ||
Matcher matcher = ANY_WORD_BETWEEN_TWO_QUOTES_PATTERN.matcher(e.getMessage()); | ||
if (matcher.find()) { | ||
String errorProperty = matcher.group(1); | ||
List<String> propsToRemove = new ArrayList<>(); | ||
for (String k : keysToRemove) { | ||
if (k.endsWith(errorProperty)) { | ||
propsToRemove.add(k); | ||
} | ||
} | ||
keysToRemove.removeAll(propsToRemove); | ||
} | ||
} | ||
} | ||
} | ||
|
||
props.keySet().removeAll(keysToRemove); | ||
} | ||
|
||
} |
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