Skip to content

Commit

Permalink
Fixes #558: Check for neo4j version being compatible with neo version
Browse files Browse the repository at this point in the history
  • Loading branch information
vga91 committed Apr 5, 2022
1 parent 55a2b2d commit e50bdb2
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions core/src/main/java/apoc/RegisterComponentFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.neo4j.kernel.extension.ExtensionFactory;
import org.neo4j.kernel.extension.ExtensionType;
import org.neo4j.kernel.extension.context.ExtensionContext;
import org.neo4j.kernel.internal.Version;
import org.neo4j.kernel.lifecycle.Lifecycle;
import org.neo4j.kernel.lifecycle.LifecycleAdapter;
import org.neo4j.logging.Log;
Expand Down Expand Up @@ -54,6 +55,14 @@ public Map<Class, Map<String, Object>> getResolvers() {

@Override
public void init() throws Exception {
final String kernelFullVersion = Version.getKernelVersion();
final String kernelVersion = getMajorMinVersion(kernelFullVersion);
final String apocFullVersion = apoc.version.Version.class.getPackage().getImplementationVersion();
if (kernelVersion != null && !kernelVersion.equals(getMajorMinVersion(apocFullVersion))) {
log.warn("The apoc version (%s) and the Neo4j version (%s) are incompatible. \n" +
"See the compatibility matrix in https://neo4j.com/labs/apoc/4.4/installation/ to see the correct version",
apocFullVersion, kernelFullVersion);
}

for (ApocGlobalComponents c: Services.loadAll(ApocGlobalComponents.class)) {
for (Class clazz: c.getContextClasses()) {
Expand All @@ -73,5 +82,13 @@ public void init() throws Exception {
);
}

private String getMajorMinVersion(String completeVersion) {
if (completeVersion == null) {
return null;
}
final String[] split = completeVersion.split("\\.");
return split[0] + "." + split[1];
}

}
}

0 comments on commit e50bdb2

Please sign in to comment.