aboutsummaryrefslogtreecommitdiffstats
path: root/server/src
diff options
context:
space:
mode:
Diffstat (limited to 'server/src')
-rw-r--r--server/src/main/java/com/vaadin/ui/TreeGrid.java45
-rw-r--r--server/src/main/java/com/vaadin/ui/UI.java37
-rw-r--r--server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerGradient.java11
-rw-r--r--server/src/test/java/com/vaadin/server/communication/ServletUIInitHandlerTest.java9
-rw-r--r--server/src/test/java/com/vaadin/ui/UITest.java56
5 files changed, 62 insertions, 96 deletions
diff --git a/server/src/main/java/com/vaadin/ui/TreeGrid.java b/server/src/main/java/com/vaadin/ui/TreeGrid.java
index 8ee154a56e..24c55fce2b 100644
--- a/server/src/main/java/com/vaadin/ui/TreeGrid.java
+++ b/server/src/main/java/com/vaadin/ui/TreeGrid.java
@@ -121,36 +121,27 @@ public class TreeGrid<T> extends Grid<T>
HierarchicalDataCommunicator<T> dataCommunicator) {
super(propertySet, dataCommunicator);
- registerRpc(new NodeCollapseRpc() {
- @Override
- public void setNodeCollapsed(String rowKey, int rowIndex,
- boolean collapse, boolean userOriginated) {
- T item = getDataCommunicator().getKeyMapper().get(rowKey);
- if (collapse && getDataCommunicator().isExpanded(item)) {
- getDataCommunicator().doCollapse(item,
- Optional.of(rowIndex));
- fireCollapseEvent(
- getDataCommunicator().getKeyMapper().get(rowKey),
- userOriginated);
- } else if (!collapse
- && !getDataCommunicator().isExpanded(item)) {
- getDataCommunicator().doExpand(item, Optional.of(rowIndex));
- fireExpandEvent(
- getDataCommunicator().getKeyMapper().get(rowKey),
- userOriginated);
- }
+ registerRpc((NodeCollapseRpc) (rowKey, rowIndex, collapse,
+ userOriginated) -> {
+ T item = getDataCommunicator().getKeyMapper().get(rowKey);
+ if (collapse && getDataCommunicator().isExpanded(item)) {
+ getDataCommunicator().doCollapse(item, Optional.of(rowIndex));
+ fireCollapseEvent(
+ getDataCommunicator().getKeyMapper().get(rowKey),
+ userOriginated);
+ } else if (!collapse && !getDataCommunicator().isExpanded(item)) {
+ getDataCommunicator().doExpand(item, Optional.of(rowIndex));
+ fireExpandEvent(
+ getDataCommunicator().getKeyMapper().get(rowKey),
+ userOriginated);
}
});
- registerRpc(new FocusParentRpc() {
- @Override
- public void focusParent(String rowKey, int cellIndex) {
- Integer parentIndex = getDataCommunicator().getParentIndex(
- getDataCommunicator().getKeyMapper().get(rowKey));
- if (parentIndex != null) {
- getRpcProxy(FocusRpc.class).focusCell(parentIndex,
- cellIndex);
- }
+ registerRpc((FocusParentRpc) (rowKey, cellIndex) -> {
+ Integer parentIndex = getDataCommunicator().getParentIndex(
+ getDataCommunicator().getKeyMapper().get(rowKey));
+ if (parentIndex != null) {
+ getRpcProxy(FocusRpc.class).focusCell(parentIndex, cellIndex);
}
});
}
diff --git a/server/src/main/java/com/vaadin/ui/UI.java b/server/src/main/java/com/vaadin/ui/UI.java
index 13adb68817..0fb1e8e3a3 100644
--- a/server/src/main/java/com/vaadin/ui/UI.java
+++ b/server/src/main/java/com/vaadin/ui/UI.java
@@ -260,18 +260,14 @@ public abstract class UI extends AbstractSingleComponentContainer
}
};
- private WindowOrderRpc windowOrderRpc = new WindowOrderRpc() {
-
- @Override
- public void windowOrderChanged(Map<Integer, Connector> windowOrders) {
- Map<Integer, Window> orders = new LinkedHashMap<>();
- for (Entry<Integer, Connector> entry : windowOrders.entrySet()) {
- if (entry.getValue() instanceof Window) {
- orders.put(entry.getKey(), (Window) entry.getValue());
- }
+ private WindowOrderRpc windowOrderRpc = windowOrders -> {
+ Map<Integer, Window> orders = new LinkedHashMap<>();
+ for (Entry<Integer, Connector> entry : windowOrders.entrySet()) {
+ if (entry.getValue() instanceof Window) {
+ orders.put(entry.getKey(), (Window) entry.getValue());
}
- fireWindowOrder(orders);
}
+ fireWindowOrder(orders);
};
/**
@@ -518,18 +514,15 @@ public abstract class UI extends AbstractSingleComponentContainer
// on.
getPushConfiguration().setPushMode(PushMode.DISABLED);
- new Thread(new Runnable() {
- @Override
- public void run() {
- // This intentionally does disconnect without locking
- // the VaadinSession to avoid deadlocks where the server
- // uses a lock for the websocket connection
-
- // See https://dev.vaadin.com/ticket/18436
- // The underlying problem is
- // https://dev.vaadin.com/ticket/16919
- setPushConnection(null);
- }
+ new Thread(() -> {
+ // This intentionally does disconnect without locking
+ // the VaadinSession to avoid deadlocks where the server
+ // uses a lock for the websocket connection
+
+ // See https://dev.vaadin.com/ticket/18436
+ // The underlying problem is
+ // https://dev.vaadin.com/ticket/16919
+ setPushConnection(null);
}).start();
}
this.session = session;
diff --git a/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerGradient.java b/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerGradient.java
index bc92a755a4..c07d17d41f 100644
--- a/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerGradient.java
+++ b/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerGradient.java
@@ -30,20 +30,15 @@ import com.vaadin.ui.AbstractField;
*/
public class ColorPickerGradient extends AbstractField<Color> {
- private ColorPickerGradientServerRpc rpc = new ColorPickerGradientServerRpc() {
-
- @Override
- public void select(int cursorX, int cursorY) {
- setValue(converter.calculate(cursorX, cursorY), true);
- }
- };
-
/** The converter. */
private Coordinates2Color converter;
/** The foreground color. */
private Color color;
+ private ColorPickerGradientServerRpc rpc = (cursorX,
+ cursorY) -> setValue(converter.calculate(cursorX, cursorY), true);
+
private ColorPickerGradient() {
registerRpc(rpc);
// width and height must be set here instead of in theme, otherwise
diff --git a/server/src/test/java/com/vaadin/server/communication/ServletUIInitHandlerTest.java b/server/src/test/java/com/vaadin/server/communication/ServletUIInitHandlerTest.java
index 6ded996687..617fe6be63 100644
--- a/server/src/test/java/com/vaadin/server/communication/ServletUIInitHandlerTest.java
+++ b/server/src/test/java/com/vaadin/server/communication/ServletUIInitHandlerTest.java
@@ -30,8 +30,6 @@ import org.junit.Test;
import org.mockito.Mockito;
import com.vaadin.server.DefaultDeploymentConfiguration;
-import com.vaadin.server.ErrorEvent;
-import com.vaadin.server.ErrorHandler;
import com.vaadin.server.LegacyCommunicationManager;
import com.vaadin.server.MockServletConfig;
import com.vaadin.server.UIClassSelectionEvent;
@@ -121,12 +119,7 @@ public class ServletUIInitHandlerTest {
}
};
- ui.setErrorHandler(new ErrorHandler() {
- @Override
- public void error(ErrorEvent event) {
- errorHandlerCalls.incrementAndGet();
- }
- });
+ ui.setErrorHandler(event -> errorHandlerCalls.incrementAndGet());
CommunicationMock mock = new CommunicationMock(ui);
VaadinRequest initRequest = mock.createInitRequest();
diff --git a/server/src/test/java/com/vaadin/ui/UITest.java b/server/src/test/java/com/vaadin/ui/UITest.java
index 886dd38087..ff9062ea0a 100644
--- a/server/src/test/java/com/vaadin/ui/UITest.java
+++ b/server/src/test/java/com/vaadin/ui/UITest.java
@@ -87,41 +87,35 @@ public class UITest {
final ConcurrentLinkedQueue<Exception> exceptions = new ConcurrentLinkedQueue<Exception>();
// Simulates the websocket close thread
- Runnable websocketClose = new Runnable() {
- @Override
- public void run() {
- externalLock.lock();
- // Wait for disconnect thread to lock VaadinSession
- websocketReachedCheckpoint.countDown();
- try {
- uiDisconnectReachedCheckpoint.await();
- } catch (InterruptedException e) {
- e.printStackTrace();
- exceptions.add(e);
- return;
- }
- uiSession.lock();
- externalLock.unlock();
+ Runnable websocketClose = () -> {
+ externalLock.lock();
+ // Wait for disconnect thread to lock VaadinSession
+ websocketReachedCheckpoint.countDown();
+ try {
+ uiDisconnectReachedCheckpoint.await();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ exceptions.add(e);
+ return;
}
+ uiSession.lock();
+ externalLock.unlock();
};
- Runnable disconnectPushFromUI = new Runnable() {
- @Override
- public void run() {
- uiSession.lock();
- // Wait for websocket thread to lock external lock
- uiDisconnectReachedCheckpoint.countDown();
- try {
- websocketReachedCheckpoint.await();
- } catch (InterruptedException e) {
- e.printStackTrace();
- exceptions.add(e);
- return;
- }
-
- ui.setSession(null);
- uiSession.unlock();
+ Runnable disconnectPushFromUI = () -> {
+ uiSession.lock();
+ // Wait for websocket thread to lock external lock
+ uiDisconnectReachedCheckpoint.countDown();
+ try {
+ websocketReachedCheckpoint.await();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ exceptions.add(e);
+ return;
}
+
+ ui.setSession(null);
+ uiSession.unlock();
};
Thread websocketThread = new Thread(websocketClose);