Vyacheslav Boyko created CAMEL-15841:
----------------------------------------
Summary: logging empties message body?
Key: CAMEL-15841
URL: https://issues.apache.org/jira/browse/CAMEL-15841
Project: Camel
Issue Type: Bug
Components: camel-core
Affects Versions: 3.5.0
Environment: my project is attached
Reporter: Vyacheslav Boyko
Attachments: egais-connector.7z
my build.gradle is
{code}
plugins {
id 'org.springframework.boot' version '2.3.5.RELEASE'
id 'io.spring.dependency-management' version '1.0.10.RELEASE'
id 'java'
}
group = 'com.bvn13'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
dependencies {
//implementation
'org.springframework.boot:spring-boot-starter-thymeleaf'
//implementation 'org.springframework.boot:spring-boot-starter-web'
implementation
'org.apache.camel.springboot:camel-spring-boot-starter:3.5.0'
implementation 'org.apache.camel:camel-http:3.5.0'
implementation 'org.apache.camel:camel-jetty:3.5.0'
implementation 'org.apache.camel:camel-gson:3.5.0'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
testImplementation('org.springframework.boot:spring-boot-starter-test')
{
exclude group: 'org.junit.vintage', module:
'junit-vintage-engine'
}
}
test {
useJUnitPlatform()
}
{code}
my route builder is:
{code:java}
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.model.dataformat.JsonLibrary;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@Component
public class EgaisExpirationDateSearcher extends RouteBuilder {
private final String host;
private final int port;
private final String searchEndpoint;
public EgaisExpirationDateSearcher(
@Value("${app.listen.host}") String host,
@Value("${app.listen.port}") int port) {
this.host = host;
this.port = port;
searchEndpoint = "jetty:http://"+host+":"+port+"/expire";
log.info("Listening at: {}", searchEndpoint);
}
@Override
public void configure() throws Exception {
from(searchEndpoint+"?httpMethodRestrict=POST")
.log("${body}") // <-----------------
.unmarshal().json(JsonLibrary.Gson, SearchRequest.class)
.log("${body}")
.process((exchange) -> {
exchange.getMessage().setBody("HI!");
})
;
}
}
{code}
my application properties are:
{code}
app:
listen:
host: localhost
port: 9091
{code}
I have an object as request body:
{code:java}
import lombok.Value;
@Value
public class SearchRequest {
String contraInn;
String alcoGoodName;
}
{code}
I perform POST HTTP request like
{code:bash}
curl -X POST -H "Content-Type: application/json" -d
'{"contraInn":123,"alcoGoodName":"name"}' http://localhost:9091/expire
{code}
now take a look at pointed line in route builder:
{code:java}
.log("${body}") // <-----------------
{code}
if I comment this line (disable logging) the log has following lines:
{code}
2020-11-10 22:07:52.172 INFO 1344 --- [ main]
c.b.b.e.EgaisConnectorApplication : Started EgaisConnectorApplication in
2.003 seconds (JVM running for 2.982)
2020-11-10 22:11:05.575 INFO 1344 --- [tp1753113235-31] route2
: com.bvn13.beerspot.egaisconnector.SearchRequest@2d34001a
{code}
but when I uncomment pointed line the body seems become empty right after
logging:
{code}
2020-11-10 22:12:40.284 INFO 10924 --- [ main]
c.b.b.e.EgaisConnectorApplication : Started EgaisConnectorApplication in
1.932 seconds (JVM running for 2.78)
2020-11-10 22:12:46.854 INFO 10924 --- [qtp216919586-31] route2
: {"contraInn":123,"alcoGoodName":"name"}
2020-11-10 22:12:46.857 INFO 10924 --- [qtp216919586-31] route2
: null
{code}
First log message is logged as arrived, then emptied (?), unmarshalled to null
and logged out as null.
Is it normal?
--
This message was sent by Atlassian Jira
(v8.3.4#803005)