Skip to content

Commit 1048b2b

Browse files
committed
Findbugs; add to verify phase, address current issues
1 parent 04a1127 commit 1048b2b

64 files changed

Lines changed: 400 additions & 308 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ cache:
1717
directories:
1818
- $HOME/.m2
1919
install: "mvn -q clean install javadoc:aggregate -Dfindbugs.skip -Daccumulo.version=${ACCUMULO_VERSION} ${ACCUMULO_LEGACY} -Dhadoop.version=${HADOOP_VERSION} -Dgeotools.version=${GEOTOOLS_VERSION} -Dgeoserver.version=${GEOSERVER_VERSION} -DskipITs=true -DskipTests=true -P ${PLATFORM_VERSION}; .utility/build-docs-site.sh"
20-
script: "mvn -q verify -Daccumulo.version=${ACCUMULO_VERSION} ${ACCUMULO_LEGACY} -Dhadoop.version=${HADOOP_VERSION} -Dgeotools.version=${GEOTOOLS_VERSION} -Dgeoserver.version=${GEOSERVER_VERSION} -P ${PLATFORM_VERSION}"
20+
script: "mvn -q -T 2C verify -Daccumulo.version=${ACCUMULO_VERSION} ${ACCUMULO_LEGACY} -Dhadoop.version=${HADOOP_VERSION} -Dgeotools.version=${GEOTOOLS_VERSION} -Dgeoserver.version=${GEOSERVER_VERSION} -P ${PLATFORM_VERSION}"
2121
before_install:
2222
- export MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=192m"
2323
- chmod +x .utility/push-javadoc-to-gh-pages.sh

geowave-accumulo/src/main/java/mil/nga/giat/geowave/accumulo/mapreduce/input/GeoWaveInputFormat.java

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,10 @@
33
import java.io.IOException;
44
import java.math.BigInteger;
55
import java.net.InetAddress;
6-
import java.util.ArrayList;
7-
import java.util.Comparator;
8-
import java.util.HashMap;
9-
import java.util.HashSet;
10-
import java.util.Iterator;
11-
import java.util.List;
12-
import java.util.Map;
6+
import java.util.*;
137
import java.util.Map.Entry;
14-
import java.util.Set;
15-
import java.util.TreeSet;
168

9+
import com.google.common.base.*;
1710
import mil.nga.giat.geowave.accumulo.AccumuloOperations;
1811
import mil.nga.giat.geowave.accumulo.mapreduce.GeoWaveConfiguratorBase;
1912
import mil.nga.giat.geowave.accumulo.mapreduce.JobContextAdapterStore;
@@ -482,6 +475,7 @@ private TreeSet<IntermediateSplitInfo> getIntermediateSplits(
482475
final String instanceId = instance.getInstanceID();
483476
final List<Range> rangeList = new ArrayList<Range>(
484477
ranges);
478+
Random r = new Random();
485479
while (!binRanges(
486480
rangeList,
487481
getUserName(context),
@@ -506,7 +500,7 @@ private TreeSet<IntermediateSplitInfo> getIntermediateSplits(
506500
}
507501
tserverBinnedRanges.clear();
508502
LOGGER.warn("Unable to locate bins for specified ranges. Retrying.");
509-
UtilWaitThread.sleep(100 + (int) (Math.random() * 100));
503+
UtilWaitThread.sleep(100 + r.nextInt(101));
510504
// sleep randomly between 100 and 200 ms
511505
tl.invalidateCache();
512506
}
@@ -911,6 +905,28 @@ public int compareTo(
911905
return retVal;
912906
}
913907

908+
@Override
909+
public boolean equals(
910+
Object obj ) {
911+
if (obj == null) {
912+
return false;
913+
}
914+
if (!(obj instanceof IntermediateSplitInfo)) {
915+
return false;
916+
}
917+
return this.compareTo((IntermediateSplitInfo) obj) == 0;
918+
}
919+
920+
@Override
921+
public int hashCode() {
922+
// think this matches the spirit of compareTo
923+
int mc = getMaxCardinality();
924+
return com.google.common.base.Objects.hashCode(
925+
mc,
926+
getTotalRangeAtCardinality(mc),
927+
super.hashCode());
928+
}
929+
914930
private synchronized BigInteger getTotalRangeAtCardinality(
915931
final int cardinality ) {
916932
final BigInteger totalRange = totalRangePerCardinalityCache.get(cardinality);

geowave-accumulo/src/main/java/mil/nga/giat/geowave/accumulo/mapreduce/output/GeoWaveOutputFormat.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public OutputCommitter getOutputCommitter(
169169
* A base class to be used to create {@link RecordWriter} instances that
170170
* write to Accumulo.
171171
*/
172-
protected class GeoWaveRecordWriter extends
172+
protected static class GeoWaveRecordWriter extends
173173
RecordWriter<GeoWaveOutputKey, Object>
174174
{
175175
private final Map<ByteArrayId, IndexWriter> indexWriterCache = new HashMap<ByteArrayId, IndexWriter>();

geowave-accumulo/src/main/java/mil/nga/giat/geowave/accumulo/util/EntryIteratorWrapper.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ public boolean hasNext() {
9494
public T next()
9595
throws NoSuchElementException {
9696
final T previousNext = nextValue;
97+
if (nextValue == null) {
98+
throw new NoSuchElementException();
99+
}
97100
nextValue = null;
98101
return previousNext;
99102
}

geowave-accumulo/src/main/java/mil/nga/giat/geowave/accumulo/util/InputFormatIteratorWrapper.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ public boolean hasNext() {
116116
public Entry<GeoWaveInputKey, T> next()
117117
throws NoSuchElementException {
118118
final Entry<GeoWaveInputKey, T> previousNext = nextValue;
119+
if (nextValue == null) {
120+
throw new NoSuchElementException();
121+
}
119122
nextValue = null;
120123
return previousNext;
121124
}

geowave-accumulo/src/main/java/mil/nga/giat/geowave/accumulo/util/IteratorWrapper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public IteratorWrapper(
5555
}
5656

5757
@Override
58-
public boolean hasNext() {
58+
public synchronized boolean hasNext() {
5959
if (conversionQueue.hasNext()) {
6060
return true;
6161
}
@@ -91,7 +91,7 @@ private synchronized void notifyIterationComplete() {
9191
}
9292

9393
@Override
94-
public void remove() {
94+
public synchronized void remove() {
9595
conversionQueue.remove();
9696
inputIterator.remove();
9797
}

geowave-accumulo/src/test/java/mil/nga/giat/geowave/accumulo/query/AccumuloRangeQueryTest.java

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import java.util.*;
44

5-
65
import com.vividsolutions.jts.geom.Polygon;
76
import com.vividsolutions.jts.io.ParseException;
87
import com.vividsolutions.jts.io.WKBReader;
@@ -135,8 +134,9 @@ public void largeQuery() {
135134
}
136135

137136
/**
138-
* Verifies equality for interning is still working as expected (topologically),
139-
* as the the largeQuery() test has a dependency on this;
137+
* Verifies equality for interning is still working as expected
138+
* (topologically), as the the largeQuery() test has a dependency on this;
139+
*
140140
* @throws ParseException
141141
*/
142142
@Test
@@ -189,10 +189,18 @@ public void testInterning()
189189
final Geometry gSerialized = wkbReader.read(b);
190190
final Geometry gSerializedArrayCopy = wkbReader.read(b2);
191191

192-
Assert.assertEquals(g, gNewInstance);
193-
Assert.assertEquals(g, gSerializedArrayCopy);
194-
Assert.assertEquals(gSerialized, gSerializedArrayCopy);
195-
Assert.assertEquals(gSerialized, gSerializedArrayCopy);
192+
Assert.assertEquals(
193+
g,
194+
gNewInstance);
195+
Assert.assertEquals(
196+
g,
197+
gSerializedArrayCopy);
198+
Assert.assertEquals(
199+
gSerialized,
200+
gSerializedArrayCopy);
201+
Assert.assertEquals(
202+
gSerialized,
203+
gSerializedArrayCopy);
196204
}
197205

198206
@Test

geowave-analytics/src/main/java/mil/nga/giat/geowave/analytics/GaussianFilter.java

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -231,26 +231,6 @@ public static void incrementBBox(
231231
}
232232
}
233233

234-
public static void main(
235-
final String[] args ) {
236-
for (int radius = 4; radius >= 1; radius--) {
237-
for (int i = -5; i <= 5; i++) {
238-
final double sigma = getSigma(
239-
radius,
240-
i);
241-
final double[] kernel = getGaussianKernel(
242-
sigma,
243-
radius);
244-
final StringBuffer buffer = new StringBuffer();
245-
for (final double k : kernel) {
246-
buffer.append(
247-
k).append(
248-
", ");
249-
}
250-
}
251-
}
252-
}
253-
254234
protected static double getSigma(
255235
final int radius,
256236
final int order ) {

geowave-analytics/src/main/java/mil/nga/giat/geowave/analytics/clustering/DistortionGroupManagement.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ public static <T> int retainBestGroups(
100100
grp.getGroupID());
101101
}
102102
}
103+
catch (final RuntimeException ex) {
104+
throw ex;
105+
}
103106
catch (final Exception ex) {
104107
LOGGER.error(
105108
"Cannot detremine groups for batch" + parentBatchId,

geowave-analytics/src/main/java/mil/nga/giat/geowave/analytics/distance/CoordinateCircleDistanceFn.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class CoordinateCircleDistanceFn implements
1212
DistanceFn<Coordinate>
1313
{
1414

15-
protected static CoordinateReferenceSystem DEFAULT_CRS;
15+
protected static final CoordinateReferenceSystem DEFAULT_CRS;
1616
static {
1717
try {
1818
DEFAULT_CRS = CRS.decode(

0 commit comments

Comments
 (0)