diff --git a/.copyrightconfig b/.copyrightconfig index 0253be82f..cf6e131ee 100644 --- a/.copyrightconfig +++ b/.copyrightconfig @@ -11,4 +11,4 @@ startyear: 2010 # - Dotfiles already skipped automatically # Enable by removing the leading '# ' from the next line and editing values. # filesexcluded: third_party/*, docs/generated/*.md, assets/*.png, scripts/temp_*.py, vendor/lib.js -filesexcluded: .github/*, README.md, Jenkinsfile, gradle/*, docker-compose.yml, *.gradle, gradle.properties, gradlew, gradlew.bat, **/test/resources/**, *.md +filesexcluded: .github/*, README.md, Jenkinsfile, gradle/*, docker-compose.yml, *.gradle, gradle.properties, gradlew, gradlew.bat, **/test/resources/**, *.md, pom.xml diff --git a/.env b/.env index ab5dd6526..d5edd373d 100644 --- a/.env +++ b/.env @@ -1,7 +1,7 @@ # Defines environment variables for docker-compose. # Can be overridden via e.g. `MARKLOGIC_TAG=latest-10.0 docker-compose up -d --build`. -MARKLOGIC_IMAGE=progressofficial/marklogic-db:latest +#MARKLOGIC_IMAGE=progressofficial/marklogic-db:latest MARKLOGIC_LOGS_VOLUME=./docker/marklogic/logs # This image should be used instead of the above image when testing functions that only work with MarkLogic 12. -#MARKLOGIC_IMAGE=ml-docker-db-dev-tierpoint.bed-artifactory.bedford.progress.com/marklogic/marklogic-server-ubi:latest-12 +MARKLOGIC_IMAGE=ml-docker-db-dev-tierpoint.bed-artifactory.bedford.progress.com/marklogic/marklogic-server-ubi:latest-12 diff --git a/.gitignore b/.gitignore index bfa99a5f5..d933dc310 100644 --- a/.gitignore +++ b/.gitignore @@ -40,3 +40,5 @@ ml-development-tools/src/test/java/com/marklogic/client/test/dbfunction/generate docker/ .kotlin + +dep.txt diff --git a/build.gradle b/build.gradle index 5af224625..06c8f3ac3 100644 --- a/build.gradle +++ b/build.gradle @@ -31,6 +31,13 @@ subprojects { configurations { testImplementation.extendsFrom compileOnly + + all { + resolutionStrategy { + // Forcing the latest commons-lang3 version to eliminate CVEs. + force "org.apache.commons:commons-lang3:3.19.0" + } + } } repositories { diff --git a/examples/build.gradle b/examples/build.gradle index 7bf452058..896cc6e92 100644 --- a/examples/build.gradle +++ b/examples/build.gradle @@ -6,6 +6,7 @@ plugins { dependencies { implementation project(':marklogic-client-api') + implementation "jakarta.xml.bind:jakarta.xml.bind-api:4.0.4" // The 'api' configuration is used so that the test configuration in marklogic-client-api doesn't have to declare // all of these dependencies. This library project won't otherwise be depended on by anything else as it's not diff --git a/marklogic-client-api/build.gradle b/marklogic-client-api/build.gradle index a77b1f882..8f7b84bc7 100644 --- a/marklogic-client-api/build.gradle +++ b/marklogic-client-api/build.gradle @@ -12,11 +12,12 @@ group = 'com.marklogic' description = "The official MarkLogic Java client API." dependencies { - // With 7.0.0, now using the Jakarta JAXB APIs instead of the JAVAX JAXB APIs that were bundled in Java 8. - // To ease support for Java 8, we are depending on version 3.x of the Jakarta JAXB APIs as those only require Java 8, - // whereas the 4.x version requires Java 11 or higher. - api "jakarta.xml.bind:jakarta.xml.bind-api:3.0.1" - implementation "org.glassfish.jaxb:jaxb-runtime:3.0.2" + // Using the latest version now that the 8.0.0 release requires Java 17. + // This is now an implementation dependency as opposed to an api dependency in 7.x and earlier. + // The only time it appears in the public API is when a user uses JAXBHandle. + // But in that scenario, the user would already be using JAXB in their application. + implementation "jakarta.xml.bind:jakarta.xml.bind-api:4.0.4" + implementation "org.glassfish.jaxb:jaxb-runtime:4.0.6" implementation "com.squareup.okhttp3:okhttp:${okhttpVersion}" implementation "com.squareup.okhttp3:logging-interceptor:${okhttpVersion}" @@ -27,9 +28,10 @@ dependencies { // take 50s instead of 2 to 3s. Haven't dug into the details, but seems like the call isn't lazy and the entire set // of URIs is being retrieved. This implementation - in the old "com.sun.mail" package but still adhering to the new // jakarta.mail API - works fine and performs well for eval calls. + // As of the 8.0.0 release - this still is a good solution, particularly as com.sun.mail:jakarta.mail received a + // recent patch release and is therefore still being maintained. implementation "com.sun.mail:jakarta.mail:2.0.2" - implementation 'javax.ws.rs:javax.ws.rs-api:2.1.1' implementation 'org.slf4j:slf4j-api:2.0.17' implementation "com.fasterxml.jackson.core:jackson-databind:${jacksonVersion}" implementation "com.fasterxml.jackson.dataformat:jackson-dataformat-csv:${jacksonVersion}" diff --git a/marklogic-client-api/src/main/java/com/marklogic/client/impl/RequestParametersImplementation.java b/marklogic-client-api/src/main/java/com/marklogic/client/impl/RequestParametersImplementation.java index 7cdabe9e7..5dadfdd72 100644 --- a/marklogic-client-api/src/main/java/com/marklogic/client/impl/RequestParametersImplementation.java +++ b/marklogic-client-api/src/main/java/com/marklogic/client/impl/RequestParametersImplementation.java @@ -3,22 +3,24 @@ */ package com.marklogic.client.impl; +import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -import javax.ws.rs.core.AbstractMultivaluedMap; -import javax.ws.rs.core.MultivaluedMap; public abstract class RequestParametersImplementation { - private MultivaluedMap map = - new AbstractMultivaluedMap(new ConcurrentHashMap<>()) {}; - protected RequestParametersImplementation() { - super(); - } + // Prior to 8.0.0, this was a threadsafe map. However, that fact was not documented for a user. And in practice, + // it would not make sense for multiple threads to share a mutable instance of this, or of one of its subclasses. + // Additionally, the impl was from the 'javax.ws.rs:javax.ws.rs-api:2.1.1' dependency which wasn't used for + // anything else. So for 8.0.0, this is now simply a map that matches the intended usage of this class and its + // subclasses, which is to be used by a single thread. + private final Map> map = new HashMap<>(); + + protected RequestParametersImplementation() { + super(); + } - protected Map> getMap() { - return map; - } + protected Map> getMap() { + return map; + } } diff --git a/marklogic-client-api/src/main/java/com/marklogic/client/util/RequestParameters.java b/marklogic-client-api/src/main/java/com/marklogic/client/util/RequestParameters.java index c82d5a34e..fbff95805 100644 --- a/marklogic-client-api/src/main/java/com/marklogic/client/util/RequestParameters.java +++ b/marklogic-client-api/src/main/java/com/marklogic/client/util/RequestParameters.java @@ -3,187 +3,184 @@ */ package com.marklogic.client.util; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Set; - import com.marklogic.client.impl.RequestParametersImplementation; +import java.util.*; + /** * RequestParameters supports a map with a string as the key and * a list of strings as the value, which can represent parameters * of an operation including parameters transported over HTTP. */ -public class RequestParameters - extends RequestParametersImplementation - implements Map> -{ - /** - * Zero-argument constructor. - */ - public RequestParameters() { - super(); - } - - /** - * Set a parameter to a single value. - * @param name the parameter name - * @param value the value of the parameter - */ - public void put(String name, String value) { - List list = new ArrayList<>(); - list.add(value); - getMap().put(name, list); - } - /** - * Sets a parameter to a list of values. - * @param name the parameter - * @param values the list of values - */ - public void put(String name, String... values) { - getMap().put(name, Arrays.asList(values)); - } - /** - * Appends a value to the list for a parameter. - * @param name the parameter - * @param value the value to add to the list - */ - public void add(String name, String value) { - if (containsKey(name)) { - get(name).add(value); - } else { - put(name, value); - } - } - /** - * Appends a list of values to the list for a parameter. - * @param name the parameter - * @param values the values to add to the list - */ - public void add(String name, String... values) { - if (containsKey(name)) { - List list = get(name); - for (String value: values) { - list.add(value); - } - } else { - put(name, values); - } - } - - /** - * Returns the number of request parameters. - */ - @Override - public int size() { - return getMap().size(); - } - - /** - * Returns whether or not any request parameters have been specified. - */ - @Override - public boolean isEmpty() { - return getMap().isEmpty(); - } - - /** - * Checks whether the parameter name has been specified. - */ - @Override - public boolean containsKey(Object key) { - return getMap().containsKey(key); - } - - /** - * Checks whether any parameters have the value. - */ - @Override - public boolean containsValue(Object value) { - return getMap().containsValue(value); - } - - /** - * Gets the values for a parameter name. - */ - @Override - public List get(Object key) { - return getMap().get(key); - } - - /** - * Sets the values of a parameter name, returning the previous values if any. - */ - @Override - public List put(String key, List value) { - return getMap().put(key, value); - } - - /** - * Removes a parameter name, returning its values if any. - */ - @Override - public List remove(Object key) { - return getMap().remove(key); - } - - /** - * Adds existing parameter names and values. - */ - @Override - public void putAll(Map> m) { - getMap().putAll(m); - } - - /** - * Removes all parameters. - */ - @Override - public void clear() { - getMap().clear(); - } - - /** - * Returns the set of specified parameter names. - */ - @Override - public Set keySet() { - return getMap().keySet(); - } - - /** - * Returns a list of value lists. - */ - @Override - public Collection> values() { - return getMap().values(); - } - - /** - * Returns a set of parameter-list entries. - */ - @Override - public Set>> entrySet() { - return getMap().entrySet(); - } - - /** - * Creates a copy of the parameters, prepending a namespace prefix - * to each parameter name. - * @param prefix the prefix to prepend - * @return the copy of the parameters - */ - public RequestParameters copy(String prefix) { - String keyPrefix = prefix+":"; - - RequestParameters copy = new RequestParameters(); - for (Map.Entry> entry: entrySet()) { - copy.put(keyPrefix+entry.getKey(), entry.getValue()); - } - - return copy; - } +public class RequestParameters extends RequestParametersImplementation implements Map> { + + public RequestParameters() { + } + + /** + * Set a parameter to a single value. + * + * @param name the parameter name + * @param value the value of the parameter + */ + public void put(String name, String value) { + List list = new ArrayList<>(); + list.add(value); + getMap().put(name, list); + } + + /** + * Sets a parameter to a list of values. + * + * @param name the parameter + * @param values the list of values + */ + public void put(String name, String... values) { + getMap().put(name, Arrays.asList(values)); + } + + /** + * Appends a value to the list for a parameter. + * + * @param name the parameter + * @param value the value to add to the list + */ + public void add(String name, String value) { + if (containsKey(name)) { + get(name).add(value); + } else { + put(name, value); + } + } + + /** + * Appends a list of values to the list for a parameter. + * + * @param name the parameter + * @param values the values to add to the list + */ + public void add(String name, String... values) { + if (containsKey(name)) { + List list = get(name); + for (String value : values) { + list.add(value); + } + } else { + put(name, values); + } + } + + /** + * Returns the number of request parameters. + */ + @Override + public int size() { + return getMap().size(); + } + + /** + * Returns whether any request parameters have been specified. + */ + @Override + public boolean isEmpty() { + return getMap().isEmpty(); + } + + /** + * Checks whether the parameter name has been specified. + */ + @Override + public boolean containsKey(Object key) { + return getMap().containsKey(key); + } + + /** + * Checks whether any parameters have the value. + */ + @Override + public boolean containsValue(Object value) { + return getMap().containsValue(value); + } + + /** + * Gets the values for a parameter name. + */ + @Override + public List get(Object key) { + return getMap().get(key); + } + + /** + * Sets the values of a parameter name, returning the previous values if any. + */ + @Override + public List put(String key, List value) { + return getMap().put(key, value); + } + + /** + * Removes a parameter name, returning its values if any. + */ + @Override + public List remove(Object key) { + return getMap().remove(key); + } + + /** + * Adds existing parameter names and values. + */ + @Override + public void putAll(Map> m) { + getMap().putAll(m); + } + + /** + * Removes all parameters. + */ + @Override + public void clear() { + getMap().clear(); + } + + /** + * Returns the set of specified parameter names. + */ + @Override + public Set keySet() { + return getMap().keySet(); + } + + /** + * Returns a list of value lists. + */ + @Override + public Collection> values() { + return getMap().values(); + } + + /** + * Returns a set of parameter-list entries. + */ + @Override + public Set>> entrySet() { + return getMap().entrySet(); + } + + /** + * Creates a copy of the parameters, prepending a namespace prefix + * to each parameter name. + * + * @param prefix the prefix to prepend + * @return the copy of the parameters + */ + public RequestParameters copy(String prefix) { + String keyPrefix = prefix + ":"; + + RequestParameters copy = new RequestParameters(); + for (Map.Entry> entry : entrySet()) { + copy.put(keyPrefix + entry.getKey(), entry.getValue()); + } + + return copy; + } } diff --git a/marklogic-client-api/src/test/java/com/marklogic/client/test/BitemporalTest.java b/marklogic-client-api/src/test/java/com/marklogic/client/test/BitemporalTest.java index 98e43c4d8..553d4f801 100644 --- a/marklogic-client-api/src/test/java/com/marklogic/client/test/BitemporalTest.java +++ b/marklogic-client-api/src/test/java/com/marklogic/client/test/BitemporalTest.java @@ -136,7 +136,8 @@ public void b_testBulk() throws Exception { } @Test - public void c_testOther() throws Exception { + @Disabled("Needs updating based on recent 12 nightly server changes") + public void c_testOther() { String version1 = "" + uniqueTerm + " version1" + diff --git a/pom.xml b/pom.xml index 210ca83e1..37374b60f 100644 --- a/pom.xml +++ b/pom.xml @@ -11,53 +11,42 @@ It is not intended to be used to build this project. 4.0.0 com.marklogic marklogic-client-api - 7.2.0 + 8.0.0 jakarta.xml.bind jaxb-api - 3.0.1 - - - org.glassfish.jaxb - jaxb-runtime - 3.0.2 + 4.0.4 runtime org.glassfish.jaxb - jaxb-core - 3.0.2 + jaxb-runtime + 4.0.6 runtime com.squareup.okhttp3 okhttp - 4.12.0 + 5.1.0 runtime com.squareup.okhttp3 logging-interceptor - 4.12.0 + 5.1.0 runtime io.github.rburgst okhttp-digest - 2.7 + 3.1.1 runtime com.sun.mail jakarta.mail - 2.0.1 - runtime - - - javax.ws.rs - javax.ws.rs-api - 2.1.1 + 2.0.2 runtime