googleapis / googleapis/java-bigtable-hbase

bigtable-hbase-2.x:2.6.1 FuzzyRowFilterAdapter is not adapting correctly when using `--illegal-access=deny`

Aperta
#3,780 0 commenti 1 reazione 0 assegnatari Vedi su GitHub
api: bigtable priority: p2 type: bug
Lingua principale
Java
Stelle
184
Fork
184
Merge medio
10h
PR unite (30g)
6

Descrizione

Hello! Hbase's [implementation](https://github.com/apache/hbase/blob/master/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/FuzzyRowFilter.java#L117-L132) of `FuzzyRowFilter` conditionally uses either `0` or `-1` to indicate that the provided byte has a fixed value. This condition is based on whether the code can make an [illegal access](https://github.com/apache/hbase/blob/f4866a49dccdeea4a0ed73bd37f9f114fdc7ea41/hbase-common/src/main/java/org/apache/hadoop/hbase/util/UnsafeAvailChecker.java#L152-L162).

In Java 17, the `illegal-access` flag is [obsolete](https://www.oracle.com/java/technologies/javase/17-relnote-issues.html#JDK-8266851), and so it is impossible to make an illegal access, so `UNSAFE_UNALIGNED` is always `false`. This means that Hbase produces fuzzy row filters with `0` to indicate that the provided byte has a fixed value, not `-1`.

However, the FuzzyRowFilterAdapter is only checking for `-1`, not conditionally `0` in fuzzy row filters:
https://github.com/googleapis/java-bigtable-hbase/blob/main/bigtable-client-core-parent/bigtable-hbase/src/main/java/com/google/cloud/bigtable/hbase/adapters/filters/FuzzyRowFilterAdapter.java#L70-L85
```
for (int i = 0; i < mask.length; i++) {
if (mask[i] == -1) {
quotingStream.write(key[i]);
} else {
// Write unquoted to match any byte at this position:
output.write(ReaderExpressionHelper.ANY_BYTE_BYTES);
}
}
```

I believe it should instead check the value of `HBasePlatformDependent.unaligned()`:
```
for (int i = 0; i < mask.length; i++) {
if (mask[i] == UnsafeAvailChecker.unaligned() ? -1 : 0) {
quotingStream.write(key[i]);
} else {
// Write unquoted to match any byte at this position:
output.write(ReaderExpressionHelper.ANY_BYTE_BYTES);
}
}
```

#### Environment details

Java version: Java 16, trying to upgrade to Java 17.

#### Steps to reproduce

1. Product an HBase fuzzy filter in Java 17, or in Java 16 with `--illegal-access=deny`
2. Pass this fuzzy filter to bigtable and check that if it is adapted correctly

#### External references such as API reference guides

See links above

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia in bigtable-hbase/src/main/java/com/google/cloud/bigtable/hbase/adapters/filters/FuzzyRowFilterAdapter.java, nel ciclo di gestione della maschera, quindi confronta le sue ipotesi con FuzzyRowFilter di HBase e i link a UnsafeAvailChecker. Riproduci il problema con Java 17 o Java 16 usando --illegal-access=deny e verifica che entrambe le codifiche della maschera adattino correttamente i byte fissi e quelli jolly.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
java
Ambito
databases
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Specificata chiaramente
Idoneità per principianti
55/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.