Skip to content

Commit 2b80723

Browse files
committedSep 30, 2024·
[Io7UetI2] Fix log4j dependency conflict.
Also improve MissingDependencyException with cause where possible.
1 parent 2fb26c5 commit 2b80723

File tree

9 files changed

+38
-14
lines changed

9 files changed

+38
-14
lines changed
 

‎core/src/main/java/apoc/util/MissingDependencyException.java

+4
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,8 @@ public class MissingDependencyException extends RuntimeException {
2525
public MissingDependencyException(String message) {
2626
super(message);
2727
}
28+
29+
public MissingDependencyException(String message, Throwable cause) {
30+
super(message, cause);
31+
}
2832
}

‎extra-dependencies/xls/build.gradle

+14-4
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,21 @@ jar {
2020
}
2121

2222
dependencies {
23-
implementation group: 'org.apache.poi', name: 'poi', version: '5.3.0'
24-
implementation group: 'org.apache.poi', name: 'poi-ooxml-lite', version: '5.3.0'
25-
implementation group: 'org.apache.poi', name: 'poi-ooxml', version: '5.3.0' , {
26-
exclude group: 'org.apache.commons', module: 'commons-compress'
23+
// Make sure no transitive dependencies are included together with apache.poi
24+
25+
compileOnly "org.apache.poi:poi:5.3.0", {
26+
exclude group: '*'
27+
}
28+
testImplementation "org.apache.poi:poi:5.3.0", {
29+
exclude group: '*'
30+
}
31+
compileOnly "org.apache.poi:poi-ooxml:5.3.0", {
32+
exclude group: '*'
2733
}
34+
testImplementation "org.apache.poi:poi-ooxml:5.3.0", {
35+
exclude group: '*'
36+
}
37+
2838
implementation group: 'org.apache.xmlbeans', name: 'xmlbeans', version: '5.0.2'
2939
implementation group: 'com.github.virtuald', name: 'curvesapi', version: '1.06'
3040
implementation group: 'org.apache.commons', name: 'commons-collections4', version: '4.4'

‎full/build.gradle

+14-4
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,20 @@ dependencies {
6464
// compileOnly "org.antlr:antlr4-runtime:4.7.2"
6565
// testCompile "org.antlr:antlr4-runtime:4.7.2"
6666

67-
compileOnly "org.apache.poi:poi:5.3.0"
68-
testImplementation "org.apache.poi:poi:5.3.0"
69-
compileOnly "org.apache.poi:poi-ooxml:5.3.0"
70-
testImplementation "org.apache.poi:poi-ooxml:5.3.0"
67+
// Make sure no transitive dependencies are included together with apache.poi
68+
69+
compileOnly "org.apache.poi:poi:5.3.0", {
70+
exclude group: '*'
71+
}
72+
testImplementation "org.apache.poi:poi:5.3.0", {
73+
exclude group: '*'
74+
}
75+
compileOnly "org.apache.poi:poi-ooxml:5.3.0", {
76+
exclude group: '*'
77+
}
78+
testImplementation "org.apache.poi:poi-ooxml:5.3.0", {
79+
exclude group: '*'
80+
}
7181

7282
implementation 'org.jsoup:jsoup:1.15.3'
7383

‎full/src/main/java/apoc/couchbase/Couchbase.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ private CouchbaseConnection getCouchbaseConnection(String hostOrKey, String buck
400400
CouchbaseConfig config = new CouchbaseConfig(configMap);
401401
return CouchbaseManager.getConnection(hostOrKey, bucket, config);
402402
} catch (NoClassDefFoundError e) {
403-
throw new MissingDependencyException(COUCHBASE_MISSING_DEPS_ERROR);
403+
throw new MissingDependencyException(COUCHBASE_MISSING_DEPS_ERROR, e);
404404
}
405405
}
406406
}

‎full/src/main/java/apoc/data/email/ExtractEmail.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public Map<String, String> email(final @Name("email_address") String value) {
4141
try {
4242
return extractEmail(value);
4343
} catch (NoClassDefFoundError e) {
44-
throw new MissingDependencyException(EMAIL_MISSING_DEPS_ERROR);
44+
throw new MissingDependencyException(EMAIL_MISSING_DEPS_ERROR, e);
4545
}
4646
}
4747
}

‎full/src/main/java/apoc/export/xls/ExportXls.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ private Stream<ProgressInfo> exportXls(
111111
try {
112112
return ExportXlsHandler.getProgressInfoStream(fileName, source, data, configMap, apocConfig, db);
113113
} catch (NoClassDefFoundError e) {
114-
throw new MissingDependencyException(XLS_MISSING_DEPS_ERROR);
114+
throw new MissingDependencyException(XLS_MISSING_DEPS_ERROR, e);
115115
}
116116
}
117117
}

‎full/src/main/java/apoc/load/LoadXls.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public Stream<XLSResult> xls(
149149
url, stream, selection, skip, hasHeader, limit, ignore, nullValues, mappings, skipNulls);
150150
return StreamSupport.stream(xlsSpliterator, false);
151151
} catch (NoClassDefFoundError e) {
152-
throw new MissingDependencyException(XLS_MISSING_DEPS_ERROR);
152+
throw new MissingDependencyException(XLS_MISSING_DEPS_ERROR, e);
153153
} catch (Exception e) {
154154
if (!failOnError)
155155
return Stream.of(

‎full/src/main/java/apoc/mongodb/MongoDBUtils.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ protected static MongoDbConfig getMongoConfig(Map<String, Object> config) {
5656
try {
5757
return new MongoDbConfig(config);
5858
} catch (NoClassDefFoundError e) {
59-
throw new MissingDependencyException(MONGO_MISSING_DEPS_ERROR);
59+
throw new MissingDependencyException(MONGO_MISSING_DEPS_ERROR, e);
6060
}
6161
}
6262
}

‎full/src/main/java/apoc/redis/RedisConfig.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public RedisConnection getRedisConnection(String uri, Map<String, Object> config
4949
Constructor<?> constructor = redisConnectionClass.getConstructor(String.class, RedisConfig.class);
5050
return (RedisConnection) constructor.newInstance(uri, redisConfig);
5151
} catch (NoClassDefFoundError e) {
52-
throw new MissingDependencyException(REDIS_MISSING_DEPS_ERROR);
52+
throw new MissingDependencyException(REDIS_MISSING_DEPS_ERROR, e);
5353
} catch (Exception e) {
5454
throw new RuntimeException(e);
5555
}

0 commit comments

Comments
 (0)
Please sign in to comment.