Giter Site home page Giter Site logo

Comments (5)

kcoleman-marklogic avatar kcoleman-marklogic commented on June 1, 2024

Sravan noted the problem goes away if he comments out his JSON document. I wonder if it could be a Jackson interaction. Below is my working example of a heterogeneous batch that uses StringHandle for JSON instead of JacksonHandle, and it works fine.

    static void example4() {
        // Synthesize input content
        StringHandle jsonContent = new StringHandle(
            "{\"key\": \"value\"}").withFormat(Format.JSON);
        StringHandle xmlContent = new StringHandle(
            "<data>some xml content</data>").withFormat(Format.XML);
        String filename = new String("C:/Users/kcoleman/Downloads/nelf.jpg");
        FileHandle binaryContent = 
            new FileHandle().with(new File(filename)).withMimetype("image/jpeg");

        // Create and build up the batch
        GenericDocumentManager gdm = client.newDocumentManager();
        DocumentWriteSet batch = gdm.newWriteSet();
        batch.add("doc1.json", jsonContent);
        batch.add("doc2.xml", xmlContent);
        batch.add("doc3.jpg", binaryContent);
        gdm.write(batch);

        // Verify results
        System.out.println("doc1.json exists as: " + gdm.exists("doc1.json").getFormat().toString());
        System.out.println("doc2.xml exists as: " + gdm.exists("doc2.xml").getFormat().toString());
        System.out.println("doc3.jpg exists as: " + gdm.exists("doc3.jpg").getFormat().toString());
    }

from java-client-api.

ehennum avatar ehennum commented on June 1, 2024

I get the same error if I do a single document write with DocumentMetadataHandle + JacksonHandle. That's also a multipart write under the covers. Write of JacksonHandle alone succeeds as does write of DocumentMetadataHandle + StringHandle.

from java-client-api.

ehennum avatar ehennum commented on June 1, 2024

Turning off resendability in the JacksonHandle (to force digest authentication before the write) and turning on HttpClient logging shows what's going on.

When StringHandle is used, the terminating boundary for the multipart is sent:

[DEBUG] wire - >> "--Boundary_1_1277304478_1403790142585[\r][\n]"
[DEBUG] wire - >> "Content-Type: application/json[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "5f[\r][\n]"
[DEBUG] wire - >> "{"object":{"key":"value"},"array":["item1","item2"]}[\r][\n]"
[DEBUG] wire - >> "--Boundary_1_1277304478_1403790142585--[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "0[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - << "HTTP/1.1 204 Content Updated[\r][\n]"

When JacksonHandle is used, the terminating boundary is written after HttpClient has already closed the stream, triggering the error:

[DEBUG] wire - >> "--Boundary_1_1409826334_1403790513065[\r][\n]"
[DEBUG] wire - >> "Content-Type: application/json[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "34[\r][\n]"
[DEBUG] wire - >> "{"object":{"key":"value"},"array":["item1","item2"]}"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "0[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] DefaultClientConnection - Connection closed
[DEBUG] DefaultHttpClient - Closing the connection.
[DEBUG] DefaultClientConnection - Connection closed
[INFO] DefaultHttpClient - I/O exception (java.io.IOException) caught when processing request: Stream closed

from java-client-api.

sammefford avatar sammefford commented on June 1, 2024

Fixed on branch dev, as part of the pojoFacade branch/commit. I configured JacksonBaseHandle to set to false both JsonGenerator.Feature.AUTO_CLOSE_TARGET and JsonParser.Feature.AUTO_CLOSE_SOURCE.

from java-client-api.

sravanr avatar sravanr commented on June 1, 2024

Verified in the dev branch.

from java-client-api.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.