Skip to content

Commit

Permalink
[Io7UetI2] Fix log4j dependency conflict.
Browse files Browse the repository at this point in the history
Also improve MissingDependencyException with cause where possible.
  • Loading branch information
Lojjs committed Sep 30, 2024
1 parent 2fb26c5 commit 2b80723
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 14 deletions.
4 changes: 4 additions & 0 deletions core/src/main/java/apoc/util/MissingDependencyException.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,8 @@ public class MissingDependencyException extends RuntimeException {
public MissingDependencyException(String message) {
super(message);
}

public MissingDependencyException(String message, Throwable cause) {
super(message, cause);
}
}
18 changes: 14 additions & 4 deletions extra-dependencies/xls/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,21 @@ jar {
}

dependencies {
implementation group: 'org.apache.poi', name: 'poi', version: '5.3.0'
implementation group: 'org.apache.poi', name: 'poi-ooxml-lite', version: '5.3.0'
implementation group: 'org.apache.poi', name: 'poi-ooxml', version: '5.3.0' , {
exclude group: 'org.apache.commons', module: 'commons-compress'
// Make sure no transitive dependencies are included together with apache.poi

compileOnly "org.apache.poi:poi:5.3.0", {
exclude group: '*'
}
testImplementation "org.apache.poi:poi:5.3.0", {
exclude group: '*'
}
compileOnly "org.apache.poi:poi-ooxml:5.3.0", {
exclude group: '*'
}
testImplementation "org.apache.poi:poi-ooxml:5.3.0", {
exclude group: '*'
}

implementation group: 'org.apache.xmlbeans', name: 'xmlbeans', version: '5.0.2'
implementation group: 'com.github.virtuald', name: 'curvesapi', version: '1.06'
implementation group: 'org.apache.commons', name: 'commons-collections4', version: '4.4'
Expand Down
18 changes: 14 additions & 4 deletions full/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,20 @@ dependencies {
// compileOnly "org.antlr:antlr4-runtime:4.7.2"
// testCompile "org.antlr:antlr4-runtime:4.7.2"

compileOnly "org.apache.poi:poi:5.3.0"
testImplementation "org.apache.poi:poi:5.3.0"
compileOnly "org.apache.poi:poi-ooxml:5.3.0"
testImplementation "org.apache.poi:poi-ooxml:5.3.0"
// Make sure no transitive dependencies are included together with apache.poi

compileOnly "org.apache.poi:poi:5.3.0", {
exclude group: '*'
}
testImplementation "org.apache.poi:poi:5.3.0", {
exclude group: '*'
}
compileOnly "org.apache.poi:poi-ooxml:5.3.0", {
exclude group: '*'
}
testImplementation "org.apache.poi:poi-ooxml:5.3.0", {
exclude group: '*'
}

implementation 'org.jsoup:jsoup:1.15.3'

Expand Down
2 changes: 1 addition & 1 deletion full/src/main/java/apoc/couchbase/Couchbase.java
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ private CouchbaseConnection getCouchbaseConnection(String hostOrKey, String buck
CouchbaseConfig config = new CouchbaseConfig(configMap);
return CouchbaseManager.getConnection(hostOrKey, bucket, config);
} catch (NoClassDefFoundError e) {
throw new MissingDependencyException(COUCHBASE_MISSING_DEPS_ERROR);
throw new MissingDependencyException(COUCHBASE_MISSING_DEPS_ERROR, e);
}
}
}
2 changes: 1 addition & 1 deletion full/src/main/java/apoc/data/email/ExtractEmail.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public Map<String, String> email(final @Name("email_address") String value) {
try {
return extractEmail(value);
} catch (NoClassDefFoundError e) {
throw new MissingDependencyException(EMAIL_MISSING_DEPS_ERROR);
throw new MissingDependencyException(EMAIL_MISSING_DEPS_ERROR, e);
}
}
}
2 changes: 1 addition & 1 deletion full/src/main/java/apoc/export/xls/ExportXls.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ private Stream<ProgressInfo> exportXls(
try {
return ExportXlsHandler.getProgressInfoStream(fileName, source, data, configMap, apocConfig, db);
} catch (NoClassDefFoundError e) {
throw new MissingDependencyException(XLS_MISSING_DEPS_ERROR);
throw new MissingDependencyException(XLS_MISSING_DEPS_ERROR, e);
}
}
}
2 changes: 1 addition & 1 deletion full/src/main/java/apoc/load/LoadXls.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public Stream<XLSResult> xls(
url, stream, selection, skip, hasHeader, limit, ignore, nullValues, mappings, skipNulls);
return StreamSupport.stream(xlsSpliterator, false);
} catch (NoClassDefFoundError e) {
throw new MissingDependencyException(XLS_MISSING_DEPS_ERROR);
throw new MissingDependencyException(XLS_MISSING_DEPS_ERROR, e);
} catch (Exception e) {
if (!failOnError)
return Stream.of(
Expand Down
2 changes: 1 addition & 1 deletion full/src/main/java/apoc/mongodb/MongoDBUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ protected static MongoDbConfig getMongoConfig(Map<String, Object> config) {
try {
return new MongoDbConfig(config);
} catch (NoClassDefFoundError e) {
throw new MissingDependencyException(MONGO_MISSING_DEPS_ERROR);
throw new MissingDependencyException(MONGO_MISSING_DEPS_ERROR, e);
}
}
}
2 changes: 1 addition & 1 deletion full/src/main/java/apoc/redis/RedisConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public RedisConnection getRedisConnection(String uri, Map<String, Object> config
Constructor<?> constructor = redisConnectionClass.getConstructor(String.class, RedisConfig.class);
return (RedisConnection) constructor.newInstance(uri, redisConfig);
} catch (NoClassDefFoundError e) {
throw new MissingDependencyException(REDIS_MISSING_DEPS_ERROR);
throw new MissingDependencyException(REDIS_MISSING_DEPS_ERROR, e);
} catch (Exception e) {
throw new RuntimeException(e);
}
Expand Down

0 comments on commit 2b80723

Please sign in to comment.