Skip to content

Invalid URI format error when bulk read with an array of URIs containing valid strings and null  #759

@georgeajit

Description

@georgeajit

An existing test has an array of length 150, but uses only 102 elements of the array, with valid URIs. The rest of the elements in the array are nulls. When JSONDocumentManager class does a read with this array, then we have FailedRequestException.

Http wire trace is not included, since OKHttp log interceptor on each request/response needs to written or configured.

com.marklogic.client.FailedRequestException: Local message: failed to read resource at documents: Bad Request. Server Message: XDMP-URI: (err:FODC0005) fn:doc(("/0", "/1", "/2", ...)) -- Invalid URI format: ""
	at com.marklogic.client.impl.OkHttpServices.checkStatus(OkHttpServices.java:4237)
	at com.marklogic.client.impl.OkHttpServices.getIteratedResourceImpl(OkHttpServices.java:2932)
	at com.marklogic.client.impl.OkHttpServices.getBulkDocumentsImpl(OkHttpServices.java:950)
	at com.marklogic.client.impl.OkHttpServices.getBulkDocuments(OkHttpServices.java:842)
	at com.marklogic.client.impl.DocumentManagerImpl.read(DocumentManagerImpl.java:440)
	at com.marklogic.client.impl.JSONDocumentImpl.read(JSONDocumentImpl.java:26)
	at com.marklogic.client.impl.DocumentManagerImpl.read(DocumentManagerImpl.java:418)
	at com.marklogic.client.impl.JSONDocumentImpl.read(JSONDocumentImpl.java:26)
	at com.marklogic.client.impl.DocumentManagerImpl.read(DocumentManagerImpl.java:401)
	at com.marklogic.client.impl.JSONDocumentImpl.read(JSONDocumentImpl.java:26)
	at com.marklogic.client.functionaltest.TestBulkReadWriteWithJacksonDataBind.testSingleJacksonHandlerHundredJsonDocs(TestBulkReadWriteWithJacksonDataBind.java:437)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
public void testSingleJacksonHandlerHundredJsonDocs() throws Exception {
		
		JacksonHandle jh = new JacksonHandle();
		jh.withFormat(Format.JSON);
		JSONDocumentManager docMgr = client.newJSONDocumentManager();
		docMgr.setMetadataCategories(Metadata.ALL);
		docMgr.setNonDocumentFormat(Format.JSON);
		DocumentWriteSet writeset = docMgr.newWriteSet();
		// put meta-data
		DocumentMetadataHandle mh = setMetadata();
		writeset.addDefault(mh);
		
		JacksonDatabindHandle<String> handle1 = new JacksonDatabindHandle<String>(String.class);

		Map<String, String> jsonMap = new HashMap<String, String>();
		String[] uris = new String[102];
				
		String dir = new String("/");
		String mapDocId = null;
		StringBuffer mapDocContent = new StringBuffer();
		for (int i=0;i<102;i++)
		{
			mapDocId = dir + Integer.toString(i);
			mapDocContent.append("{\"content\":\"");
			mapDocContent.append(Integer.toString(i));
			mapDocContent.append("\"}");
			
			jsonMap.put(mapDocId, mapDocContent.toString());
			
			handle1.set(mapDocContent.toString());
			writeset.add(mapDocId, handle1);
			
			uris[i] = mapDocId;
						
			mapDocContent.setLength(0);
			mapDocId = null;
			docMgr.write(writeset);
			writeset.clear();
		}
		
		int count=0;
		
		 DocumentPage page = docMgr.read(uris);
		 DocumentRecord rec;
				  
		 while(page.hasNext()){
	    rec = page.next();
	    
	    assertNotNull("DocumentRecord should never be null", rec);
		assertNotNull("Document uri should never be null", rec.getUri());
		assertTrue("Document uri should start with " + DIRECTORY, rec.getUri().startsWith(DIRECTORY));
	    
		rec.getContent(jh);
		//Verify the contents: comparing Map with JacksonHandle's.
	    assertEquals("Comparing the content :",jsonMap.get(rec.getUri()),jh.get().toString());
	    count++;
	  }
     assertEquals("document count", 102,count);
     // Issue #294 DocumentPage.size() should return correct size
		assertTrue("DocumentPage Size did not return expected value:: returned==  "+page.size(), page.size() == 102 );
							
	}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions