vaadin / flow

Vaadin Flow is a Java framework binding Vaadin web components to Java. This is part of Vaadin 10+.
Apache License 2.0
609 stars 167 forks source link

Hotswap reloads every time IntelliJ is defocused #19971

Closed jojule closed 1 week ago

jojule commented 1 week ago

Description of the bug

Every time I change window focus from IntelliJ to anything else (for example the browser running my application), hotswap reload is triggered. Even if I have not made any changes.

For me it looks like this

HOTSWAP AGENT: 18:40:42.412 WARNING (org.hotswap.agent.watch.nio.WatcherNIO2) - Watcher on /Users/phoenix/Downloads/my-app/target/classes/com/example/application/services not valid, removing path=
HOTSWAP AGENT: 18:40:42.587 INFO (org.hotswap.agent.plugin.spring.reload.SpringBeanReload) - try to add changed property 'file:/Users/phoenix/Downloads/my-app/target/classes/application.properties' into org.springframework.beans.factory.support.DefaultListableBeanFactory@7048535f
HOTSWAP AGENT: 18:40:43.374 INFO (org.hotswap.agent.plugin.jackson.JacksonPlugin) - Reloaded Jackson.
HOTSWAP AGENT: 18:40:44.097 RELOAD (org.hotswap.agent.plugin.spring.reload.SpringBeanReload) - the properties of 'org.springframework.beans.factory.support.DefaultListableBeanFactory@7048535f' is changed
HOTSWAP AGENT: 18:40:44.103 ERROR (org.hotswap.agent.plugin.spring.reload.XmlsChangedCommand) - Error invoking method
java.lang.reflect.InvocationTargetException
    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:118)
    at java.base/java.lang.reflect.Method.invoke(Method.java:580)
    at org.hotswap.agent.plugin.spring.reload.SpringChangedReloadCommand.executeCommand(SpringChangedReloadCommand.java:54)
    at org.hotswap.agent.command.impl.CommandExecutor.run(CommandExecutor.java:43)
}}${_p9k__e::=${${_p9k__1ldir+00}:-${${(%):-$_p9k__c%1(l.1.0)}[-1]}1}}}+}${${_p9k__e:#00}:+${${_p9k_t[$_p9k__n]/<_p9k__ss>/$_p9k__ss}/<_p9k__s>/$_p9k__s}${_p9k__v}${${(M)_p9k__e:#11}:+ }${_p9k__c}%b%K{234\}%F{031\} ${${:-${_p9k__s::=%F{234\}}${_p9k__ss::=%242F}${_p9k__sss::=%F{234\}}${_p9k__i::=2}${_p9k__bg::=234}}+}}${(e)_p9k__vcs}%b%k$_p9k__sss%b%k%f${:-" %b%k%f"}}}}+}${(e)_p9k_t[6]}${${_p9k__h::=95.5}+}${${_p9k__d::=$((_p9k__m-_p9k__h))}+}${_p9k__lprompt/\%\{d\%\}*\%\{d\%\}/${_p9k__1ldir-${:-"%B%F{039}"}${(Q)${:-"\\~"}}${:-"%b%K{234}%F{031}"}/${${${_p9k__d:#-*}:+Downloads}:-${:-"%F{103}"}Dow${:-"%b%K{234}%F{031}"}${$((_p9k__d+=6))+}}/${:-"%B%F{039}"}my-app${:-"%b%K{234}%F{031}"}}}${${_p9k__m::=$((_p9k__d+_p9k__h))}+}}${${COLUMNS::=$_p9k__clm}+}"
    at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:180)
    at org.springframework.util.PropertyPlaceholderHelper.replacePlaceholders(PropertyPlaceholderHelper.java:126)
    at org.springframework.core.env.AbstractPropertyResolver.doResolvePlaceholders(AbstractPropertyResolver.java:239)
    at org.springframework.core.env.AbstractPropertyResolver.resolveRequiredPlaceholders(AbstractPropertyResolver.java:210)
    at org.springframework.core.env.AbstractPropertyResolver.resolveNestedPlaceholders(AbstractPropertyResolver.java:230)
    at org.springframework.boot.context.properties.source.ConfigurationPropertySourcesPropertyResolver.getProperty(ConfigurationPropertySourcesPropertyResolver.java:80)
    at org.springframework.boot.context.properties.source.ConfigurationPropertySourcesPropertyResolver.getProperty(ConfigurationPropertySourcesPropertyResolver.java:61)
    at org.springframework.core.env.AbstractEnvironment.getProperty(AbstractEnvironment.java:552)
    at org.hotswap.agent.plugin.spring.files.PropertyReload.getPropertyOfPropertySource(PropertyReload.java:77)
    at org.hotswap.agent.plugin.spring.files.PropertyReload.reloadPropertySource(PropertyReload.java:60)
    at org.hotswap.agent.plugin.spring.reload.SpringBeanReload.refreshProperties(SpringBeanReload.java:385)
    at org.hotswap.agent.plugin.spring.reload.SpringBeanReload.doReload(SpringBeanReload.java:277)
    at org.hotswap.agent.plugin.spring.reload.SpringBeanReload.reload(SpringBeanReload.java:259)
    at org.hotswap.agent.plugin.spring.reload.SpringChangedAgent.doReload(SpringChangedAgent.java:204)
    at org.hotswap.agent.plugin.spring.reload.SpringChangedAgent.reloadAll(SpringChangedAgent.java:192)
    at org.hotswap.agent.plugin.spring.reload.SpringChangedAgent.reload(SpringChangedAgent.java:143)
    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
    ... 3 more

Expected behavior

If no files have been changed, there should not be reload.

Minimal reproducible example

Minimal Hello World application from start.vaadin.com with two views: One for Hilla and for Flow

Versions

Hilla: 24.5.0.alpha15 Flow: 24.5.0.alpha20 Vaadin: 24.5.0.alpha17 Copilot: 24.5.0.alpha20 Frontend Hotswap: Enabled, using Vite OS: aarch64 Mac OS X 15.0 Java: JetBrains s.r.o. 21.0.3 Browser: Chrome 128.0.6613.138 (Official Build) (arm64) Java Hotswap: false IDE Plugin: 1.3.1 IDE: IntelliJ 2024.2

Artur- commented 1 week ago

Does it help if you remove this from the launch configuration?

image
mcollovati commented 1 week ago

Looking at the logs, it appears that there's something that modifies the application.properties file, triggering Spring reload.

EDIT: it happens, for example, if you touch the application.properties in target/classes folder.

mcollovati commented 1 week ago

Or any other properties file, according to the filter in the Spring plugin

@OnResourceFileEvent(path = "/", filter = ".*.properties", events = {FileEvent.MODIFY})
Artur- commented 1 week ago

This specific problem related to moving focus from IntelliJ to the browser should be resolved by turning off the frame deactivation policy, which will be done automatically with https://github.com/vaadin/intellij-plugin/pull/87

Artur- commented 1 week ago

There is another problem described here also, which is why your application.properties keep changing. Without that, you would only see "Loaded classes are up to date. Nothing to reload." when moving to the browser window