Commit Graph

543 Commits

Author SHA1 Message Date
Havoc Pennington
aea95bd228 fix some warnings from findbugs
Only one of these, possible incomplete skip
from DataInput.skipBytes(), was a real problem
I think.
2012-04-12 15:33:15 -04:00
Havoc Pennington
db3a676c02 Update build: sbt 0.11.2, maven central publish config, gpg 2012-04-12 15:21:06 -04:00
Havoc Pennington
f0e4dfd806 remove ConfigSubstitution, it was a serialization compat shim
The serialization-pocalypse removes the need for this shim.
2012-04-12 13:21:10 -04:00
Havoc Pennington
388d85fb5d Serialization-pocalypse: change serialization format
The previous use of Java's default serialization dumped
all implementation-detail class names and fields into the serialization,
making it basically impossible to improve the implementation.

Two strategies here:
 - prohibit serialization of unresolved configs, which are
   the location of a lot of implementation detail
 - delegate all serialization to an Externalizable
   SerializedConfigValue class, which serializes
   using fields that have lengths. Unknown fields
   can thus be skipped and we can write code to
   support obsolete fields, and so on.

As a side effect, this makes the serialization far more compact
because we don't need the Java per-class header noise, and we
jump through some hoops to avoid writing out duplicate ConfigOrigin
information. It still isn't super-compact compared to something
like protobuf but it's a lot less insane.
2012-04-12 13:04:14 -04:00
Havoc Pennington
d14d8cae78 add a couple tips about debugging configs to the README 2012-04-12 00:54:14 -04:00
Havoc Pennington
4add0330d8 fix formatting of a comment in Parseable.java 2012-04-09 19:19:04 -04:00
Havoc Pennington
2dc420ccf0 If include statements from a cycle, throw a nicer error 2012-04-09 19:18:46 -04:00
Havoc Pennington
36f4e2e61a write release notes for 0.NEXT 2012-04-09 12:49:38 -04:00
Havoc Pennington
6490226e8f Implement parsing url() file() classpath() includes 2012-04-09 12:26:44 -04:00
Havoc Pennington
05c60ea0fb Make string, stream parsers support classpath includes
Previously they didn't support any kind of include.
2012-04-09 12:26:44 -04:00
Havoc Pennington
386613909b hack ConfigImplUtil.urlToFile to make "file://whatever" with two slashes work
This compounds the wrongness of that method.
2012-04-09 12:26:44 -04:00
Havoc Pennington
3b7d99a797 Groundwork for the new file() url() classpath() include syntax
This patch doesn't have the parser just the implementation
2012-04-09 12:26:39 -04:00
Havoc Pennington
cdd3e127fc allow setting a ClassLoader on ConfigParseOptions
This should have been the API, rather than adding a loader
parameter to ConfigFactory methods.

By adding to the options, the class loader is inherited by
any included files or urls. Previously, it was only inherited
by included classpath resources, but including classpath resources
from non-classpath resources would lose track of the class loader.

The methods that take a ClassLoader are now convenience API that
just adds that passed-in loader to your ConfigParseOptions.
2012-04-09 10:29:35 -04:00
Havoc Pennington
ce352691ff make clear in docs that ConfigIncludeContext should not be implemented by apps 2012-04-09 10:28:51 -04:00
Havoc Pennington
5e7b929b65 Split ConfigIncludeContext from Parseable out into its own file 2012-04-09 10:28:51 -04:00
Havoc Pennington
8c6b204905 Specify url() classpath() file() includes in the spec 2012-04-09 10:28:45 -04:00
Havoc Pennington
3e46429871 split SimpleIncluder and fromBasename out of ConfigImpl.java
Just to have less stuff in one big file.
2012-04-06 19:41:30 -04:00
Havoc Pennington
69e6164b30 Support += convenience syntax
a += b

transforms to

    a += ${?a} [b]
2012-04-06 10:58:00 -04:00
Havoc Pennington
27096e262f Minor spec editing 2012-04-06 00:52:53 -04:00
Havoc Pennington
47e168a92f Implement array and object concatenation
path : [ /bin ]
  path : ${path} [ /usr/bin ]

This added very few lines of code or bytecode!
It's just a natural extension of the existing
string concatenation.

But it did add a fair few lines of specification
and tests.
2012-04-06 00:35:47 -04:00
Havoc Pennington
8189be0f16 make ConfigException.WrongType extra constructors public
and let Eclipse reformat a bit
2012-04-05 22:49:14 -04:00
Havoc Pennington
11a43d701c add very basic ConcatenationTest for string concatenation 2012-04-05 16:02:52 -04:00
Havoc Pennington
80eac565c6 remove ignoresFallbacks param from AbstractConfigValue.newCopy
Only one subclass ever used this, SimpleConfigObject

So now we have withFallbacksIgnored that asserts they are
already ignored, for the other classes, and has a special
SimpleConfigObject implementation.
2012-04-05 15:24:24 -04:00
Havoc Pennington
a8d444e19f Improve the spec's description of self-referential semantics 2012-04-05 14:59:05 -04:00
Havoc Pennington
401f2dc176 don't need to replace() in ConfigConcatenation
Because the cycle is detected by the nested ConfigReference.
2012-04-05 14:55:21 -04:00
Havoc Pennington
8fdc372330 Assert that delayed merge stacks don't contain other delayed merge stacks 2012-04-05 14:21:11 -04:00
Havoc Pennington
b696dbee38 Fix semantics of references from _inside_ a field value to that field
vs. the value itself being a reference to the field.

So this looks "backward":

  a : ${a}

vs. this does not:

  a : { b : ${a} }
2012-04-05 14:16:42 -04:00
Havoc Pennington
06ed4d24e1 fix error message for type errors mid-path
If you looked up "a.b.c" and b is not an object, it said
"a.b.c is a FOO and not an OBJECT"
now it says
"a.b is a FOO and not an OBJECT"
2012-04-05 14:02:37 -04:00
Havoc Pennington
683e72cbbe Clean up code and semantics around self-referential handling
The basic idea in this patch is to unify on the "replacer"
(modifying the tree in which we lookup substitutions)
mechanism for detecting cycles.

Drop the "traverse" method, instead keeping a trace of expressions
we've passed through for nice error messages.

There is now only one internal checked exception possible,
NotPossibleToResolve which is thrown when a cycle is detected;
this checked exception is always caught by ConfigReference
so cannot "escape" from the library. The exception exists
because we want to get the traceString debug info out
of the spot that detected the cycle, if we didn't want that
debug info we could just return null as usual for undefined.

As part of simplifying this (which should also simplify the
spec), resolutions which require double-traverse of the same
reference are no longer supported:
   a=1, b=${a}, a=${b}

Also, cycles now always throw UnresolvedSubstitution rather
than BadValue. This was needed for consistency since
conceptually a single a=${a} is going to "look back" earlier
in the merge stack, discover there is no earlier value of a,
and fail; it should be the same exception as a=${a},a={b:1},
and in both cases referring to these cycles via ${?} should
hide the exception.
2012-04-05 09:39:39 -04:00
Havoc Pennington
006777c062 Split ConfigSubstitution into ConfigConcatenation and ConfigReference
This makes the code a good bit simpler to reason about, the old
ConfigSubstitution really mixed two things into one class.

Unfortunately old ConfigSubstitution is hanging around as a compat
shim so we can deserialize stuff from the old version of the library.

The old version will not be able to deserialize unresolved configs
from this new version.

In retrospect it might have been better to forbid serialization
of unresolved configs and only support serializing resolved configs.
2012-03-31 22:09:05 -04:00
Havoc Pennington
27d92bec46 make ResolveSource.replacements use the value, not MemoKey, as key
The MemoKey stuff here was leftover from some earlier version of
the code, and was no longer used (the restrictToChild was always
null in the MemoKey).
2012-03-30 21:40:18 -04:00
Havoc Pennington
0f712f423b move "replacement" handling from ResolveContext to ResolveSource
this is where it belongs conceptually
2012-03-30 21:36:50 -04:00
Havoc Pennington
15bcfc984d move the "replacements" functionality to ResolveSource from Context
Conceptually, a "replacement" is a transformation of ResolveSource
2012-03-30 21:00:01 -04:00
Havoc Pennington
a22924de6d Delete SubstitutionResolver, so it's all in ResolveContext now 2012-03-30 20:46:26 -04:00
Havoc Pennington
0101d9ef37 move the memoizing functionality out of SubstitutionResolver 2012-03-30 20:10:05 -04:00
Havoc Pennington
d6b27c839a split 'ResolveSource' from SubstitutionResolver and ConfigSubstitution.
this is part of a plan to remove SubstitutionResolver (moving the
memoized hash to ResolveContext) and to move the "replacements"
functionality to ResolveSource. Should be clearer.
2012-03-30 19:24:44 -04:00
Havoc Pennington
e438dfc8c2 remove NeedsFullResolver internal checked exception
I think this was a relic of some earlier idea about how to do
things. It was used in one place that could just use the
public NotResolved exception, since it was converted to that
later anyhow.

To avoid error-message regression, we still catch NotResolved
and change it into a NotResolved with a different message in
certain cases.

Also clean up the wording of NotResolved in various places.
Probably NotResolved could just have a zero-parameters constructor.
2012-03-30 18:54:47 -04:00
Havoc Pennington
f6b1458169 couple of typo / formatting fixes 2012-03-30 17:26:54 -04:00
Havoc Pennington
44ce684985 Allow self-referential fields.
With this patch, you can write:

    path="a🅱️c"
    path=${path}":d"

The semantics are somewhat complicated to specify and
implement, but hopefully not complicated to use for
any reasonable usage that makes any sense.

This patch is technically backward incompatible,
illustrated by a change to existing unit tests,
but the changed behavior is in a bizarre corner case:
cyclical self-references where the cycle could be broken
by only partially resolving an object.

This corner case just threw an exception in the version
of this lib included with Akka/Play 2.0, but in commit
a59e31f744 we tried to handle the case. So the behavior
changes since that commit.

The partial resolution case now has the same consistent
defined semantics we use for all self-reference
resolution, that is it "looks back." In the previous
code it would "look forward."
2012-03-29 14:25:28 -04:00
Havoc Pennington
d9c9adc39f combine three resolveSubstitutions() parameters into ResolveContext
This makes it easier to mess with the parameters needed without
changing every resolveSubstitutions() all over the place.

Really the SubstitutionResolver and ResolveContext should maybe
be merged, but keeping this patch more incremental.
2012-03-29 09:51:58 -04:00
Havoc Pennington
6de4a991d4 In ConfigSubstitution, never ignoreFallbacks
Because the upcoming "allow self-references" behavior will
require looking at fallbacks.
2012-03-29 08:54:52 -04:00
Havoc Pennington
5566a091af Print problem object if merging an object yields non-object 2012-03-29 08:52:01 -04:00
Havoc Pennington
450a91ac22 add /bin-test-lib to .gitignore
This is a separate eclipse output folder for test-lib, because it
has test01.conf and so does the main src/test/resources
2012-03-28 23:34:47 -04:00
Havoc Pennington
5187a7ad4d To detect cycles, track visited MemoKey not visited nodes
Otherwise we can get a fake cycle when we try to do a partial
resolve on a node we are currently doing a full resolve on.
2012-03-28 23:07:00 -04:00
Havoc Pennington
db85e5ec8a Reimplement cycle detection with a traversed-node-set
This is probably not different from the depth counter
in practical situations, but it does guarantee 100%
that we are only detecting true cycles. Since we want
true cycles to have different semantics (in a following
patch), I feel better about this implementation.
2012-03-28 19:50:27 -04:00
Havoc Pennington
16871b597e add a future todo item about including URLs 2012-03-28 14:23:04 -04:00
Havoc Pennington
ef79b804e7 Link to the Typesafe CLA web form from the README 2012-03-27 07:53:13 -04:00
Havoc Pennington
4bee83c8a8 if -Dconfig.resource resource name starts with "/", drop the "/"
this is for compatibility with previous behavior.
2012-03-02 10:14:36 -05:00
Havoc Pennington
f497419970 minor clarifications and typo fixes in the spec 2012-03-01 19:47:14 -05:00
Havoc Pennington
08229c85b3 update NEWS for 0.3.0 2012-03-01 14:07:02 -05:00