Skip to content

Commit

Permalink
NumberFormatException in until-successful's secondsBetweenRetries fea…
Browse files Browse the repository at this point in the history
…turing properties (#558)

fixes #454
  • Loading branch information
svacas authored Nov 3, 2021
1 parent e5779b5 commit f0368eb
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 7 deletions.
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

0 comments on commit f0368eb

Please sign in to comment.