ObjectMapper.writeValueAsString() taking too long to convert object to json on Jira server

Hi
We have common code base for our cloud and server addon. We have a rest api which returns list of objects which we convert to json using jackson ObjectMapper.
For server addon ObjectMapper takes 4-5 seconds to convert 50 records which is too much but for similar data on cloud addon conversion happens in 20-30 milliseconds.
What could be the reason?

Dependency added -

<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
		<dependency>
			<groupId>com.fasterxml.jackson.core</groupId>
			<artifactId>jackson-databind</artifactId>
			<version>2.8.8</version>
			<scope>provided</scope>
		</dependency>

Changing scope to compile also doesn’t work.

ObjectMapper configuration -

ObjectMapper objectMapper = new ObjectMapper();
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
objectMapper.setSerializationInclusion(Include.ALWAYS);
objectMapper.setTimeZone(TimeZone.getDefault());
1 Like

Hi @sagar - is it consistently 4-5 seconds for converting 50 records, even after JVM warmed up? On the machine you’re testig/profiling on, how much memory is available? Perhaps GC issues?

Hi @nmansilla, replying on behalf @sagar my co-worker, yes it is consistently 4-5 seconds and there is no memory or GC issues as far as we have observed on various systems.

Sorry @nmansilla, it was false alarm, some custom serializer for a class was taking time, it was nothing to do with ObjectMapper.

1 Like