Skip to content

Commit 8714715

Browse files
author
Daniel Roudnitsky
committed
apply spotless
1 parent 29b9a82 commit 8714715

File tree

3 files changed

+49
-29
lines changed

3 files changed

+49
-29
lines changed

hbase-client/src/main/java/org/apache/hadoop/hbase/DoNotRetryRuntimeException.java

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,31 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
118
package org.apache.hadoop.hbase;
219

320
import org.apache.yetus.audience.InterfaceAudience;
421

522
/**
6-
* When a fatal issue is encountered during an RPC which is not retriable, and the issue
7-
* is encountered deep in a call stack where throwing a checked DoNotRetryIOException is not
8-
* possible (e.g filter/comparator application), this unchecked exception can be thrown
9-
* and will be wrapped in a checked DoNotRetryIOException at the RPC boundary before returning
10-
* to the client to prevent client retries and to propagate the exception message cleanly.
11-
* You should use this exception only when absolutely necessary. Wherever possible, use a checked
12-
* DoNotRetryIOException
23+
* When a fatal issue is encountered during an RPC which is not retriable, and the issue is
24+
* encountered deep in a call stack where throwing a checked DoNotRetryIOException is not possible
25+
* (e.g filter/comparator application), this unchecked exception can be thrown and will be wrapped
26+
* in a checked DoNotRetryIOException at the RPC boundary before returning to the client to prevent
27+
* client retries and to propagate the exception message cleanly. You should use this exception only
28+
* when absolutely necessary. Wherever possible, use a checked DoNotRetryIOException
1329
*/
1430
@InterfaceAudience.Private
1531
public class DoNotRetryRuntimeException extends RuntimeException {

hbase-client/src/main/java/org/apache/hadoop/hbase/filter/BinaryComponentComparator.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929

3030
/**
3131
* A binary comparator which lexicographically compares against the specified byte array similar to
32-
* {@link BinaryComparator} but starts the comparison from the specified offset. Will throw
33-
* a runtime exception if a comparison is attempted with a byte array that
34-
* is too short for the specified offest. See HBASE-22969 for examples on how to use this comparator
32+
* {@link BinaryComparator} but starts the comparison from the specified offset. Will throw a
33+
* runtime exception if a comparison is attempted with a byte array that is too short for the
34+
* specified offest. See HBASE-22969 for examples on how to use this comparator
3535
*/
3636
@InterfaceAudience.Public
3737
@SuppressWarnings("ComparableType")
@@ -50,10 +50,9 @@ public OffsetOutOfBoundsException(String message) {
5050

5151
/**
5252
* @param value the byte array to compare against
53-
* @param offset the starting position (0-based) from which to start comparisons
54-
* Must be less than the length of input arrays being passed
55-
* for comparison, otherwise an {@link OffsetOutOfBoundsException} will be thrown
56-
* on comparison.
53+
* @param offset the starting position (0-based) from which to start comparisons Must be less than
54+
* the length of input arrays being passed for comparison, otherwise an
55+
* {@link OffsetOutOfBoundsException} will be thrown on comparison.
5756
*/
5857
public BinaryComponentComparator(byte[] value, int offset) {
5958
super(value);
@@ -62,7 +61,7 @@ public BinaryComponentComparator(byte[] value, int offset) {
6261

6362
/**
6463
* @throws OffsetOutOfBoundsException if input byte array is too small for the offset provided to
65-
* comparator when it was constructed
64+
* comparator when it was constructed
6665
*/
6766
@Override
6867
public int compareTo(byte[] value) {
@@ -71,13 +70,14 @@ public int compareTo(byte[] value) {
7170

7271
/**
7372
* @throws OffsetOutOfBoundsException if input byte array is too small for the offset provided to
74-
* comparator when it was constructed
73+
* comparator when it was constructed
7574
*/
7675
@Override
7776
public int compareTo(byte[] value, int offset, int length) {
7877
if (offset + this.offset >= value.length) {
79-
String message = String.format("A byte array was encountered with a length %d that is too"
80-
+ " short/incompatible with the offset value %d provided to BinaryComponentComparator",
78+
String message = String.format(
79+
"A byte array was encountered with a length %d that is too"
80+
+ " short/incompatible with the offset value %d provided to BinaryComponentComparator",
8181
value.length, offset + this.offset);
8282
throw new OffsetOutOfBoundsException(message);
8383
}

hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestFiltersWithBinaryComponentComparator.java

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import static org.junit.Assert.assertTrue;
2222
import static org.junit.Assert.fail;
2323

24-
import org.apache.hbase.thirdparty.com.google.common.base.Throwables;;
2524
import java.io.IOException;
2625
import java.util.ArrayList;
2726
import java.util.Arrays;
@@ -52,6 +51,8 @@
5251
import org.slf4j.Logger;
5352
import org.slf4j.LoggerFactory;
5453

54+
import org.apache.hbase.thirdparty.com.google.common.base.Throwables;
55+
5556
@Category(MediumTests.class)
5657
public class TestFiltersWithBinaryComponentComparator {
5758

@@ -153,7 +154,8 @@ public void testRowAndValueFilterWithBinaryComponentComparator() throws IOExcept
153154
ht.close();
154155
}
155156

156-
@Rule public ExpectedException thrown = ExpectedException.none();
157+
@Rule
158+
public ExpectedException thrown = ExpectedException.none();
157159

158160
@Test
159161
public void testThrowsExceptionOnOffsetOutOfBounds() {
@@ -162,7 +164,8 @@ public void testThrowsExceptionOnOffsetOutOfBounds() {
162164
byte[] componentValue = new byte[] { (byte) 'A' };
163165
int offsetValue = 10;
164166
byte[] valueTooShortForOffset = new byte[offsetValue];
165-
BinaryComponentComparator comparator = new BinaryComponentComparator(componentValue, offsetValue);
167+
BinaryComponentComparator comparator =
168+
new BinaryComponentComparator(componentValue, offsetValue);
166169
comparator.compareTo(valueTooShortForOffset);
167170
}
168171

@@ -172,13 +175,14 @@ public void testThrowsExceptionOnOffsetOutOfBounds() {
172175
*/
173176
@Test
174177
public void testOutOfBoundsExceptionIsNotRetryable() throws IOException {
175-
Table table = TEST_UTIL.createTable(TableName.valueOf(name.getMethodName()), family, Integer.MAX_VALUE);
178+
Table table =
179+
TEST_UTIL.createTable(TableName.valueOf(name.getMethodName()), family, Integer.MAX_VALUE);
176180

177181
// ColumnValueFilter with BinaryComponentComparator with offset 10
178182
int offsetValue = 10;
179183
BinaryComponentComparator comparator = new BinaryComponentComparator(new byte[1], offsetValue);
180-
ColumnValueFilter columnValueFilter = new ColumnValueFilter(
181-
family, qf, CompareOperator.EQUAL, comparator);
184+
ColumnValueFilter columnValueFilter =
185+
new ColumnValueFilter(family, qf, CompareOperator.EQUAL, comparator);
182186
Scan scan = new Scan().setFilter(columnValueFilter);
183187

184188
// Insert a row with column value length >= comparator offset
@@ -190,12 +194,12 @@ public void testOutOfBoundsExceptionIsNotRetryable() throws IOException {
190194

191195
// Scan should throw DoNotRetryIOException due to incompatible value length
192196
try (ResultScanner scanner = table.getScanner(scan)) {
193-
scanner.iterator().forEachRemaining(result -> {});
197+
scanner.iterator().forEachRemaining(result -> {
198+
});
194199
fail("Scan completed successfully but should have failed");
195-
}
196-
catch (Exception e) {
197-
boolean expectedExceptionFound = Throwables.getCausalChain(e).stream()
198-
.anyMatch(DoNotRetryIOException.class::isInstance);
200+
} catch (Exception e) {
201+
boolean expectedExceptionFound =
202+
Throwables.getCausalChain(e).stream().anyMatch(DoNotRetryIOException.class::isInstance);
199203
if (!expectedExceptionFound) {
200204
fail("Expected DoNotRetryIOException as the cause, but got: " + e.getCause());
201205
}

0 commit comments

Comments
 (0)