File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
sdk/core/azure-core-test/src/main/java/com/azure/core/test/policy Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -104,13 +104,21 @@ private void setDefaultRecordingOptions() {
104104 /**
105105 * Stops recording of test traffic.
106106 * @param variables A list of random variables generated during the test which is saved in the recording.
107+ * @throws RuntimeException If the test proxy returns an error while stopping recording.
107108 */
108109 public void stopRecording (Queue <String > variables ) {
109110 HttpRequest request = new HttpRequest (HttpMethod .POST , proxyUrl + "/record/stop" )
110111 .setHeader (HttpHeaderName .CONTENT_TYPE , "application/json" )
111112 .setHeader (X_RECORDING_ID , xRecordingId )
112113 .setBody (serializeVariables (variables ));
113- client .sendSync (request , Context .NONE ).close ();
114+
115+ try (HttpResponse response = client .sendSync (request , Context .NONE )) {
116+ checkForTestProxyErrors (response );
117+
118+ if (response .getStatusCode () == 400 ) {
119+ throw new RuntimeException (response .getBodyAsBinaryData ().toString ());
120+ }
121+ }
114122 }
115123
116124 /**
@@ -138,7 +146,7 @@ private String serializeVariables(Queue<String> variables) {
138146 if (variable == null ) {
139147 builder .append ("null" );
140148 } else {
141- builder .append ('"' ). append ( variable ).append ('"' );
149+ builder .append (variable ).append ('"' );
142150 }
143151 }
144152
You can’t perform that action at this time.
0 commit comments