@@ -503,9 +503,8 @@ private static boolean addSpecialHeadersToRequestOptions(JavaBlock function, Cli
503503
504504 // repeatability headers
505505 if (repeatabilityRequestHeaders ) {
506- addSpecialHeadersToLocalVariables (function , clientMethod );
507- requestOptionsSetHeaderIfAbsent (function , MethodUtil .REPEATABILITY_REQUEST_ID_VARIABLE_NAME , MethodUtil .REPEATABILITY_REQUEST_ID_HEADER );
508- requestOptionsSetHeaderIfAbsent (function , MethodUtil .REPEATABILITY_FIRST_SENT_VARIABLE_NAME , MethodUtil .REPEATABILITY_FIRST_SENT_HEADER );
506+ requestOptionsSetHeaderIfAbsent (function , MethodUtil .REPEATABILITY_REQUEST_ID_EXPRESSION , MethodUtil .REPEATABILITY_REQUEST_ID_HEADER );
507+ requestOptionsSetHeaderIfAbsent (function , MethodUtil .REPEATABILITY_FIRST_SENT_EXPRESSION , MethodUtil .REPEATABILITY_FIRST_SENT_HEADER );
509508 }
510509
511510 // content-type headers for optional body parameter
@@ -523,23 +522,16 @@ private static boolean addSpecialHeadersToRequestOptions(JavaBlock function, Cli
523522 return requestOptionsLocal ;
524523 }
525524
526- private static void requestOptionsSetHeaderIfAbsent (JavaBlock function , String variableName , String headerName ) {
525+ private static void requestOptionsSetHeaderIfAbsent (JavaBlock function , String expression , String headerName ) {
527526 function .line ("requestOptionsLocal.addRequestCallback(requestLocal -> {" );
528527 function .indent (() -> {
529528 function .ifBlock (String .format ("requestLocal.getHeaders().get(HttpHeaderName.fromString(\" %1$s\" )) == null" , headerName ), ifBlock -> {
530- function .line (String .format ("requestLocal.getHeaders().set(HttpHeaderName.fromString(\" %1$s\" ), %2$s);" , headerName , variableName ));
529+ function .line (String .format ("requestLocal.getHeaders().set(HttpHeaderName.fromString(\" %1$s\" ), %2$s);" , headerName , expression ));
531530 });
532531 });
533532 function .line ("});" );
534533 }
535534
536- protected static void addSpecialHeadersToLocalVariables (JavaBlock function , ClientMethod clientMethod ) {
537- if (MethodUtil .isMethodIncludeRepeatableRequestHeaders (clientMethod .getProxyMethod ())) {
538- function .line (String .format ("String %1$s = CoreUtils.randomUuid().toString();" , MethodUtil .REPEATABILITY_REQUEST_ID_VARIABLE_NAME ));
539- function .line (String .format ("String %1$s = DateTimeRfc1123.toRfc1123String(OffsetDateTime.now());" , MethodUtil .REPEATABILITY_FIRST_SENT_VARIABLE_NAME ));
540- }
541- }
542-
543535 protected static void writeMethod (JavaType typeBlock , JavaVisibility visibility , String methodSignature , Consumer <JavaBlock > method ) {
544536 if (visibility == JavaVisibility .Public ) {
545537 typeBlock .publicMethod (methodSignature , method );
@@ -742,8 +734,6 @@ private void generatePagedSinglePage(ClientMethod clientMethod, JavaType typeBlo
742734 boolean requestOptionsLocal = false ;
743735 if (settings .isDataPlaneClient ()) {
744736 requestOptionsLocal = addSpecialHeadersToRequestOptions (function , clientMethod );
745- } else {
746- addSpecialHeadersToLocalVariables (function , clientMethod );
747737 }
748738
749739 String serviceMethodCall = checkAndReplaceParamNameCollision (clientMethod , restAPIMethod , requestOptionsLocal , settings );
@@ -1063,8 +1053,6 @@ protected void generatePlainSyncMethod(ClientMethod clientMethod, JavaType typeB
10631053 boolean requestOptionsLocal = false ;
10641054 if (settings .isDataPlaneClient ()) {
10651055 requestOptionsLocal = addSpecialHeadersToRequestOptions (function , clientMethod );
1066- } else {
1067- addSpecialHeadersToLocalVariables (function , clientMethod );
10681056 }
10691057
10701058 String serviceMethodCall = checkAndReplaceParamNameCollision (clientMethod , restAPIMethod .toSync (), requestOptionsLocal ,
@@ -1163,8 +1151,6 @@ protected void generatePagedAsyncSinglePage(ClientMethod clientMethod, JavaType
11631151 boolean requestOptionsLocal = false ;
11641152 if (settings .isDataPlaneClient ()) {
11651153 requestOptionsLocal = addSpecialHeadersToRequestOptions (function , clientMethod );
1166- } else {
1167- addSpecialHeadersToLocalVariables (function , clientMethod );
11681154 }
11691155
11701156 String serviceMethodCall = checkAndReplaceParamNameCollision (clientMethod , restAPIMethod , requestOptionsLocal , settings );
@@ -1300,8 +1286,6 @@ protected void generateSimpleAsyncRestResponse(ClientMethod clientMethod, JavaTy
13001286 boolean requestOptionsLocal = false ;
13011287 if (settings .isDataPlaneClient ()) {
13021288 requestOptionsLocal = addSpecialHeadersToRequestOptions (function , clientMethod );
1303- } else {
1304- addSpecialHeadersToLocalVariables (function , clientMethod );
13051289 }
13061290
13071291 String serviceMethodCall = checkAndReplaceParamNameCollision (clientMethod , restAPIMethod , requestOptionsLocal , settings );
0 commit comments