--- a/httpclient/src/main/java/org/apache/http/client/utils/URLEncodedUtils.java
+++ b/httpclient/src/main/java/org/apache/http/client/utils/URLEncodedUtils.java
@@ -32,6 +32,7 @@ import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.Reader;
 import java.net.URI;
+import java.nio.Buffer;
 import java.nio.ByteBuffer;
 import java.nio.CharBuffer;
 import java.nio.charset.Charset;
@@ -587,7 +588,7 @@ public class URLEncodedUtils {
                 bb.put((byte) c);
             }
         }
-        bb.flip();
+        ((Buffer) bb).flip();
         return charset.decode(bb).toString();
     }
 
