Github user robertdale commented on the issue:

    https://github.com/apache/tinkerpop/pull/855
  
    Well, you would do use ConcurrentHashMap ;-)
    ```
    static Map<Class, Boolean> LOADED = new ConcurrentHashMap<>();
            try {
                LOADED.computeIfAbsent(graphOrGraphComputerClass, (unused) -> {
    
                    final String graphComputerClassName = null != 
graphOrGraphComputerClass.getDeclaringClass()
                            ? 
graphOrGraphComputerClass.getCanonicalName().replace(
                                    "." + 
graphOrGraphComputerClass.getSimpleName(),
                                    "$" + 
graphOrGraphComputerClass.getSimpleName())
                            : graphOrGraphComputerClass.getCanonicalName();
                    try {
                        Class.forName(graphComputerClassName);
                    } catch (ClassNotFoundException e) {
                        throw new RuntimeException(e);
                    }
    
                    // keep track of stuff we already loaded once - stuff in 
this if/statement isn't
                    // cheap and this
                    // method gets called a lot, basically every time a new 
traversal gets spun up
                    // (that includes
                    // child traversals. perhaps it is possible to just check 
the cache keys for
                    // this information, but
                    // it's not clear if this method will be called with 
something not in the cache
                    // and if it is and
                    // it results in error, then we'd probably not want to deal 
with this block
                    // again anyway
                    return Boolean.TRUE;
                });
            } catch (Exception e) {
                throw new IllegalStateException(e.getCause().getMessage(), 
e.getCause());
            }
    
    ```



---

Reply via email to