Created
February 11, 2018 19:24
-
-
Save ItamarBenjamin/feb62ab96bda55555aa6c96dd545ddaf to your computer and use it in GitHub Desktop.
org.springframework.messaging.Message deserialization bug in spring-messaging:4.3.14.RELEASE
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
buildscript { | |
ext { | |
springBootVersion = '1.5.10.RELEASE' | |
} | |
repositories { | |
mavenCentral() | |
} | |
dependencies { | |
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") | |
} | |
} | |
apply plugin: 'java' | |
apply plugin: 'eclipse' | |
apply plugin: 'org.springframework.boot' | |
group = 'com.example' | |
version = '0.0.1-SNAPSHOT' | |
sourceCompatibility = 1.8 | |
repositories { | |
mavenCentral() | |
} | |
ext { | |
springCloudVersion = 'Edgware.SR2' | |
} | |
dependencies { | |
compile('org.springframework.cloud:spring-cloud-stream') | |
testCompile group: 'org.springframework.cloud', name: 'spring-cloud-stream-test-support' | |
} | |
dependencyManagement { | |
imports { | |
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}" | |
} | |
} | |
configurations.all { | |
resolutionStrategy { | |
dependencySubstitution { | |
// Uncomment to fix | |
// substitute module('org.springframework:spring-messaging') with module('org.springframework:spring-messaging:4.3.13.RELEASE') | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.demobug; | |
import org.springframework.boot.SpringApplication; | |
import org.springframework.boot.autoconfigure.SpringBootApplication; | |
import org.springframework.cloud.stream.annotation.EnableBinding; | |
import org.springframework.cloud.stream.annotation.StreamListener; | |
import org.springframework.cloud.stream.messaging.Processor; | |
import org.springframework.messaging.Message; | |
@SpringBootApplication | |
@EnableBinding(Processor.class) | |
public class DemoBugApplication { | |
public static void main(String[] args) { | |
SpringApplication.run(DemoBugApplication.class, args); | |
} | |
@StreamListener(value = Processor.INPUT) | |
public void process(Message<Foo> message) { | |
Foo msg = message.getPayload(); | |
System.out.println("Received Payload: " + msg.foo); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.demobug; | |
import org.junit.Test; | |
import org.junit.runner.RunWith; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.boot.test.context.SpringBootTest; | |
import org.springframework.cloud.stream.messaging.Processor; | |
import org.springframework.cloud.stream.test.binder.MessageCollector; | |
import org.springframework.messaging.Message; | |
import org.springframework.messaging.support.GenericMessage; | |
import org.springframework.test.context.junit4.SpringRunner; | |
import java.util.concurrent.BlockingQueue; | |
@RunWith(SpringRunner.class) | |
@SpringBootTest | |
public class DemoBugApplicationTests { | |
@Autowired | |
private Processor processor; | |
@Autowired | |
private MessageCollector collector; | |
@Test | |
public void contextLoads() { | |
this.processor.input().send(new GenericMessage<>("{\"foo\":\"bar\"}")); | |
BlockingQueue<Message<?>> messages = collector.forChannel(processor.output()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.demobug; | |
public class Foo { | |
public String getFoo() { | |
return foo; | |
} | |
public void setFoo(String foo) { | |
this.foo = foo; | |
} | |
public String foo; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment