Skip to content

Commit

Permalink
Merge branch 'refs/heads/grad-release'
Browse files Browse the repository at this point in the history
  • Loading branch information
chris.ditcher authored and chris.ditcher committed Nov 1, 2024
2 parents 54fbb76 + b464916 commit 6098c94
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@

import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;

@Component
public class JsonTransformer implements Transformer {

private static final Logger log = LoggerFactory.getLogger(JsonTransformer.class);
private static final String MARSHALLING_MSG = "Time taken for unmarshalling response from String to {} is {} ms";

final ObjectMapper objectMapper;

Expand All @@ -36,35 +36,6 @@ public Object unmarshall(byte[] input, Class<?> clazz) {
return result;
}

public Object unmarshallWithWrapper(String input, Class<?> clazz) {
final ObjectReader reader = objectMapper.readerFor(clazz);
Object result = null;
long start = System.currentTimeMillis();
try {
result = reader
.with(DeserializationFeature.UNWRAP_ROOT_VALUE)
.with(DeserializationFeature.USE_JAVA_ARRAY_FOR_JSON_ARRAY)
.readValue(input);
} catch (IOException e) {
log.error(e.getLocalizedMessage(), e);
}
log.debug("Time taken for unmarshalling response from String to {} is {} ms", clazz.getSimpleName(), (System.currentTimeMillis() - start));
return result;
}

public String marshallWithWrapper(Object input) {
ObjectWriter prettyPrinter = objectMapper.writer();
String result = null;
try {
result = prettyPrinter
.with(SerializationFeature.WRAP_ROOT_VALUE)
.writeValueAsString(input);
} catch (IOException e) {
log.error(e.getLocalizedMessage(), e);
}

return result;
}

@Override
public Object unmarshall(String input, Class<?> clazz) {
Expand All @@ -75,7 +46,7 @@ public Object unmarshall(String input, Class<?> clazz) {
} catch (IOException e) {
log.error(e.getLocalizedMessage(), e);
}
log.debug("Time taken for unmarshalling response from String to {} is {} ms", clazz.getName(), (System.currentTimeMillis() - start));
log.debug(MARSHALLING_MSG, clazz.getName(), (System.currentTimeMillis() - start));
return result;
}

Expand All @@ -88,7 +59,7 @@ public Object unmarshall(String input, TypeReference<?> valueTypeRef) {
} catch (IOException e) {
log.error(e.getLocalizedMessage(), e);
}
log.debug("Time taken for unmarshalling response from String to {} is {} ms", valueTypeRef.getType().getTypeName(), (System.currentTimeMillis() - start));
log.debug(MARSHALLING_MSG, valueTypeRef.getType().getTypeName(), (System.currentTimeMillis() - start));
return result;
}

Expand All @@ -107,17 +78,12 @@ public Object unmarshall(InputStream input, Class<?> clazz) {

@Override
public String marshall(Object input) {
ObjectWriter prettyPrinter = objectMapper.writerWithDefaultPrettyPrinter();
String result = null;
try {
result = prettyPrinter
.with(SerializationFeature.INDENT_OUTPUT)
.with(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS)
.writeValueAsString(input);
result = objectMapper.writeValueAsString(input);
} catch (IOException e) {
log.error(e.getLocalizedMessage(), e);
}

return result;
}

Expand Down
2 changes: 1 addition & 1 deletion tools/config/update-configmap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ FLB_CONFIG="[SERVICE]
Exclude_Path *.gz,*.zip
Parser docker
Mem_Buf_Limit 20MB
Buffer_Max_Size 1MB
Buffer_Max_Size 4MB
[FILTER]
Name record_modifier
Match *
Expand Down

0 comments on commit 6098c94

Please sign in to comment.