Date
1 - 5 of 5
Use of ModifierType fails if TypeDefinitionCategory is not loaded before
Thomas Franco <to...@...>
Hi,
When I try to set consistency of a property key (using JanusGraphManagement.setConsistency in a java project) I get a NPE if I don't refer the class TypeDefinitionCategory before. The method setConsistency uses ModifierType and there is a cyclic dependency between ModifierType and TypeDefinitionCategory. You can reproduce the error with this minimalist java code: import org.janusgraph.graphdb.database.management.ModifierType; import org.janusgraph.graphdb.types.TypeDefinitionCategory; public class JGModifierTypeIssue { public static void main(String[] args) { TypeDefinitionCategory dummy = TypeDefinitionCategory.BACKING_INDEX; // without the following line the next line generates a NPE System.out.println(ModifierType.CONSISTENCY); } } Should I create an issue on Github ? Regards, Toom. |
|
HadoopMarc <bi...@...>
Hi Thomas, Thanks for asking on the user group first. I cannot reproduce the issue (works fine on my system using java8). I ran: mvn exec:java -Dexec.mainClass="JGModifierTypeIssue" and get CONSISTENCY printed whether the TypeDefinitionCategory line is commented out or not. I used the pom.xml file below. Also, java does not have the concept of cyclical dependencies (as in python): an import causes a class load unless the class is already loaded. HTH, Marc <?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> <groupId>org.example</groupId> <artifactId>jgquestion</artifactId> <version>1.0-SNAPSHOT</version> <dependencies> <dependency> <groupId>org.janusgraph</groupId> <artifactId>janusgraph-core</artifactId> <version>0.5.2</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>3.0.0</version> <executions> <execution> <goals> <goal>exec</goal> </goals> </execution> </executions> <configuration> <executable>maven</executable> </configuration> </plugin> </plugins> </build> </project> Op maandag 31 augustus 2020 om 15:30:57 UTC+2 schreef Thomas Franco: Hi, |
|
toom <to...@...>
Cyclical dependency is not the right term. Static part of both class refers static member of the other.
toggle quoted message
Show quoted text
Anyway, I use your pom.xml and I reproduce the problem with Oracle java 8 (maybe it depends on the order of class load): $ cat src/main/java/JGModifierTypeIssue.java import org.janusgraph.graphdb.database.management.ModifierType; public class JGModifierTypeIssue { public static void main(String[] args) { System.out.println(ModifierType.CONSISTENCY); } } $ mvn exec:java -Dexec.mainClass="JGModifierTypeIssue" [INFO] Scanning for projects... [INFO] [INFO] -----------------------< org.example:jgquestion >----------------------- [INFO] Building jgquestion 1.0-SNAPSHOT [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- exec-maven-plugin:3.0.0:java (default-cli) @ jgquestion --- [WARNING] java.lang.ExceptionInInitializerError at org.janusgraph.graphdb.database.management.ModifierType.<clinit> (ModifierType.java:23) at JGModifierTypeIssue.main (JGModifierTypeIssue.java:8) at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:254) at java.lang.Thread.run (Thread.java:748) Caused by: java.lang.NullPointerException at org.janusgraph.graphdb.database.management.ModifierType.values (ModifierType.java:22) at org.janusgraph.graphdb.types.TypeDefinitionCategory.<clinit> (TypeDefinitionCategory.java:84) at org.janusgraph.graphdb.database.management.ModifierType.<clinit> (ModifierType.java:23) at JGModifierTypeIssue.main (JGModifierTypeIssue.java:8) at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:254) at java.lang.Thread.run (Thread.java:748) [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 0.682 s [INFO] Finished at: 2020-09-01T08:05:43+02:00 [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:3.0.0:java (default-cli) on project jgquestion: An exception occured while executing the Java class. null: ExceptionInInitializerError: NullPointerException -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException $ java -version java version "1.8.0_201" Java(TM) SE Runtime Environment (build 1.8.0_201-b09) Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode) Toom. On Monday, August 31, 2020 at 9:31:30 PM UTC+2 HadoopMarc wrote:
|
|
HadoopMarc <bi...@...>
Hi Toom, You are right, my bad. I can confirm this behaviour. Can you also document how this affects the use of JanusGraphManagement.setConsistency? void setConsistency(JanusGraphSchemaElement element, ConsistencyModifier consistency); Note that this method takes a ConsistencyModifier, not a ModifierType, that is why I ask. Best wishes, Marc Op dinsdag 1 september 2020 om 08:09:12 UTC+2 schreef toom: Cyclical dependency is not the right term. Static part of both class refers static member of the other. |
|
toom <to...@...>
Hello Marc,
toggle quoted message
Show quoted text
The method setConsistency uses ModifierType.CONSISTENCY (cf. https://github.com/JanusGraph/janusgraph/blob/v0.5.2/janusgraph-core/src/main/java/org/janusgraph/graphdb/database/management/ManagementSystem.java#L1268) Regards, Toom. On Wednesday, September 2, 2020 at 9:32:19 PM UTC+2 HadoopMarc wrote:
|
|