Riverside-Software / sonar-openedge

CABL (Code Analyzer for ABL in SonarQube) - ABL ANTLR4 Parser
https://riverside-software.fr
GNU Lesser General Public License v3.0
63 stars 25 forks source link

JsonConstruct:Write(OUTPUT LONCHAR) should not be used #910

Open movedoa opened 3 years ago

movedoa commented 3 years ago

When using the JsonConstruct:Write method (JsonArray/JsonObject) with a LONGCHAR variable, you have to use it with INPUT-OUTPUT since the OUTPUT version is defined with CHARACTER and produces errors if the output is longer than 32k chars.

If you don't specify a parameter mode is also works, but you shouldn't do that (#528).

This should be a general rule, not just for these types since one could produce the same with custom methods.

DEFINE VARIABLE loJsonObject AS Progress.Json.ObjectModel.JsonObject NO-UNDO.
DEFINE VARIABLE liCount AS INTEGER NO-UNDO.
DEFINE VARIABLE llcOutoput AS LONGCHAR NO-UNDO.

loJsonObject = NEW Progress.Json.ObjectModel.JsonObject().

DO liCount = 1 TO 1000:
   loJsonObject:Add(STRING(liCount), "01234567890123456789012345678901234567890123456789":U).   
END.

// Error -> Attempt to exceed maximum size of a CHARACTER variable. (9324)
// loJsonObject:Write(OUTPUT llcOutoput).

// Works
loJsonObject:Write(INPUT-OUTPUT llcOutoput).

// Also works
loJsonObject:Write(llcOutoput).
akompanas commented 5 days ago

I recently got burnt by this exact issue. Is there a way to get more traction to this?

gquerret commented 4 days ago

I recently got burnt by this exact issue. Is there a way to get more traction to this?

Yes, could be done