mirror of
https://github.com/lightbend/config.git
synced 2025-04-02 15:41:00 +08:00
Add identity hash codes to some substitution trace messages
Otherwise you can't tell how it works since replacements and memoization are done by identity.
This commit is contained in:
parent
9e8532d3f0
commit
7994e02c71
@ -39,6 +39,6 @@ final class MemoKey {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final String toString() {
|
public final String toString() {
|
||||||
return "MemoKey(" + value + "," + restrictToChildOrNull + ")";
|
return "MemoKey(" + value + "@" + System.identityHashCode(value) + "," + restrictToChildOrNull + ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -127,7 +127,8 @@ final class ResolveContext {
|
|||||||
return cached;
|
return cached;
|
||||||
} else {
|
} else {
|
||||||
if (ConfigImpl.traceSubstitutionsEnabled())
|
if (ConfigImpl.traceSubstitutionsEnabled())
|
||||||
ConfigImpl.trace(depth(), "not found in cache, resolving " + original);
|
ConfigImpl.trace(depth(),
|
||||||
|
"not found in cache, resolving " + original + "@" + System.identityHashCode(original));
|
||||||
|
|
||||||
AbstractConfigValue resolved = source.resolveCheckingReplacement(this, original);
|
AbstractConfigValue resolved = source.resolveCheckingReplacement(this, original);
|
||||||
|
|
||||||
|
@ -85,6 +85,8 @@ final class ResolveSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void replace(AbstractConfigValue value, ResolveReplacer replacer) {
|
void replace(AbstractConfigValue value, ResolveReplacer replacer) {
|
||||||
|
if (ConfigImpl.traceSubstitutionsEnabled())
|
||||||
|
ConfigImpl.trace("Replacing " + value + "@" + System.identityHashCode(value) + " with " + replacer);
|
||||||
ResolveReplacer old = replacements.put(value, replacer);
|
ResolveReplacer old = replacements.put(value, replacer);
|
||||||
if (old != null)
|
if (old != null)
|
||||||
throw new ConfigException.BugOrBroken("should not have replaced the same value twice: "
|
throw new ConfigException.BugOrBroken("should not have replaced the same value twice: "
|
||||||
@ -95,6 +97,9 @@ final class ResolveSource {
|
|||||||
ResolveReplacer replacer = replacements.remove(value);
|
ResolveReplacer replacer = replacements.remove(value);
|
||||||
if (replacer == null)
|
if (replacer == null)
|
||||||
throw new ConfigException.BugOrBroken("unreplace() without replace(): " + value);
|
throw new ConfigException.BugOrBroken("unreplace() without replace(): " + value);
|
||||||
|
if (ConfigImpl.traceSubstitutionsEnabled())
|
||||||
|
ConfigImpl.trace("Unreplacing " + value + "@" + System.identityHashCode(value) + " which was replaced by "
|
||||||
|
+ replacer);
|
||||||
}
|
}
|
||||||
|
|
||||||
private AbstractConfigValue replacement(ResolveContext context, AbstractConfigValue value)
|
private AbstractConfigValue replacement(ResolveContext context, AbstractConfigValue value)
|
||||||
@ -131,8 +136,8 @@ final class ResolveSource {
|
|||||||
AbstractConfigValue resolved;
|
AbstractConfigValue resolved;
|
||||||
|
|
||||||
if (ConfigImpl.traceSubstitutionsEnabled())
|
if (ConfigImpl.traceSubstitutionsEnabled())
|
||||||
ConfigImpl.trace(context.depth(), "resolving " + original + " with trace '" + context.traceString()
|
ConfigImpl.trace(context.depth(),
|
||||||
+ "'");
|
"resolving unreplaced " + original + " with trace '" + context.traceString() + "'");
|
||||||
resolved = original.resolveSubstitutions(context);
|
resolved = original.resolveSubstitutions(context);
|
||||||
|
|
||||||
return resolved;
|
return resolved;
|
||||||
|
Loading…
Reference in New Issue
Block a user