File tree Expand file tree Collapse file tree 8 files changed +91
-12
lines changed
main/java/com/appland/appmap
test/java/com/appland/appmap/test/fixture Expand file tree Collapse file tree 8 files changed +91
-12
lines changed Original file line number Diff line number Diff line change 4141
4242 - name : Run Tests
4343 shell : bash
44+ env :
45+ GITHUB_TOKEN : ${{ github.token }}
4446 run : |
4547 set -e
4648 bin/disable-gradle-daemon
Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ public class Properties {
3434 public static final Integer PatternThreshold =
3535 resolveProperty ("appmap.config.patternThreshold" , 10 );
3636
37+ public static final Boolean DisableValue = resolveProperty ("appmap.event.disableValue" , false );
3738 public static final Integer MaxValueSize = resolveProperty ("appmap.event.valueSize" , 1024 );
3839
3940 public static final String [] Records = resolveProperty ("appmap.record" , new String [0 ]);
Original file line number Diff line number Diff line change @@ -115,19 +115,23 @@ public <T> T get() {
115115 */
116116 public Value freeze () {
117117 if (this .value != null ) {
118- try {
119- this .value = this .value .toString ();
120-
121- if (Properties .MaxValueSize > 0 && this .value != null ) {
122- this .value = StringUtils .abbreviate ((String ) this .value , "..." , Properties .MaxValueSize );
118+ if (Properties .DisableValue ) {
119+ this .value = "< disabled >" ;
120+ } else {
121+ try {
122+ this .value = this .value .toString ();
123+
124+ if (Properties .MaxValueSize > 0 && this .value != null ) {
125+ this .value = StringUtils .abbreviate ((String ) this .value , "..." , Properties .MaxValueSize );
126+ }
127+ } catch (Throwable e ) {
128+ Logger .println ("failed to resolve value of " + this .classType );
129+ Logger .println (e .getMessage ());
130+ // it's possible our value object has been partially cleaned up and
131+ // calls toString on a null object or the operation is otherwise
132+ // unsupported
133+ this .value = "< invalid >" ;
123134 }
124- } catch (Throwable e ) {
125- Logger .println ("failed to resolve value of " + this .classType );
126- Logger .println (e .getMessage ());
127- // it's possible our value object has been partially cleaned up and
128- // calls toString on a null object or the operation is otherwise
129- // unsupported
130- this .value = "< invalid >" ;
131135 }
132136 }
133137 return this ;
Original file line number Diff line number Diff line change 1+ package com .appland .appmap .test .fixture ;
2+
3+ public class Example {
4+ @ Override
5+ public String toString () {
6+ return "an Example" ;
7+ }
8+
9+ public Example doSomething (Example other ) {
10+ return other ;
11+ }
12+
13+ }
Original file line number Diff line number Diff line change 1+ * .class
Original file line number Diff line number Diff line change 1+ import java .io .IOException ;
2+ import java .io .OutputStreamWriter ;
3+
4+ import com .appland .appmap .record .Recorder ;
5+ import com .appland .appmap .record .Recording ;
6+
7+ import com .appland .appmap .test .fixture .Example ;
8+
9+ public class DisabledValue {
10+
11+ public static void main (String [] argv ) {
12+ final Recording recording = Recorder .getInstance ().record (() -> {
13+ new Example ().doSomething (new Example ());
14+ });
15+
16+ try {
17+ recording .readFully (true , new OutputStreamWriter (System .out ));
18+ } catch (IOException e ) {
19+ e .printStackTrace ();
20+ }
21+
22+ }
23+ }
Original file line number Diff line number Diff line change 1+ name : test-event
2+ packages :
3+ - path : com.appland.appmap.test.fixture
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bats
2+
3+ load ' ../../build/bats/bats-support/load'
4+ load ' ../../build/bats/bats-assert/load'
5+ load ' ../helper'
6+
7+ sep=" $JAVA_PATH_SEPARATOR "
8+ AGENT_JAR=" $( find_agent_jar) "
9+ wd=$( getcwd)
10+ test_cp=" ${wd} /test/event${sep}${wd} /build/classes/java/test"
11+ java_cmd=" java -javaagent:'${AGENT_JAR} ' -cp '${test_cp} '"
12+
13+ setup () {
14+ javac -cp " ${AGENT_JAR}${sep}${test_cp} " test/event/* .java
15+
16+ cd test/event
17+ _configure_logging
18+ }
19+
20+ @test " disabled value" {
21+ local cmd=" ${java_cmd} -Dappmap.event.disableValue=true DisabledValue"
22+ [[ $BATS_VERBOSE_RUN == 1 ]] && echo " cmd: $cmd " >&3
23+
24+ local output
25+ output=$( eval " $cmd " )
26+
27+ echo " $output " | jq -e ' .events[0] | select(.event=="call"
28+ and .parameters[0].value == "< disabled >"
29+ and .receiver.value == "< disabled >")'
30+ echo " $output " | jq -e ' .events[1] | select(.event=="return"
31+ and .return_value.value == "< disabled >")'
32+ }
You can’t perform that action at this time.
0 commit comments