Skip to content

Commit f71c48b

Browse files
committed
Findbug fixes
1 parent b9bb921 commit f71c48b

File tree

3 files changed

+46
-17
lines changed

3 files changed

+46
-17
lines changed

hadoop-project/pom.xml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@
206206
<powermock.version>1.5.6</powermock.version>
207207
<solr.version>7.7.0</solr.version>
208208
<openssl-wildfly.version>1.0.7.Final</openssl-wildfly.version>
209+
<hamcrest.version>1.3</hamcrest.version>
209210
</properties>
210211

211212
<dependencyManagement>
@@ -1355,6 +1356,11 @@
13551356
<artifactId>jsr305</artifactId>
13561357
<version>3.0.2</version>
13571358
</dependency>
1359+
<dependency>
1360+
<groupId>com.google.code.findbugs</groupId>
1361+
<artifactId>annotations</artifactId>
1362+
<version>3.0.1</version>
1363+
</dependency>
13581364
<dependency>
13591365
<groupId>javax.xml.bind</groupId>
13601366
<artifactId>jaxb-api</artifactId>
@@ -1682,7 +1688,13 @@
16821688
<dependency>
16831689
<groupId>org.hamcrest</groupId>
16841690
<artifactId>hamcrest-library</artifactId>
1685-
<version>1.3</version>
1691+
<version>${hamcrest.version}</version>
1692+
</dependency>
1693+
<dependency>
1694+
<groupId>org.hamcrest</groupId>
1695+
<artifactId>hamcrest-core</artifactId>
1696+
<version>${hamcrest.version}</version>
1697+
<scope>test</scope>
16861698
</dependency>
16871699
<dependency>
16881700
<groupId>org.assertj</groupId>
@@ -1710,6 +1722,14 @@
17101722
<artifactId>jna</artifactId>
17111723
<version>${jna.version}</version>
17121724
</dependency>
1725+
1726+
<dependency>
1727+
<groupId>net.jodah</groupId>
1728+
<artifactId>concurrentunit</artifactId>
1729+
<version>0.4.6</version>
1730+
<scope>test</scope>
1731+
</dependency>
1732+
17131733
</dependencies>
17141734
</dependencyManagement>
17151735

hadoop-tools/hadoop-azure/pom.xml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,12 @@
172172
<groupId>com.google.guava</groupId>
173173
<artifactId>guava</artifactId>
174174
</dependency>
175+
<dependency>
176+
<groupId>com.google.code.findbugs</groupId>
177+
<artifactId>annotations</artifactId>
178+
<version>3.0.1</version>
179+
<scope>provided</scope>
180+
</dependency>
175181

176182
<dependency>
177183
<groupId>org.eclipse.jetty</groupId>
@@ -212,6 +218,11 @@
212218
<scope>provided</scope>
213219
</dependency>
214220

221+
<dependency>
222+
<groupId>com.google.code.findbugs</groupId>
223+
<artifactId>annotations</artifactId>
224+
</dependency>
225+
215226
<!-- dependencies use for test only -->
216227
<dependency>
217228
<groupId>junit</groupId>
@@ -288,19 +299,14 @@
288299
<artifactId>hamcrest-library</artifactId>
289300
<scope>test</scope>
290301
</dependency>
291-
292-
<!-- https://.mvnrepository.com/artifact/net.jodah/concurrentunit -->
293302
<dependency>
294-
<groupId>net.jodah</groupId>
295-
<artifactId>concurrentunit</artifactId>
296-
<version>0.4.6</version>
303+
<groupId>org.hamcrest</groupId>
304+
<artifactId>hamcrest-core</artifactId>
297305
<scope>test</scope>
298306
</dependency>
299-
<!-- https://mvnrepository.com/artifact/org.hamcrest/hamcrest-core -->
300307
<dependency>
301-
<groupId>org.hamcrest</groupId>
302-
<artifactId>hamcrest-core</artifactId>
303-
<version>1.3</version>
308+
<groupId>net.jodah</groupId>
309+
<artifactId>concurrentunit</artifactId>
304310
<scope>test</scope>
305311
</dependency>
306312

hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsByteBufferPool.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@
1818

1919
package org.apache.hadoop.fs.azurebfs.services;
2020

21+
import java.util.concurrent.ArrayBlockingQueue;
22+
2123
import com.google.common.annotations.VisibleForTesting;
2224
import com.google.common.base.Preconditions;
23-
24-
import java.util.concurrent.ArrayBlockingQueue;
25+
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
2526

2627
import static java.lang.Math.ceil;
2728
import static java.lang.Math.min;
29+
2830
import static org.apache.hadoop.fs.azurebfs.constants.FileSystemConfigurations.MAX_VALUE_MAX_AZURE_WRITE_MEM_USAGE_PERCENTAGE;
2931
import static org.apache.hadoop.fs.azurebfs.constants.FileSystemConfigurations.MIN_VALUE_MAX_AZURE_WRITE_MEM_USAGE_PERCENTAGE;
3032

@@ -81,18 +83,18 @@ private void validate(final int queueCapacity,
8183
.checkArgument(queueCapacity > 0, "queueCapacity cannot be < 1");
8284
}
8385

84-
private boolean isPossibleToIssueNewBuffer() {
86+
private synchronized boolean isPossibleToIssueNewBuffer() {
8587
Runtime rt = Runtime.getRuntime();
86-
double bufferCountByMaxFreeBuffers = ceil(
87-
maxBuffersToPool + rt.availableProcessors());
88+
int bufferCountByMaxFreeBuffers =
89+
maxBuffersToPool + rt.availableProcessors();
8890
if (numBuffersInUse >= bufferCountByMaxFreeBuffers) {
8991
return false;
9092
}
9193

9294
double freeMemory = rt.maxMemory() - (rt.totalMemory() - rt.freeMemory());
93-
double bufferCountByMemory = ceil(
95+
int bufferCountByMemory = (int) ceil(
9496
(freeMemory * maxMemUsagePercentage / HUNDRED) / bufferSize);
95-
int maxBuffersThatCanBeInUse = (int) min(bufferCountByMemory,
97+
int maxBuffersThatCanBeInUse = min(bufferCountByMemory,
9698
bufferCountByMaxFreeBuffers);
9799
if (maxBuffersThatCanBeInUse < 2) {
98100
maxBuffersThatCanBeInUse = 2;
@@ -133,6 +135,7 @@ public byte[] get() {
133135
/**
134136
* @param byteArray The buffer to be offered back to the pool.
135137
*/
138+
@SuppressFBWarnings("RV_RETURN_VALUE_IGNORED")
136139
public synchronized void release(byte[] byteArray) {
137140
Preconditions.checkArgument(byteArray.length == bufferSize,
138141
"Buffer size has" + " to be %s (Received buffer length: %s)",

0 commit comments

Comments
 (0)