Commit a500c81
authored
feat: lazy load jsonParser and yamlParser FlagFileParser (#35)
I want to be able to use the thin jar without the snakeyaml dependency,
since I don't need to parse yaml files, just json files.
If I try that I get the following exception:
```
Cause: java.lang.ClassNotFoundException: org.yaml.snakeyaml.error.YAMLException
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:476)
at sbt.internal.ManagedClassLoader.findClass(ManagedClassLoader.java:103)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:594)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:527)
at com.launchdarkly.sdk.server.integrations.FileDataSourceParsing$FlagFileParser.<clinit>(FileDataSourceParsing.java:76)
at com.launchdarkly.sdk.server.integrations.FileDataSourceImpl$DataLoader.load(FileDataSourceImpl.java:241)
at com.launchdarkly.sdk.server.integrations.FileDataSourceImpl.reload(FileDataSourceImpl.java:108)
at com.launchdarkly.sdk.server.integrations.FileDataSourceImpl.start(FileDataSourceImpl.java:92)
at com.launchdarkly.sdk.server.LDClient.<init>(LDClient.java:239)
```
This PR avoids loading the `YamlFlagFileParser` by using a holder class
idiom for lazy initialization of a static field.
**Requirements**
- [ ] I have added test coverage for new or changed functionality
- Existing tests still pass, but I don't see a way to add unit tests for
this functionality. I published this library locally and tested it on my
project successfully.
- [x] I have followed the repository's [pull request submission
guidelines](../blob/main/CONTRIBUTING.md#submitting-pull-requests)
- [ ] I have validated my changes against all supported platform
versions
**Related issues**
n/a
**Describe the solution you've provided**
The solution is to lazy load the `YamlFlagFileParser` (and the
`JsonFlagFileParser`) so they are only initialised if needed
**Describe alternatives you've considered**
n/a
**Additional context**
n/a1 parent 8fe5eef commit a500c81
File tree
1 file changed
+13
-3
lines changed- lib/sdk/server/src/main/java/com/launchdarkly/sdk/server/integrations
1 file changed
+13
-3
lines changedLines changed: 13 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
75 | | - | |
76 | | - | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
77 | 87 | | |
78 | 88 | | |
79 | 89 | | |
80 | 90 | | |
81 | 91 | | |
82 | | - | |
| 92 | + | |
83 | 93 | | |
84 | 94 | | |
85 | 95 | | |
| |||
0 commit comments