Skip to content

Commit 93a58da

Browse files
committed
HBASE-22510 Address findbugs/spotbugs complaints (branch-1)
1 parent e233cfb commit 93a58da

File tree

6 files changed

+27
-14
lines changed

6 files changed

+27
-14
lines changed

hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/EncodedDataBlock.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ public byte[] encodeData() {
255255
}
256256
BufferGrabbingByteArrayOutputStream stream = new BufferGrabbingByteArrayOutputStream();
257257
baos.writeTo(stream);
258-
this.dataBlockEncoder.endBlockEncoding(encodingCtx, out, stream.getOurBytes());
258+
this.dataBlockEncoder.endBlockEncoding(encodingCtx, out, stream.toByteArray());
259259
} catch (IOException e) {
260260
throw new RuntimeException(String.format(
261261
"Bug in encoding part of algorithm %s. " +
@@ -268,14 +268,15 @@ public byte[] encodeData() {
268268
private static class BufferGrabbingByteArrayOutputStream extends ByteArrayOutputStream {
269269
private byte[] ourBytes;
270270

271-
private synchronized byte[] getOurBytes() {
272-
return ourBytes;
273-
}
274-
275271
@Override
276272
public synchronized void write(byte[] b, int off, int len) {
277273
this.ourBytes = b;
278274
}
275+
276+
@Override
277+
public synchronized byte[] toByteArray() {
278+
return ourBytes;
279+
}
279280
}
280281

281282
@Override

hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3078,7 +3078,7 @@ public List<String> listNamespaces() throws IOException {
30783078
}
30793079
}
30803080
if (cpHost != null) {
3081-
bypass = cpHost.postListNamespaces(namespaces);
3081+
cpHost.postListNamespaces(namespaces);
30823082
}
30833083
return namespaces;
30843084
}

hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/MasterQuotaManager.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -440,9 +440,10 @@ private void applyThrottle(final Quotas.Builder quotas, final ThrottleRequest re
440440
case READ_SIZE:
441441
if (req.hasTimedQuota()) {
442442
throttle.setReadSize(req.getTimedQuota());
443-
} else {
444-
throttle.clearReadSize();
445-
}
443+
} else {
444+
throttle.clearReadSize();
445+
}
446+
break;
446447
case REQUEST_CAPACITY_UNIT:
447448
if (req.hasTimedQuota()) {
448449
throttle.setReqCapacityUnit(req.getTimedQuota());

hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7959,7 +7959,9 @@ public Result append(Append mutate, long nonceGroup, long nonce) throws IOExcept
79597959
for (Map.Entry<Store, List<Cell>> entry: removedCellsForMemStore.entrySet()) {
79607960
entry.getKey().add(entry.getValue());
79617961
}
7962-
if (we != null) mvcc.complete(we);
7962+
if (we != null) {
7963+
mvcc.complete(we);
7964+
}
79637965
} else if (we != null) {
79647966
mvcc.completeAndWait(we);
79657967
}
@@ -8180,16 +8182,21 @@ private Result doIncrement(Increment increment, long nonceGroup, long nonce) thr
81808182
rowLock.release();
81818183
}
81828184
// if the wal sync was unsuccessful, remove keys from memstore
8185+
WriteEntry we = walKey != null ? walKey.getWriteEntry() : null;
81838186
if (doRollBackMemstore) {
81848187
for (Map.Entry<Store, List<Cell>> entry: forMemStore.entrySet()) {
81858188
rollbackMemstore(entry.getKey(), entry.getValue());
81868189
}
81878190
for (Map.Entry<Store, List<Cell>> entry: removedCellsForMemStore.entrySet()) {
81888191
entry.getKey().add(entry.getValue());
81898192
}
8190-
if (walKey != null) mvcc.complete(walKey.getWriteEntry());
8193+
if (we != null) {
8194+
mvcc.complete(we);
8195+
}
81918196
} else {
8192-
if (walKey != null) mvcc.completeAndWait(walKey.getWriteEntry());
8197+
if (we != null) {
8198+
mvcc.completeAndWait(we);
8199+
}
81938200
}
81948201
}
81958202

hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HStore.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2796,10 +2796,14 @@ private void removeCompactedfiles(Collection<StoreFile> compactedfiles)
27962796
// Just close and return
27972797
filesToRemove.add(file);
27982798
} else {
2799-
LOG.info("Can't archive compacted file " + file.getPath()
2799+
if (r != null) {
2800+
LOG.info("Can't archive compacted file " + file.getPath()
28002801
+ " because of either isCompactedAway=" + r.isCompactedAway()
28012802
+ " or file has reference, isReferencedInReads=" + r.isReferencedInReads()
28022803
+ ", refCount=" + r.getRefCount() + ", skipping for now.");
2804+
} else {
2805+
LOG.info("Can't archive compacted file " + file.getPath() + ", skipping for now.");
2806+
}
28032807
}
28042808
} catch (Exception e) {
28052809
LOG.error(

hbase-server/src/main/java/org/apache/hadoop/hbase/util/compaction/MajorCompactor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
public class MajorCompactor extends Configured implements Tool {
7070

7171
private static final Logger LOG = LoggerFactory.getLogger(MajorCompactor.class);
72-
protected static final Set<MajorCompactionRequest> ERRORS = Sets.newHashSet();
72+
static final Set<MajorCompactionRequest> ERRORS = Sets.newHashSet();
7373

7474
protected ClusterCompactionQueues clusterCompactionQueues;
7575
private long timestamp;

0 commit comments

Comments
 (0)