Buggy code:
public final class RequestTemplate implements Serializable { private static final long serialVersionUID = 1L ; private final Map < String , Collection < String > > queries = new LinkedHashMap < String , Collection < String > > ( ) ; private final Map < String , Collection < String > > headers = new LinkedHashMap < String , Collection < String > > ( ) ; private String method ; private StringBuilder url = new StringBuilder ( ) ; private transient Charset charset ; private byte [ ] body ; private String bodyTemplate ; private boolean decodeSlash = true ; public RequestTemplate ( ) { } public RequestTemplate ( RequestTemplate toCopy ) { } private static String urlDecode ( String arg ) { } private static String urlEncode ( Object arg ) { } private static boolean isHttpUrl ( CharSequence value ) { } private static CharSequence removeTrailingSlash ( CharSequence charSequence ) { } public static String expand ( String template , Map < String , ? > variables ) { } private static Map < String , Collection < String > > parseAndDecodeQueries ( String queryLine ) { } private static void putKV ( String stringToParse , Map < String , Collection < String > > map ) { } public RequestTemplate resolve ( Map < String , ? > unencoded ) { replaceQueryValues ( unencoded ) ; Map < String , String > encoded = new LinkedHashMap < String , String > ( ) ; for ( Map . Entry < String , ? > entry : unencoded . entrySet ( ) ) { encoded . put ( entry . getKey ( ) , RequestTemplate . urlEncode ( String . valueOf ( entry . getValue ( ) ) ) ) ; } String resolvedUrl = RequestTemplate . expand ( url . toString ( ) , encoded ) . replace ( "+" , "%20" ) ; if ( decodeSlash ) { resolvedUrl = resolvedUrl . replace ( "%2F" , "//" ) ; } url = new StringBuilder ( resolvedUrl ) ; Map < String , Collection < String > > resolvedHeaders = new LinkedHashMap < String , Collection < String > > ( ) ; for ( String field : headers . keySet ( ) ) { Collection < String > resolvedValues = new ArrayList < String > ( ) ; for ( String value : Util . valuesOrEmpty ( headers , field ) ) { String resolved ; if ( ( value . indexOf ( '{' ) ) == 0 ) { resolved = RequestTemplate . expand ( value , unencoded ) ; } else { resolved = value ; } if ( resolved != null ) { resolvedValues . add ( resolved ) ; } } resolvedHeaders . put ( field , resolvedValues ) ; } headers . clear ( ) ; headers . putAll ( resolvedHeaders ) ; if ( ( bodyTemplate ) != null ) { <START_BUG> body ( RequestTemplate . urlDecode ( RequestTemplate . expand ( bodyTemplate , unencoded ) ) ) ; <END_BUG> } return this ; } public Request request ( ) { } public RequestTemplate method ( String method ) { } public String method ( ) { } public RequestTemplate decodeSlash ( boolean decodeSlash ) { } public boolean decodeSlash ( ) { } public RequestTemplate append ( CharSequence value ) { } public RequestTemplate insert ( int pos , CharSequence value ) { } public String url ( ) { } public RequestTemplate query ( String configKey , String ... values ) { } public RequestTemplate query ( String configKey , Iterable < String > values ) { } private String encodeIfNotVariable ( String in ) { } public RequestTemplate queries ( Map < String , Collection < String > > queries ) { } public Map < String , Collection < String > > queries ( ) { } public RequestTemplate header ( String name , String ... values ) { } public RequestTemplate header ( String name , Iterable < String > values ) { } public RequestTemplate headers ( Map < String , Collection < String > > headers ) { } public Map < String , Collection < String > > headers ( ) { } public RequestTemplate body ( byte [ ] bodyData , Charset charset ) { } public RequestTemplate body ( String bodyText ) { } public Charset charset ( ) { } public byte [ ] body ( ) { } public RequestTemplate bodyTemplate ( String bodyTemplate ) { } public String bodyTemplate ( ) { } private StringBuilder pullAnyQueriesOutOfUrl ( StringBuilder url ) { } private boolean allValuesAreNull ( Collection < String > values ) { } @ Override public String toString ( ) { } public void replaceQueryValues ( Map < String , ? > unencoded ) { } public String queryLine ( ) { } interface Factory { RequestTemplate create ( Object [ ] argv ) { } } }

Fix:
body ( RequestTemplate . urlDecode ( RequestTemplate . expand ( bodyTemplate , encoded ) ) ) ;