From 683ba1d9c1afea8920979bdcb298cf29885d2c6b Mon Sep 17 00:00:00 2001 From: knoobie Date: Tue, 16 May 2023 09:59:19 +0200 Subject: [PATCH] chore: replace logic to get production mode info --- flow-html-components/pom.xml | 5 ----- .../java/com/vaadin/flow/component/html/Label.java | 13 +++++++------ 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/flow-html-components/pom.xml b/flow-html-components/pom.xml index 4954c7b51c1..8f020194bf4 100644 --- a/flow-html-components/pom.xml +++ b/flow-html-components/pom.xml @@ -26,11 +26,6 @@ flow-data ${project.version} - - jakarta.servlet - jakarta.servlet-api - provided - jakarta.platform jakarta.jakartaee-web-api diff --git a/flow-html-components/src/main/java/com/vaadin/flow/component/html/Label.java b/flow-html-components/src/main/java/com/vaadin/flow/component/html/Label.java index d6b561eeae0..27a53d13ab4 100644 --- a/flow-html-components/src/main/java/com/vaadin/flow/component/html/Label.java +++ b/flow-html-components/src/main/java/com/vaadin/flow/component/html/Label.java @@ -24,6 +24,7 @@ import com.vaadin.flow.component.PropertyDescriptor; import com.vaadin.flow.component.PropertyDescriptors; import com.vaadin.flow.component.Tag; +import com.vaadin.flow.server.VaadinService; import com.vaadin.flow.shared.Registration; import org.slf4j.LoggerFactory; @@ -137,8 +138,7 @@ public Optional getFor() { @Override protected void onAttach(AttachEvent attachEvent) { super.onAttach(attachEvent); - if (skipForAttributeCheck(attachEvent) - || !attachEvent.isInitialAttach()) { + if (skipForAttributeCheck() || !attachEvent.isInitialAttach()) { return; // skip check in production so that customer / clients / // ops-teams are not complaining about this warning to the // devs. This should be dealt with by devs in development @@ -173,17 +173,18 @@ && getChildren().findAny().isEmpty()) { * @return true if in production mode or the mode is unclear, false if in * development mode **/ - private static boolean skipForAttributeCheck(AttachEvent attachEvent) { + private static boolean skipForAttributeCheck() { if (productionMode != null) { return productionMode; } - var session = attachEvent.getSession(); - if (session == null) { + var service = VaadinService.getCurrent(); + if (service == null) { return true; } - productionMode = session.getConfiguration().isProductionMode(); + productionMode = service.getDeploymentConfiguration() + .isProductionMode(); return productionMode; } }