You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltaspike.apache.org by "Andrew Marinchuk (Jira)" <ji...@apache.org> on 2019/12/02 15:42:00 UTC
[jira] [Created] (DELTASPIKE-1397) Detect the cycled variable
references
Andrew Marinchuk created DELTASPIKE-1397:
--------------------------------------------
Summary: Detect the cycled variable references
Key: DELTASPIKE-1397
URL: https://issues.apache.org/jira/browse/DELTASPIKE-1397
Project: DeltaSpike
Issue Type: Wish
Security Level: public (Regular issues)
Components: Configuration
Affects Versions: 1.9.1
Environment: JDK 1.8
Reporter: Andrew Marinchuk
Due to mistake in config file, we encountered the java.lang.StackOverflowError.
{code:title=properties}fs.docs.path=/opt/docsFolder
fs.docs.path.IntegrationTest=/mnt/targetDocs
fs.docs.path.Staging=${fs.docs.path.IntegrationTest}
fs.docs.path.IntegrationTest=${fs.docs.path.IntegrationTest} <------- here is invalid copy-pasted string
fs.docs.path.Production=${fs.docs.path.IntegrationTest}{code}{code:title=stack trace}....
at org.apache.deltaspike.core.impl.config.TypedResolverImpl.getValue(TypedResolverImpl.java:253)
at org.apache.deltaspike.core.impl.config.TypedResolverImpl.resolveVariables(TypedResolverImpl.java:556)
at org.apache.deltaspike.core.impl.config.TypedResolverImpl.getPropertyValue(TypedResolverImpl.java:590)
at org.apache.deltaspike.core.impl.config.TypedResolverImpl.resolveStringValue(TypedResolverImpl.java:436)
at org.apache.deltaspike.core.impl.config.TypedResolverImpl.getValue(TypedResolverImpl.java:253)
at org.apache.deltaspike.core.impl.config.TypedResolverImpl.resolveVariables(TypedResolverImpl.java:556)
at org.apache.deltaspike.core.impl.config.TypedResolverImpl.getPropertyValue(TypedResolverImpl.java:590)
at org.apache.deltaspike.core.impl.config.TypedResolverImpl.resolveStringValue(TypedResolverImpl.java:436)
at org.apache.deltaspike.core.impl.config.TypedResolverImpl.getValue(TypedResolverImpl.java:253) {code}
It's very hard to find the configuration variable with a self-referencing problem because StackOverflowError's message does not contain information about variable with problem.
Wrapping each TypedResolver.getValue()'s call into try-catch is not the best practice in app code, but it's possible to detect the simplest self-referencing issues in org.apache.deltaspike.core.impl.config.TypedResolverImpl.resolveVariables(String).
The better (but much expensive) way is to track the reference chain during resolving variables or catching the StackOverflowError in library's code (it's not a good practice and will not help to find the core of reference loop because try-catch should be done at the first TypedResolver.getValue()'s call).
--
This message was sent by Atlassian Jira
(v8.3.4#803005)