Skip to content

Commit

Permalink
Merge branch '2.2.x' into 2.3.x
Browse files Browse the repository at this point in the history
Closes gh-21786
  • Loading branch information
wilkinsona committed Jun 9, 2020
2 parents e9f6dc9 + a0f29ed commit 8155cc5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -20,13 +20,15 @@

import com.fasterxml.jackson.databind.ObjectMapper;

import org.springframework.boot.LazyInitializationExcludeFilter;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type;
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.converter.ByteArrayMessageConverter;
import org.springframework.messaging.converter.DefaultContentTypeResolver;
Expand Down Expand Up @@ -74,6 +76,11 @@ public boolean configureMessageConverters(List<MessageConverter> messageConverte
return false;
}

@Bean
static LazyInitializationExcludeFilter eagerStompWebSocketHandlerMapping() {
return (name, definition, type) -> name.equals("stompWebSocketHandlerMapping");
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import org.springframework.boot.LazyInitializationBeanFactoryPostProcessor;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
import org.springframework.boot.autoconfigure.web.servlet.DispatcherServletAutoConfiguration;
Expand Down Expand Up @@ -110,6 +111,13 @@ void basicMessagingWithStringResponse() throws Throwable {
assertThat(new String((byte[]) result)).isEqualTo("string data");
}

@Test
void whenLazyInitializationIsEnabledThenBasicMessagingWorks() throws Throwable {
this.context.register(LazyInitializationBeanFactoryPostProcessor.class);
Object result = performStompSubscription("/app/string");
assertThat(new String((byte[]) result)).isEqualTo("string data");
}

@Test
void customizedConverterTypesMatchDefaultConverterTypes() {
List<MessageConverter> customizedConverters = getCustomizedConverters();
Expand Down Expand Up @@ -192,7 +200,7 @@ public void handleTransportError(StompSession session, Throwable exception) {
stompClient.connect("ws://localhost:{port}/messaging", handler,
this.context.getEnvironment().getProperty("local.server.port"));

if (!latch.await(30000, TimeUnit.SECONDS)) {
if (!latch.await(30, TimeUnit.SECONDS)) {
if (failure.get() != null) {
throw failure.get();
}
Expand Down

0 comments on commit 8155cc5

Please sign in to comment.