Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix dependency conflict for ObjectMapper in PushEndpoint (#3137) (CP: 24.6) #3138

Merged
merged 4 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import java.util.Collections;
import java.util.List;

import com.fasterxml.jackson.databind.ObjectMapper;

import com.vaadin.hilla.EndpointProperties;
import org.atmosphere.client.TrackMessageSizeInterceptor;
import org.atmosphere.cpr.ApplicationConfig;
Expand All @@ -14,6 +16,7 @@
import org.atmosphere.interceptor.AtmosphereResourceLifecycleInterceptor;
import org.atmosphere.interceptor.SuspendTrackerInterceptor;
import org.atmosphere.util.SimpleBroadcaster;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.web.servlet.ServletContextInitializer;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
Expand Down Expand Up @@ -46,8 +49,10 @@ public PushConfigurer(EndpointProperties endpointProperties) {
}

@Bean
PushEndpoint pushEndpoint() {
return new PushEndpoint();
PushEndpoint pushEndpoint(
@Qualifier("hillaEndpointObjectMapper") ObjectMapper objectMapper,
PushMessageHandler pushMessageHandler) {
return new PushEndpoint(objectMapper, pushMessageHandler);
}

@Bean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import java.security.Principal;
import java.util.function.Consumer;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.atmosphere.cpr.AtmosphereRequest;
import org.atmosphere.cpr.AtmosphereResource;
import org.atmosphere.cpr.AtmosphereResourceEvent;
Expand All @@ -12,14 +14,11 @@
import org.atmosphere.util.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.context.SecurityContextImpl;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

import com.vaadin.hilla.push.messages.fromclient.AbstractServerMessage;
import com.vaadin.hilla.push.messages.toclient.AbstractClientMessage;

Expand All @@ -28,11 +27,15 @@
*/
public class PushEndpoint extends AtmosphereHandlerAdapter {

@Autowired
private ObjectMapper objectMapper;
@Autowired
private PushMessageHandler pushMessageHandler;

PushEndpoint(ObjectMapper objectMapper,
PushMessageHandler pushMessageHandler) {
this.objectMapper = objectMapper;
this.pushMessageHandler = pushMessageHandler;
}

@Override
public void onRequest(AtmosphereResource resource) throws IOException {
String method = resource.getRequest().getMethod();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package com.vaadin.hilla.test.reactgrid;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;

import com.vaadin.flow.component.page.AppShellConfigurator;
import com.vaadin.flow.theme.Theme;
Expand All @@ -13,4 +16,13 @@ public class Application implements AppShellConfigurator {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}

@Bean
@Primary
ObjectMapper myObjectMapper() {
// This is only to test that you can have a custom object mapper without
// causing problems for Hilla
return new ObjectMapper();
}

}
Loading