Skip to content

Commit 0bfadcd

Browse files
authored
fix!: Use dedicated mapping for Vaadin push endpoint (#15188)
Removes pushUrl configuration option, and instead maps push always to a dedicated path (/VAADIN/push). Related-to #14641
1 parent 448ed9b commit 0bfadcd

23 files changed

+62
-206
lines changed

flow-client/src/main/java/com/vaadin/client/communication/AtmospherePushConnection.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,15 @@ public AtmospherePushConnection(Registry registry) {
188188
}
189189

190190
});
191-
if (getPushConfiguration().getPushUrl() == null) {
192-
url = registry.getApplicationConfiguration().getServiceUrl();
193-
} else {
194-
url = getPushConfiguration().getPushUrl();
191+
url = getPushConfiguration().getPushUrl();
192+
// If a specific serviceUrl is defined, prepend pushUrl with it
193+
String serviceUrl = registry.getApplicationConfiguration()
194+
.getServiceUrl();
195+
if (!serviceUrl.equals(".")) {
196+
if (!serviceUrl.endsWith("/")) {
197+
serviceUrl += "/";
198+
}
199+
url = serviceUrl + url;
195200
}
196201
runWhenAtmosphereLoaded(
197202
() -> Scheduler.get().scheduleDeferred(this::connect));

flow-client/src/main/java/com/vaadin/client/communication/PushConfiguration.java

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import com.vaadin.client.flow.reactive.Reactive;
2626
import com.vaadin.flow.internal.nodefeature.NodeFeatures;
2727
import com.vaadin.flow.internal.nodefeature.PushConfigurationMap;
28+
import com.vaadin.flow.server.Constants;
2829

2930
/**
3031
* Provides the push configuration stored in the root node with an easier to use
@@ -88,19 +89,12 @@ private NodeMap getConfigurationMap() {
8889
}
8990

9091
/**
91-
* Gets the push URL configured on the server.
92+
* Gets the fixed push URL.
9293
*
93-
* @return the push URL configured on the server or null if none has been
94-
* configured
94+
* @return the fixed push URL (VAADIN/push)
9595
*/
9696
public String getPushUrl() {
97-
if (getConfigurationMap()
98-
.hasPropertyValue(PushConfigurationMap.PUSH_URL_KEY)) {
99-
return (String) getConfigurationMap()
100-
.getProperty(PushConfigurationMap.PUSH_URL_KEY).getValue();
101-
}
102-
103-
return null;
97+
return Constants.PUSH_MAPPING;
10498
}
10599

106100
/**

flow-server/src/main/java/com/vaadin/flow/component/PushConfiguration.java

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -138,27 +138,6 @@ public interface PushConfiguration extends Serializable {
138138
*/
139139
void setParameter(String parameter, String value);
140140

141-
/**
142-
* Sets the URL to use for push requests.
143-
* <p>
144-
* This is only used when overriding the URL to use. Setting this to null
145-
* (the default) will use the default URL.
146-
*
147-
* @param pushUrl
148-
* The push URL to use
149-
*/
150-
void setPushUrl(String pushUrl);
151-
152-
/**
153-
* Returns the URL to use for push requests.
154-
* <p>
155-
* This is only used when overriding the URL to use. Returns null (the
156-
* default) when the default URL is used.
157-
*
158-
* @return the URL to use for push requests, or null to use to default
159-
*/
160-
String getPushUrl();
161-
162141
/**
163142
* Sets the factory that will be used to create new instances of
164143
* {@link PushConnection}.
@@ -235,16 +214,6 @@ public void setPushMode(PushMode pushMode) {
235214
}
236215
}
237216

238-
@Override
239-
public void setPushUrl(String pushUrl) {
240-
getPushConfigurationMap().setPushUrl(pushUrl);
241-
}
242-
243-
@Override
244-
public String getPushUrl() {
245-
return getPushConfigurationMap().getPushUrl();
246-
}
247-
248217
@Override
249218
public Transport getTransport() {
250219
return getPushConfigurationMap().getTransport();

flow-server/src/main/java/com/vaadin/flow/function/DeploymentConfiguration.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,6 @@ public interface DeploymentConfiguration
123123
*/
124124
PushMode getPushMode();
125125

126-
/**
127-
* Returns the URL that bidirectional ("push") client-server communication
128-
* should use.
129-
*
130-
* @return The push URL to use
131-
*/
132-
String getPushURL();
133-
134126
/**
135127
* Gets the properties configured for the deployment, e.g. as init
136128
* parameters to the servlet.

flow-server/src/main/java/com/vaadin/flow/internal/BootstrapHandlerHelper.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import java.io.Serializable;
1919

20+
import com.vaadin.flow.server.Constants;
2021
import com.vaadin.flow.server.HandlerHelper;
2122
import com.vaadin.flow.server.VaadinRequest;
2223
import com.vaadin.flow.server.VaadinSession;
@@ -66,12 +67,8 @@ public static String getServiceUrl(VaadinRequest vaadinRequest) {
6667
*/
6768
public static String getPushURL(VaadinSession vaadinSession,
6869
VaadinRequest vaadinRequest) {
69-
String serviceUrl = getServiceUrl(vaadinRequest);
70+
String pushURL = Constants.PUSH_MAPPING;
7071

71-
String pushURL = vaadinSession.getConfiguration().getPushURL();
72-
if (pushURL == null) {
73-
pushURL = serviceUrl;
74-
}
7572
String contextPath = vaadinRequest.getService()
7673
.getContextRootRelativePath(vaadinRequest);
7774

flow-server/src/main/java/com/vaadin/flow/internal/nodefeature/PushConfigurationMap.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ public PushConfigurationParametersMap(StateNode node) {
5858
public static final String FALLBACK_TRANSPORT_KEY = "fallbackTransport";
5959
public static final String PUSHMODE_KEY = "pushMode";
6060
public static final String ALWAYS_USE_XHR_TO_SERVER = "alwaysXhrToServer";
61-
public static final String PUSH_URL_KEY = "pushUrl";
6261
public static final String PARAMETERS_KEY = "parameters";
6362

6463
/**
@@ -138,16 +137,6 @@ public PushMode getPushMode() {
138137
return PushMode.valueOf(get(PUSHMODE_KEY).toString());
139138
}
140139

141-
@Override
142-
public void setPushUrl(String pushUrl) {
143-
put(PUSH_URL_KEY, pushUrl);
144-
}
145-
146-
@Override
147-
public String getPushUrl() {
148-
return getOrDefault(PUSH_URL_KEY, null);
149-
}
150-
151140
@Override
152141
public String getParameter(String key) {
153142
return (String) getParameters().get(key);

flow-server/src/main/java/com/vaadin/flow/server/BootstrapHandler.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1525,7 +1525,6 @@ protected BootstrapContext createAndInitUI(Class<? extends UI> uiClass,
15251525
.orElseGet(deploymentConfiguration::getPushMode);
15261526
setupPushConnectionFactory(pushConfiguration, context);
15271527
pushConfiguration.setPushMode(pushMode);
1528-
pushConfiguration.setPushUrl(deploymentConfiguration.getPushURL());
15291528
push.map(Push::transport).ifPresent(pushConfiguration::setTransport);
15301529

15311530
// Set thread local here so it is available in init

flow-server/src/main/java/com/vaadin/flow/server/Constants.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,6 @@ public final class Constants implements Serializable {
130130
@Deprecated
131131
public static final String SERVLET_PARAMETER_PUSH_MODE = InitParameters.SERVLET_PARAMETER_PUSH_MODE;
132132

133-
/**
134-
* @deprecated Use {@link InitParameters#SERVLET_PARAMETER_PUSH_URL}
135-
* instead.
136-
*/
137-
@Deprecated
138-
public static final String SERVLET_PARAMETER_PUSH_URL = InitParameters.SERVLET_PARAMETER_PUSH_URL;
139-
140133
/**
141134
* @deprecated Use {@link InitParameters#SERVLET_PARAMETER_SYNC_ID_CHECK}
142135
* instead.
@@ -372,6 +365,11 @@ public final class Constants implements Serializable {
372365
*/
373366
public static final String VAADIN_MAPPING = "VAADIN/";
374367

368+
/**
369+
* The path used in the vaadin servlet for handling push.
370+
*/
371+
public static final String PUSH_MAPPING = VAADIN_MAPPING + "push";
372+
375373
/**
376374
* The static build resources folder.
377375
*/

flow-server/src/main/java/com/vaadin/flow/server/DefaultDeploymentConfiguration.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ public class DefaultDeploymentConfiguration
9292
private int webComponentDisconnect;
9393
private boolean closeIdleSessions;
9494
private PushMode pushMode;
95-
private String pushURL;
9695
private boolean syncIdCheck;
9796
private boolean sendUrlsAsParameters;
9897
private boolean requestTiming;
@@ -129,7 +128,6 @@ public DefaultDeploymentConfiguration(ApplicationConfiguration parentConfig,
129128
checkWebComponentDisconnectTimeout();
130129
checkCloseIdleSessions();
131130
checkPushMode();
132-
checkPushURL();
133131
checkSyncIdCheck();
134132
checkSendUrlsAsParameters();
135133

@@ -257,16 +255,6 @@ public PushMode getPushMode() {
257255
return pushMode;
258256
}
259257

260-
/**
261-
* {@inheritDoc}
262-
* <p>
263-
* The default mode is <code>""</code> which uses the servlet URL.
264-
*/
265-
@Override
266-
public String getPushURL() {
267-
return pushURL;
268-
}
269-
270258
/**
271259
* Log a warning if Vaadin is not running in production mode.
272260
*/
@@ -404,11 +392,6 @@ private void checkPushMode() {
404392
}
405393
}
406394

407-
private void checkPushURL() {
408-
pushURL = getStringProperty(InitParameters.SERVLET_PARAMETER_PUSH_URL,
409-
"");
410-
}
411-
412395
private void checkSyncIdCheck() {
413396
syncIdCheck = getBooleanProperty(
414397
InitParameters.SERVLET_PARAMETER_SYNC_ID_CHECK,

flow-server/src/main/java/com/vaadin/flow/server/InitParameters.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ public class InitParameters implements Serializable {
5656
public static final String SERVLET_PARAMETER_WEB_COMPONENT_DISCONNECT = "webComponentDisconnect";
5757
public static final String SERVLET_PARAMETER_CLOSE_IDLE_SESSIONS = "closeIdleSessions";
5858
public static final String SERVLET_PARAMETER_PUSH_MODE = "pushMode";
59-
public static final String SERVLET_PARAMETER_PUSH_URL = "pushURL";
6059
public static final String SERVLET_PARAMETER_SYNC_ID_CHECK = "syncIdCheck";
6160
public static final String SERVLET_PARAMETER_SEND_URLS_AS_PARAMETERS = "sendUrlsAsParameters";
6261
public static final String SERVLET_PARAMETER_PUSH_SUSPEND_TIMEOUT_LONGPOLLING = "pushLongPollingSuspendTimeout";

0 commit comments

Comments
 (0)