Introduced a new property appmap.event.disableValue to disable the custom stringification of objects during AppMap recordings. This change includes:
A DisableValue property in "Properties" class to toggle stringification.
Updates to the Value class to respect this property.
A new test case in DisabledValue to validate functionality when DisableValue is enabled.
An example class Example for testing and a bats script to verify the changes.
Summary of Changes
Introduced a Configuration Property to Disable Stringification:
Added a new property DisableValue in the Properties class which can be toggled to disable the stringification of objects.
Default value for this property is set to false.
public class Properties {
public static final Boolean DisableValue = resolveProperty("appmap.event.disableValue", false);
public static final Integer MaxValueSize = resolveProperty("appmap.event.valueSize", 1024);
// Other properties...
}
Modified the Value Class to Utilize the New Property:
Updated the freeze method in the Value class to check the DisableValue property.
If DisableValue is true, the object’s value is set to a placeholder ("< disabled >").
public class Value {
public Value freeze() {
if (this.value != null) {
if (Properties.DisableValue) {
this.value = "< disabled >";
} else {
try {
this.value = this.value.toString();
if (Properties.MaxValueSize > 0 && this.value != null) {
this.value = StringUtils.abbreviate((String) this.value, "...", Properties.MaxValueSize);
}
} catch (Throwable e) {
Logger.println("failed to resolve value of " + this.classType);
Logger.println(e.getMessage());
this.value = "< invalid >";
}
}
}
return this;
}
}
Created a Test Case to Validate the New Property:
Added a new test class DisabledValue that generates an AppMap recording to verify the behavior when DisableValue is enabled.
import java.io.IOException;
import java.io.OutputStreamWriter;
import com.appland.appmap.record.Recorder;
import com.appland.appmap.record.Recording;
public class DisabledValue {
public static void main(String[] argv) {
final Recording recording = Recorder.getInstance().record(() -> {
new Example().doSomething(new Example());
});
try {
recording.readFully(true, new OutputStreamWriter(System.out));
} catch (IOException e) {
e.printStackTrace();
}
}
}
Added an Example Class to Use in the Test:
Created the Example class with a toString method and a method doSomething that returns an instance of the Example class.
public class Example {
@Override
public String toString() {
return "an Example";
}
public Example doSomething(Example other) {
return other;
}
}
Updated Testing Setup and bats Test:
Configured a new bats test script to compile the test files and run the new test, verifying the DisableValue property functionality using jq to inspect the AppMap JSON output.
Fixes #287.
Introduced a new property
appmap.event.disableValue
to disable the custom stringification of objects during AppMap recordings. This change includes:DisableValue
property in "Properties" class to toggle stringification.Value
class to respect this property.DisabledValue
to validate functionality whenDisableValue
is enabled.Example
for testing and abats
script to verify the changes.Summary of Changes
DisableValue
in theProperties
class which can be toggled to disable the stringification of objects.false
.Value
Class to Utilize the New Property:freeze
method in theValue
class to check theDisableValue
property.DisableValue
istrue
, the object’s value is set to a placeholder ("< disabled >"
).DisabledValue
that generates an AppMap recording to verify the behavior whenDisableValue
is enabled.Example
class with atoString
method and a methoddoSomething
that returns an instance of theExample
class.bats
Test:bats
test script to compile the test files and run the new test, verifying theDisableValue
property functionality usingjq
to inspect the AppMap JSON output.