Java OrientDB在运行多个实例时返回空顶点

Java OrientDB在运行多个实例时返回空顶点,java,database,orientdb,Java,Database,Orientdb,这个测试应该是不言自明的,但不管怎么说,我们一直在寻找这个奇怪的bug,经过无数次不同的测试,我们发现了这个问题 服务器必须处理来自不同领域(例如来自不同域)的数据,最好将它们存储在完全不同的数据库中 由于某些原因,当先前在其他位置打开另一个OrientGraph时,OrientDB返回空顶点 希望这对于StackOverflow的算法来说是足够无意义的文本,下面是代码: @Test public void testLowLevelMultipleRealms() throws Exceptio

这个测试应该是不言自明的,但不管怎么说,我们一直在寻找这个奇怪的bug,经过无数次不同的测试,我们发现了这个问题

服务器必须处理来自不同领域(例如来自不同域)的数据,最好将它们存储在完全不同的数据库中

由于某些原因,当先前在其他位置打开另一个OrientGraph时,OrientDB返回空顶点

希望这对于StackOverflow的算法来说是足够无意义的文本,下面是代码:

@Test
public void testLowLevelMultipleRealms() throws Exception {

    String location=("plocal:"+StorageHandler.getBase("test")+"db/orient/");
    String location2=("plocal:"+StorageHandler.getBase("local")+"db/orient/");

    boolean importantVariable=true;
    if(importantVariable){
        //fails
        OrientGraph graph =  new OrientGraphFactory(location).setupPool(1,10).getTx();
        graph.shutdown();

        //also fails
        //OrientGraph graph =  new OrientGraphFactory(location).setupPool(1,10).getTx();

        //also fails
        //new OrientGraphFactory(location).setupPool(1,10);

        //doesn't fail
        //new OrientGraphFactory(location);

        //doesn't fail
        //OrientGraph graph =  new OrientGraphFactory(location2).setupPool(1,10).getTx();


    }
    OrientGraph graph =  new OrientGraphFactory(location2).setupPool(1,10).getTx();

    Vertex v = graph.getVertex("#9:1");
    assertNotNull(v);//passes
    assertNotNull(v.getProperty("title"));//fails iff. importantVariable==true


}

结果表明,OrientDB只检查路径的最后一个文件夹,以检查db:s是否相同。由于这两条路径都以db/orient结尾,所以它被弄乱了。添加一个冗余但唯一的子文件夹成功了。

您也可以使用
$
而不是
/
,它会起作用。

找到了这个。。。tl;dr:OrientDB将对上次使用的数据库的引用保存在ThreadLocal空间中。。。但我不知道该怎么解决这个问题