Skip to content

Commit

Permalink
Fix ByteBuffer errors to be compatible with Java 8 runtimes (#937)
Browse files Browse the repository at this point in the history
* Fix `ByteBuffer` errors to be compatible with Java 8 runtimes
* Increment version to 29.46.3

---------

Co-authored-by: Yan Zhou <[email protected]>
  • Loading branch information
JoeJoe1989 and Yan Zhou authored Sep 27, 2023
1 parent 4e8dd72 commit 1da9f81
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ and what APIs have changed, if applicable.

## [Unreleased]

## [29.46.3] - 2023-09-26
- Fix ByteBuffer errors to be compatible with Java 8 runtimes.

## [29.46.2] - 2023-09-25
- add service/cluster-not-found count to simple load balancer jmx. And add entry-out-of-sync count to dual read monitoring.

Expand Down Expand Up @@ -5536,7 +5539,8 @@ patch operations can re-use these classes for generating patch messages.

## [0.14.1]

[Unreleased]: https://github.com/linkedin/rest.li/compare/v29.46.2...master
[Unreleased]: https://github.com/linkedin/rest.li/compare/v29.46.3...master
[29.46.3]: https://github.com/linkedin/rest.li/compare/v29.46.2...v29.46.3
[29.46.2]: https://github.com/linkedin/rest.li/compare/v29.46.1...v29.46.2
[29.46.1]: https://github.com/linkedin/rest.li/compare/v29.46.0...v29.46.1
[29.46.0]: https://github.com/linkedin/rest.li/compare/v29.45.1...v29.46.0
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version=29.46.2
version=29.46.3
group=com.linkedin.pegasus
org.gradle.configureondemand=true
org.gradle.parallel=true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
import java.net.URI;
import java.net.URLDecoder;
import java.nio.ByteBuffer;
import java.nio.Buffer;
import java.nio.CharBuffer;
import java.nio.charset.Charset;
import java.util.ArrayList;
Expand Down Expand Up @@ -831,7 +832,9 @@ private static ByteBuffer decodePercentEncodedOctets(String s, int i, ByteBuffer
if (bb == null)
bb = ByteBuffer.allocate(1);
else
bb.clear();
// Fix java.lang.NoSuchMethodError: java.nio.ByteBuffer.clear()Ljava/nio/ByteBuffer based on the suggestions from
// https://stackoverflow.com/questions/61267495/exception-in-thread-main-java-lang-nosuchmethoderror-java-nio-bytebuffer-flip
((Buffer)bb).clear();

while (true) {
// Decode the hex digits
Expand All @@ -849,16 +852,19 @@ private static ByteBuffer decodePercentEncodedOctets(String s, int i, ByteBuffer

// Check if the byte buffer needs to be increased in size
if (bb.position() == bb.capacity()) {
bb.flip();
// Fix java.lang.NoSuchMethodError: java.nio.ByteBuffer.flip()Ljava/nio/ByteBuffer based on the suggestions from
// https://stackoverflow.com/questions/61267495/exception-in-thread-main-java-lang-nosuchmethoderror-java-nio-bytebuffer-flip
((Buffer)bb).flip();
// Create a new byte buffer with the maximum number of possible
// octets, hence resize should only occur once
ByteBuffer bb_new = ByteBuffer.allocate(s.length() / 3);
bb_new.put(bb);
bb = bb_new;
}
}

bb.flip();
// Fix java.lang.NoSuchMethodError: java.nio.ByteBuffer.flip()Ljava/nio/ByteBuffer based on the suggestions from
// https://stackoverflow.com/questions/61267495/exception-in-thread-main-java-lang-nosuchmethoderror-java-nio-bytebuffer-flip
((Buffer)bb).flip();
return bb;
}

Expand Down

0 comments on commit 1da9f81

Please sign in to comment.