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

NumberFormatException in until-successful's secondsBetweenRetries featuring properties #558

Merged
merged 1 commit into from
Nov 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import static com.mulesoft.tools.migration.step.util.XmlDslUtils.getContainerElement;
import static com.mulesoft.tools.migration.step.util.XmlDslUtils.getFlowExceptionHandlingElement;
import static com.mulesoft.tools.migration.step.util.XmlDslUtils.removeAttribute;
import static java.lang.Integer.parseInt;

/**
* Migrate Until Successful
Expand Down Expand Up @@ -80,8 +81,14 @@ public void execute(Element element, MigrationReport report) throws RuntimeExcep
}

if (element.getAttribute("secondsBetweenRetries") != null) {
Integer retries = Integer.valueOf(element.getAttributeValue("secondsBetweenRetries")) * 1000;
element.setAttribute("millisBetweenRetries", retries.toString());
String retries = element.getAttributeValue("secondsBetweenRetries");
try {
retries = String.valueOf(parseInt(retries) * 1000);
} catch (NumberFormatException nfe) {
String propertyName = retries.startsWith("${") ? retries.substring(2, retries.length() - 1) : retries;
report.report("untilSuccessful.secondsBetweenRetries", element, element, propertyName);
}
element.setAttribute("millisBetweenRetries", retries);
removeAttribute(element, "secondsBetweenRetries");
}

Expand Down
5 changes: 5 additions & 0 deletions mule-migration-tool-library/src/main/resources/report.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,11 @@ untilSuccessful:
message: Threading Profile is no longer needed in Mule 4.
docLinks:
- https://docs.mulesoft.com/mule-runtime/4.3/intro-engine
secondsBetweenRetries:
type: WARN
message: "Update the property '{prop}' to specify the period between retries in milliseconds."
docLinks:
- https://docs.mulesoft.com/mule-runtime/4.3/migration-core-until-successful

json:
mapper:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ public static Object[] params() {
"until-successful-04",
// TODO MMT-258
// "until-successful-05",
"until-successful-06"
"until-successful-06",
"until-successful-07",
"until-successful-08"
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd">

<flow name="untilFlow">
<until-successful ackExpression="#['test']" secondsBetweenRetries="10" synchronous="lala">
<until-successful secondsBetweenRetries="10">
<logger message="#[1]"/>
</until-successful>
</flow>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@
<until-successful millisBetweenRetries="10000">
<logger message="#[1]"/>
</until-successful>
<set-payload value="#['test']"/>
</flow>
</mule>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd">

<flow name="untilFlow">
<until-successful secondsBetweenRetries="${secsBetweenRetries}">
<logger message="#[1]"/>
</until-successful>
</flow>
</mule>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd">

<flow name="untilFlow">
<until-successful millisBetweenRetries="${secsBetweenRetries}">
<logger message="#[1]"/>
</until-successful>
</flow>
</mule>
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ public UntilSuccessfulMigrationTestCase(String appToMigrate) {

@Test
public void test() throws Exception {
simpleCase(appToMigrate, "-M-DhttpPort=" + httpPort.getValue());
simpleCase(appToMigrate, "-M-DhttpPort=" + httpPort.getValue(), "-M-Dsecs=30");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd">
<flow name="untilFlow">
<until-successful>
<until-successful secondsBetweenRetries="${secs}">
<threading-profile maxThreadsActive="45" maxThreadsIdle="5" threadTTL="52" threadWaitTimeout="52"/>
<logger message="#[1]"/>
</until-successful>
Expand Down