- 
                Notifications
    You must be signed in to change notification settings 
- Fork 32
Description
Is there an existing issue for this?
- I have searched the existing issues
SDK Version
<dependency>
  <groupId>com.optimizely.ab</groupId>
  <artifactId>core-api</artifactId>
  <version>4.1.1</version>
</dependency>
Current Behavior
Using JsonConfigParser leads to runtime exception, because it requires org.json.JsonObject from org.json:json which is not provided as an implementation dependency.
JsonConfigParser https://github.com/optimizely/java-sdk/blob/master/core-api/src/main/java/com/optimizely/ab/config/parser/JsonConfigParser.java
Dependency excluded here: https://github.com/optimizely/java-sdk/blob/master/core-api/build.gradle#L11
Expected Behavior
Users of your library should be able to use JsonConfigParser without knowing about its internal dependencies.
Steps To Reproduce
Create a Project with
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <artifactId>repro</artifactId>
    <groupId>repro</groupId>
    <version>1.0.0</version>
    <dependencies>
        <dependency>
            <groupId>com.optimizely.ab</groupId>
            <artifactId>core-api</artifactId>
            <version>4.1.1</version>
        </dependency>
    </dependencies>
</project>
and settings.xml
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
          https://maven.apache.org/xsd/settings-1.0.0.xsd">
</settings>
and src/main/java/Main.java
import com.optimizely.ab.config.parser.ConfigParseException;
import com.optimizely.ab.config.parser.JsonConfigParser;
public class Main {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
        JsonConfigParser parser = new JsonConfigParser();
        try {
            parser.parseProjectConfig("{}");
        } catch (ConfigParseException e) {
            e.printStackTrace();
        }
    }
}
% mvn clean compile
% mvn exec:java -Dexec.mainClass=Main
Java Version
% mvn -version
Apache Maven 3.9.9 (8e8579a9e76f7d015ee5ec7bfcdc97d260186937)
Maven home: /usr/local/Cellar/maven/3.9.9/libexec
Java version: 11.0.22, vendor: Amazon.com Inc.
Link
No response
Logs
No response
Severity
No response
Workaround/Solution
Solution
Change https://github.com/optimizely/java-sdk/blob/master/core-api/build.gradle#L11
from compileOnly to implementation
Alternatively, do not expose JsonConfigParser to consumers of your library.
Recent Change
No response
Conflicts
No response