Skip to content

Commit 81efa17

Browse files
authored
HBASE-22509 Address findbugs/spotbugs complaints (branch-1.4) (#277)
Signed-off-by: Sean Busbey <busbey@apache.org>
1 parent fdbe797 commit 81efa17

4 files changed

Lines changed: 22 additions & 6 deletions

File tree

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

Lines changed: 6 additions & 1 deletion
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.ourBytes);
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. " +
@@ -272,6 +272,11 @@ private static class BufferGrabbingByteArrayOutputStream extends ByteArrayOutput
272272
public synchronized void write(byte[] b, int off, int len) {
273273
this.ourBytes = b;
274274
}
275+
276+
@Override
277+
public synchronized byte[] toByteArray() {
278+
return ourBytes;
279+
}
275280
}
276281

277282
@Override

hbase-hadoop2-compat/src/main/java/org/apache/hadoop/metrics2/lib/MetricsExecutorImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public void stop() {
4848

4949
private enum ExecutorSingleton {
5050
INSTANCE;
51-
private final ScheduledExecutorService scheduler = new ScheduledThreadPoolExecutor(1,
51+
private transient final ScheduledExecutorService scheduler = new ScheduledThreadPoolExecutor(1,
5252
new ThreadPoolExecutorThreadFactory("HBase-Metrics2-"));
5353
}
5454

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
@@ -7963,7 +7963,9 @@ public Result append(Append mutate, long nonceGroup, long nonce) throws IOExcept
79637963
for (Map.Entry<Store, List<Cell>> entry: removedCellsForMemStore.entrySet()) {
79647964
entry.getKey().add(entry.getValue());
79657965
}
7966-
if (we != null) mvcc.complete(we);
7966+
if (we != null) {
7967+
mvcc.complete(we);
7968+
}
79677969
} else if (we != null) {
79687970
mvcc.completeAndWait(we);
79697971
}
@@ -8184,16 +8186,21 @@ private Result doIncrement(Increment increment, long nonceGroup, long nonce) thr
81848186
rowLock.release();
81858187
}
81868188
// if the wal sync was unsuccessful, remove keys from memstore
8189+
WriteEntry we = walKey != null ? walKey.getWriteEntry() : null;
81878190
if (doRollBackMemstore) {
81888191
for (Map.Entry<Store, List<Cell>> entry: forMemStore.entrySet()) {
81898192
rollbackMemstore(entry.getKey(), entry.getValue());
81908193
}
81918194
for (Map.Entry<Store, List<Cell>> entry: removedCellsForMemStore.entrySet()) {
81928195
entry.getKey().add(entry.getValue());
81938196
}
8194-
if (walKey != null) mvcc.complete(walKey.getWriteEntry());
8197+
if (we != null) {
8198+
mvcc.complete(we);
8199+
}
81958200
} else {
8196-
if (walKey != null) mvcc.completeAndWait(walKey.getWriteEntry());
8201+
if (we != null) {
8202+
mvcc.completeAndWait(we);
8203+
}
81978204
}
81988205
}
81998206

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
@@ -2836,10 +2836,14 @@ private void removeCompactedfiles(Collection<StoreFile> compactedfiles)
28362836
// Just close and return
28372837
filesToRemove.add(file);
28382838
} else {
2839-
LOG.info("Can't archive compacted file " + file.getPath()
2839+
if (r != null) {
2840+
LOG.info("Can't archive compacted file " + file.getPath()
28402841
+ " because of either isCompactedAway=" + r.isCompactedAway()
28412842
+ " or file has reference, isReferencedInReads=" + r.isReferencedInReads()
28422843
+ ", refCount=" + r.getRefCount() + ", skipping for now.");
2844+
} else {
2845+
LOG.info("Can't archive compacted file " + file.getPath() + ", skipping for now.");
2846+
}
28432847
}
28442848
} catch (Exception e) {
28452849
LOG.error(

0 commit comments

Comments
 (0)