Skip to content

Commit

Permalink
Merge branch 'master' into issues/close_opened_streams
Browse files Browse the repository at this point in the history
  • Loading branch information
caalador committed Dec 10, 2021
2 parents 287e907 + 5ec8ddd commit b197b5c
Show file tree
Hide file tree
Showing 12 changed files with 207 additions and 39 deletions.
35 changes: 35 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
name: Bug report
about: Issues for Flow related problems
title: ''
labels: ''
assignees: ''

---

<!--
Please READ these instructions & USE the issue template below, Thank You!
For general support from the community, use https://stackoverflow.com/questions/tagged/vaadin (or tag vaadin-flow) or Vaadin discord chat https://discord.gg/MYFq5RTbBn instead.
NOTE: Issues concerning UI components (e.g. Button, Grid, TextField, ...) should go to the components repository https://github.com/vaadin/flow-components
NOTE: Issues concerning Vaadin Fusion should go to the Fusion repository https://github.com/vaadin/fusion
Good quality bug report increases the likelihood to get the bug fixed. A bad quality one will likely be just closed. Please use the following template to report bugs.
-->
### Description of the bug
<!-- Explain briefly what is broken -->
### Minimal reproducible example
<!-- What are the steps to reproduce the issue, example project or a code snippet without dependencies -->
### Expected behavior
<!-- What should happen -->
### Actual behavior
<!-- What actually happens, attach server/browser logs when there are errors/exceptions -->
### Versions:
- Vaadin / Flow version:
- Java version:
- OS version:
- Browser version (if applicable):
- Application Server (if applicable):
- IDE (if applicable):
24 changes: 24 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
name: Feature request
about: Request for a new feature to Flow
title: ''
labels: enhancement
assignees: ''

---

### Describe your motivation

A concise description of why you are proposing a change. For example, you would like a new feature to solve a use-case, or you want an existing feature changed because it is difficult to use.

### Describe the solution you'd like

Provide a clear and concise description of what you want to happen.

### Describe alternatives you've considered

Provide information about other solutions you've tried or researched.

### Additional context

Is there anything else you can add about the proposal?
39 changes: 39 additions & 0 deletions .github/ISSUE_TEMPLATE/vite-bug-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
name: Vite bug report
about: Issues about the Vite support in Vaadin 22+
title: ''
labels: vite
assignees: ''

---

<!--
Please READ these instructions & USE the issue template below, Thank You!
Vite is only available in Vaadin 22+ projects
For general support from the community, use https://stackoverflow.com/questions/tagged/vaadin (or tag vaadin-flow) or Vaadin discord chat https://discord.gg/MYFq5RTbBn instead.
NOTE: Issues concerning UI components (e.g. Button, Grid, TextField, ...) should go to the components repository https://github.com/vaadin/flow-components .
NOTE: Issues concerning Vaadin Fusion should go to the Fusion repository https://github.com/vaadin/fusion
Good quality bug report increases the likelihood to get the bug fixed. A bad quality one will likely be just closed. Please use the following template to report bugs.
-->
### Description of the bug
<!-- Explain briefly what is broken -->
### Minimal reproducible example
<!-- What are the steps to reproduce the issue, example project or a code snippet without dependencies -->
### Expected behavior
<!-- What should happen -->
### Actual behavior
<!-- What actually happens, attach server/browser logs when there are errors/exceptions -->
### Versions:
- Vaadin / Flow version:
- Java version:
- OS version:
- Browser version (if applicable):
- Application Server (if applicable):
- IDE (if applicable):
- Development or production mode:
- Project from start.vaadin.com or activated in application:
63 changes: 37 additions & 26 deletions flow-plugins/flow-gradle-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
central repo is done within platform final releases.
</description>

<properties>
<gradle.executable>./gradlew</gradle.executable>
</properties>

<dependencies>
<dependency>
<groupId>com.vaadin</groupId>
Expand Down Expand Up @@ -51,40 +55,34 @@
</execution>
</executions>
</plugin>
<!-- run gradle tasks -->

<!-- execute Gradle command -->
<plugin>
<groupId>codes.rafael.gradlemavenplugin</groupId>
<artifactId>gradle-maven-plugin</artifactId>
<version>1.0.10</version>
<configuration>
<gradleVersion>7.3</gradleVersion>
<tasks>
<task>clean</task>
<task>build</task>
<task>javadocJar</task>
</tasks>
<args>
<arg>-x</arg>
<arg>functionalTest</arg>
<arg>-S</arg>
</args>
</configuration>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>gradle</id>
<phase>prepare-package</phase>
<configuration>
<executable>${gradle.executable}</executable>
<arguments>
<argument>clean</argument>
<argument>build</argument>
<argument>javadocJar</argument>
<argument>-x</argument>
<argument>functionalTest</argument>
<argument>-S</argument>
</arguments>
</configuration>
<goals>
<goal>invoke</goal>
<goal>exec</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.gradle</groupId>
<artifactId>gradle-tooling-api</artifactId>
<version>7.3-20210825160000+0000</version>
</dependency>
</dependencies>
</plugin>

<!-- copy generated JARs -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
Expand Down Expand Up @@ -140,7 +138,20 @@
</execution>
</executions>
</plugin>

</plugins>
</build>

<profiles>
<profile>
<id>windows_profile</id>
<activation>
<os>
<family>Windows</family>
</os>
</activation>
<properties>
<gradle.executable>gradlew.bat</gradle.executable>
</properties>
</profile>
</profiles>
</project>
2 changes: 1 addition & 1 deletion flow-plugins/flow-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
<dependency>
<groupId>nl.jqno.equalsverifier</groupId>
<artifactId>equalsverifier</artifactId>
<version>3.7.2</version>
<version>3.8</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
20 changes: 18 additions & 2 deletions flow-server/src/main/java/com/vaadin/flow/component/UI.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.util.Objects;
import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.regex.Pattern;

Expand Down Expand Up @@ -527,9 +528,24 @@ public void handleError(Exception exception) {
if (command instanceof ErrorHandlingCommand) {
ErrorHandlingCommand errorHandlingCommand = (ErrorHandlingCommand) command;
errorHandlingCommand.handleError(exception);
} else {
} else if (getSession() != null) {
getSession().getErrorHandler()
.error(new ErrorEvent(exception));
} else {
/*
* The session has expired after `ui.access` was called.
* It makes no sense to pollute the logs with a
* UIDetachedException at this point.
*/
if (exception instanceof ExecutionException
&& ((ExecutionException) exception)
.getCause() instanceof UIDetachedException) {
getLogger().debug(exception.getMessage(),
exception);
} else {
getLogger().error(exception.getMessage(),
exception);
}
}
} catch (Exception e) {
getLogger().error(e.getMessage(), e);
Expand Down Expand Up @@ -708,7 +724,7 @@ public ReconnectDialogConfiguration getReconnectDialogConfiguration() {
return getNode().getFeature(ReconnectDialogConfigurationMap.class);
}

private static Logger getLogger() {
Logger getLogger() {
return LoggerFactory.getLogger(UI.class.getName());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class DefaultDeploymentConfiguration

public static final String NOT_PRODUCTION_MODE_WARNING = "\nWARNING: Vaadin is running in DEBUG MODE with debug features enabled, but with a prebuild frontend bundle (production ready).\n"
+ "When deploying application for production, disable debug features by enabling production mode!\n"
+ "See more from https://vaadin.com/docs/v14/flow/production/tutorial-production-mode-basic.html";
+ "See more from https://vaadin.com/docs/latest/flow/production/overview";

public static final String WARNING_V14_BOOTSTRAP = "Using deprecated Vaadin 14 bootstrap mode.\n"
+ "Client-side views written in TypeScript are not supported. Vaadin 15+ enables client-side and server-side views.\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ Map<String, String> getDefaultDevDependencies() {

defaults.put("typescript", "4.4.3");

final String WORKBOX_VERSION = "6.2.0";
final String WORKBOX_VERSION = "6.4.2";

if (featureFlags.isEnabled(FeatureFlags.VITE)) {
defaults.put("vite", "v2.7.0");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
public class AbstractConfigurationFactory implements Serializable {

public static final String DEV_FOLDER_MISSING_MESSAGE = "Running project in development mode with no access to folder '%s'.%n"
+ "Build project in production mode instead, see https://vaadin.com/docs/v15/flow/production/tutorial-production-mode-basic.html";
+ "Build project in production mode instead, see https://vaadin.com/docs/latest/flow/production/overview";

/**
* Returns the config parameters from the token file data {@code buildInfo}.
Expand Down
44 changes: 43 additions & 1 deletion flow-server/src/test/java/com/vaadin/flow/component/UITest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

package com.vaadin.flow.component;

import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
Expand All @@ -24,14 +27,19 @@
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;

import org.apache.commons.io.IOUtils;
import org.hamcrest.CoreMatchers;
import org.hamcrest.MatcherAssert;
import org.junit.After;
import org.junit.Assert;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.ArgumentMatchers;
import org.mockito.MockedStatic;
import org.mockito.Mockito;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.impl.SimpleLogger;

import com.vaadin.flow.component.internal.PendingJavaScriptInvocation;
import com.vaadin.flow.component.page.History;
Expand Down Expand Up @@ -80,6 +88,7 @@
import com.vaadin.flow.server.VaadinResponse;
import com.vaadin.flow.server.VaadinService;
import com.vaadin.flow.server.VaadinServletRequest;
import com.vaadin.flow.server.frontend.MockLogger;
import com.vaadin.flow.shared.Registration;
import com.vaadin.tests.util.AlwaysLockedVaadinSession;
import com.vaadin.tests.util.MockUI;
Expand All @@ -88,6 +97,7 @@
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mockStatic;

public class UITest {

Expand Down Expand Up @@ -183,11 +193,17 @@ public void elementIsBody() {
}

private static UI createTestUI() {
MockLogger mockLogger = new MockLogger();
UI ui = new UI() {
@Override
public void doInit(VaadinRequest request, int uiId) {

}

@Override
Logger getLogger() {
return mockLogger;
}
};

return ui;
Expand Down Expand Up @@ -514,7 +530,7 @@ public void unsetSession_detachEventIsFiredForUIChildren()
}

@Test
public void unserSession_datachEventIsFiredForElements() {
public void unsetSession_detachEventIsFiredForElements() {
UI ui = createTestUI();

List<ElementDetachEvent> events = new ArrayList<>();
Expand All @@ -536,6 +552,32 @@ public void unserSession_datachEventIsFiredForElements() {
assertEquals(ui.getElement(), events.get(1).getSource());
}

@Test
public void unsetSession_accessErrorHandlerStillWorks() throws IOException {
UI ui = createTestUI();
initUI(ui, "", null);

ui.getSession().access(() -> ui.getInternals().setSession(null));
ui.access(() -> {
Assert.fail("We should never get here because the UI is detached");
});

// Unlock to run pending access tasks
ui.getSession().unlock();

String logOutput = ((MockLogger) ui.getLogger()).getLogs();
String logOutputNoDebug = logOutput.replaceAll("^\\[Debug\\].*", "");

Assert.assertFalse(
"No NullPointerException should be logged but got: "
+ logOutput,
logOutput.contains("NullPointerException"));
Assert.assertFalse(
"No UIDetachedException should be logged but got: "
+ logOutputNoDebug,
logOutputNoDebug.contains("UIDetachedException"));
}

@Test
public void beforeClientResponse_regularOrder() {
UI ui = createTestUI();
Expand Down
2 changes: 1 addition & 1 deletion fusion-endpoint/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-el</artifactId>
<version>9.0.55</version>
<version>9.0.56</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Loading

0 comments on commit b197b5c

Please sign in to comment.