I'm using java 1.8.0_211 on ubuntu18.04
in my build.gradle the deps  for jackson are
  jooqdbCompile "com.fasterxml.jackson.core:jackson-databind:2.9.+"
  jooqdbCompile "com.fasterxml.jackson.core:jackson-core:2.9.+"
  jooqdbCompile "com.fasterxml.jackson.core:jackson-annotations:2.9.+"
(I did just notice today that a 2.10 exists)

>From this 

public static void writeAsString(AbstractPayload payload, String outdirName) {
    File ofile = new File(outdirName, payload.getRunTag().toString()+ 
".json.gz");
    try (FileOutputStream fos = new FileOutputStream(ofile);
         GZIPOutputStream zos = new GZIPOutputStream(fos,true) ) {
        logger.error("Writing to file: {}", ofile.getCanonicalPath());
        payload.asJson(zos);
    }
    catch (Exception e) {
        logger.error ("Complete write failure of payload {}", 
payload.getRunTag(), e);
        e.printStackTrace();
    }
}

to the "asJson" call here

public void asJson(OutputStream stream) {
    try {
        getObjectMapper().writeValue(stream, this);
    }
    catch (Exception e) {
        e.printStackTrace();
        logger.error("{}: could not serialize to stream", getRunTag());
    }
}

and the "getObjectMapper() call is

private ObjectMapper getObjectMapper() {
    if (objectMapper == null) {
        objectMapper = new ObjectMapper();
        objectMapper.configure(SerializationFeature.INDENT_OUTPUT, false);
        objectMapper.configure(JsonGenerator.Feature.AUTO_CLOSE_TARGET, false);
        
objectMapper.setDefaultPropertyInclusion(JsonInclude.Value.construct(Include.NON_EMPTY,
 Include.ALWAYS));
    }
    return objectMapper;
}


I see plenty of flush()ing jackson-core so I don't think that's the problem, 

but putting the GZIPOutputStream in a try/with appeared to help. Prior to that,

small "payloads" (typically under 2K bytes) where getting written as 10-byte 
files.


gzip -d just complains and does nothing to the source json.gz file


I can zcat the json.gz files successfully, but do get the gzip error messages:


zcat test/crashpad/chaser/db182faa-cafd-47e9-9798-bc645486ffe1.json.gz | python 
-m json.tool >/tmp/c.json

gzip: test/crashpad/chaser/db182faa-cafd-47e9-9798-bc645486ffe1.json.gz: 
unexpected end of file
tail -f /tmp/c.json
                [
                    null,
                    "174616,9746805,9815786,9815795,9815801,9815813",
                    null,
                    null
                ]
            ]
        }
    }
}



-- 
You received this message because you are subscribed to the Google Groups 
"jackson-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jackson-user/3dd4b5a4-d63a-49f9-b6d4-d8ff7fcd688a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to