question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Quarkus hot replace does not work for code in constructor

See original GitHub issue

Describe the bug Changes to code in the constructor of Java classes are not included in the hot reload, even though Quarkus reports that the class is reloaded.

Expected behavior Changing the code in the constructor of Java classes that are subject to hot reload should be included in the hot reload.

Actual behavior When code in constructor of a Java class is updated and a new request is made, the changes in the code are not reflected to reloaded class.

To Reproduce Follow the rest tutorial from Quarkus documentation to create a project. Basically this corresponds to running:

mvn io.quarkus:quarkus-maven-plugin:1.12.2.Final:create \
    -DprojectGroupId=org.acme \
    -DprojectArtifactId=rest-json-quickstart \
    -DclassName="org.acme.rest.json.FruitResource" \
    -Dpath="/fruits" \
    -Dextensions="resteasy,resteasy-jackson"

Then start Quarkus with: ./mvnw compile quarkus:dev

Navigate to http://localhost:8080/resteasy-jackson/quarks using a modern browser This will display a JSON payload as a result of the GET http request.

Now update the code in JacksonResource type’s constructor in the generated project code, while Quarkus is still running. Change any of the text values of items added to quarkus field, for example, use the following: quarks.add(new Quark("Up", "The updated value goes here."));

Save the changes to file.

Refresh the browser page. Quarkus will print to terminal that changes are detected to modified Java class and it is reloaded. The changes in the constructor code are not reflected to response from Quarkus. Browser still displays the same json payload.

Configuration As set by the mvn archetype above

Screenshots Not applicable

Environment (please complete the following information): ./mvnw --version produces:

Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /home/<user-name>/.m2/wrapper/dists/apache-maven-3.6.3-bin/1iopthnavndlasol9gbrbg6bf2/apache-maven-3.6.3
Java version: 11.0.10, vendor: GraalVM Community, runtime: /usr/lib/jvm/graalvm-ce-java11-21.0.0.2
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.15.0-101-generic", arch: "amd64", family: "unix"

This code is run under Ubuntu 18.04.

Additional context N/A

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:13 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
gsmetcommented, Mar 24, 2021

@grumpyrodriguez just add quarkus.live-reload.instrumentation=false to your application.properties and things will be back to the way it was.

@stuartwdouglas @mkouba while I agree instrumentation has its perks, our previous live reload had a lot of success and one of the reasons was that it always worked and you didn’t have weird edge cases.

0reactions
geoandcommented, Jan 26, 2022

I am going to close this as we have reverted to not using instrumentation unless explicitly requested by the user.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Quarkus hot replace does not work for code in constructor
Update: It looks like the changes to code in the constructor of a type are not reloaded. If I change something in a...
Read more >
Contexts and Dependency Injection - Quarkus
That's why Quarkus users are encouraged not to use private members in their beans. This involves injection fields, constructors and initializers, observer ...
Read more >
Introduction to Contexts and Dependency Injection - Quarkus
This is a constructor injection. In fact, this code would not work in regular CDI implementations where a bean with a normal scope...
Read more >
Writing Your Own Extension - Quarkus
If bytecode is recorded with @Record(RUNTIME_INIT) then it is executed from the application's main method. This code will be run on native executable...
Read more >
Configuring Your Application - Quarkus
Hardcoded values in your code are a no-go (even if we all did it at some point ;-)). In this guide, we will...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found