This is an automated email from the ASF dual-hosted git repository.
wchevreuil pushed a commit to branch branch-3
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/branch-3 by this push:
new 4f129046964 HBASE-29325 Gson reflection failures on
TestBucketCache.testCacheSimple (#6999)
4f129046964 is described below
commit 4f129046964a1f0d2d1fda3bdc61a1842ebe0616
Author: Wellington Ramos Chevreuil <[email protected]>
AuthorDate: Mon Jul 7 09:54:10 2025 +0100
HBASE-29325 Gson reflection failures on TestBucketCache.testCacheSimple
(#6999)
Signed-off-by: Duo Zhang <[email protected]>
Signed-off-by: Istvan Toth <[email protected]>
Reviewed-by: Kota-SH <[email protected]>
---
.../hadoop/hbase/io/hfile/BlockCacheUtil.java | 48 +++++++++++-----------
1 file changed, 25 insertions(+), 23 deletions(-)
diff --git
a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/BlockCacheUtil.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/BlockCacheUtil.java
index 2c1559b1147..7cc919aa026 100644
---
a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/BlockCacheUtil.java
+++
b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/BlockCacheUtil.java
@@ -20,6 +20,7 @@ package org.apache.hadoop.hbase.io.hfile;
import static org.apache.hadoop.hbase.io.hfile.HFileBlock.FILL_HEADER;
import java.io.IOException;
+import java.lang.reflect.Modifier;
import java.nio.ByteBuffer;
import java.util.HashSet;
import java.util.Map;
@@ -58,29 +59,30 @@ public class BlockCacheUtil {
/**
* Needed generating JSON.
*/
- private static final Gson GSON = GsonUtil.createGson()
- .registerTypeAdapter(FastLongHistogram.class, new
TypeAdapter<FastLongHistogram>() {
-
- @Override
- public void write(JsonWriter out, FastLongHistogram value) throws
IOException {
- AgeSnapshot snapshot = new AgeSnapshot(value);
- out.beginObject();
- out.name("mean").value(snapshot.getMean());
- out.name("min").value(snapshot.getMin());
- out.name("max").value(snapshot.getMax());
- out.name("75thPercentile").value(snapshot.get75thPercentile());
- out.name("95thPercentile").value(snapshot.get95thPercentile());
- out.name("98thPercentile").value(snapshot.get98thPercentile());
- out.name("99thPercentile").value(snapshot.get99thPercentile());
- out.name("999thPercentile").value(snapshot.get999thPercentile());
- out.endObject();
- }
-
- @Override
- public FastLongHistogram read(JsonReader in) throws IOException {
- throw new UnsupportedOperationException();
- }
- }).setPrettyPrinting().create();
+ private static final Gson GSON =
+ GsonUtil.createGson().excludeFieldsWithModifiers(Modifier.PRIVATE)
+ .registerTypeAdapter(FastLongHistogram.class, new
TypeAdapter<FastLongHistogram>() {
+
+ @Override
+ public void write(JsonWriter out, FastLongHistogram value) throws
IOException {
+ AgeSnapshot snapshot = new AgeSnapshot(value);
+ out.beginObject();
+ out.name("mean").value(snapshot.getMean());
+ out.name("min").value(snapshot.getMin());
+ out.name("max").value(snapshot.getMax());
+ out.name("75thPercentile").value(snapshot.get75thPercentile());
+ out.name("95thPercentile").value(snapshot.get95thPercentile());
+ out.name("98thPercentile").value(snapshot.get98thPercentile());
+ out.name("99thPercentile").value(snapshot.get99thPercentile());
+ out.name("999thPercentile").value(snapshot.get999thPercentile());
+ out.endObject();
+ }
+
+ @Override
+ public FastLongHistogram read(JsonReader in) throws IOException {
+ throw new UnsupportedOperationException();
+ }
+ }).setPrettyPrinting().create();
/** Returns The block content as String. */
public static String toString(final CachedBlock cb, final long now) {