Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotswap reloads every time IntelliJ is defocused #19971

Closed
jojule opened this issue Sep 18, 2024 · 5 comments · Fixed by vaadin/intellij-plugin#87
Closed

Hotswap reloads every time IntelliJ is defocused #19971

jojule opened this issue Sep 18, 2024 · 5 comments · Fixed by vaadin/intellij-plugin#87

Comments

@jojule
Copy link
Contributor

jojule commented Sep 18, 2024

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-
Copy link
Member

Artur- commented Sep 18, 2024

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

@mcollovati
Copy link
Collaborator

mcollovati commented Sep 18, 2024

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
Copy link
Collaborator

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

@OnResourceFileEvent(path = "/", filter = ".*.properties", events = {FileEvent.MODIFY})

Artur- added a commit to vaadin/intellij-plugin that referenced this issue Sep 19, 2024
The default value for frame deactivation is to update classes and resources.

This causes an extra update when going from IntelliJ to the browser which either does nothing or then does an extra hotswap of some files, as described in vaadin/flow#19971
Artur- added a commit to vaadin/intellij-plugin that referenced this issue Sep 19, 2024
The default value for frame deactivation is to update classes and resources.

This causes an extra update when going from IntelliJ to the browser which either does nothing or then does an extra hotswap of some files, as described in vaadin/flow#19971
@Artur-
Copy link
Member

Artur- commented Sep 19, 2024

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 vaadin/intellij-plugin#87

@Artur-
Copy link
Member

Artur- commented Sep 19, 2024

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

MarcinVaadin pushed a commit to vaadin/intellij-plugin that referenced this issue Sep 19, 2024
The default value for frame deactivation is to update classes and resources.

This causes an extra update when going from IntelliJ to the browser which either does nothing or then does an extra hotswap of some files, as described in vaadin/flow#19971
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants