Skip to content

Commit ef5b703

Browse files
leerhojmalkin
authored andcommitted
All except 2 of the fixes here were security related fixes to harden our
classes against "finalizer attacks". See https://wiki.sei.cmu.edu/confluence/display/java/OBJ11-J.+Be+wary+of+letting+constructors+throw+exceptions
1 parent b50100d commit ef5b703

20 files changed

+69
-8
lines changed

src/main/java/org/apache/datasketches/fdt/FdtSketch.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
*
4747
* @author Lee Rhodes
4848
*/
49-
public class FdtSketch extends ArrayOfStringsSketch {
49+
public final class FdtSketch extends ArrayOfStringsSketch {
5050

5151
/**
5252
* Create new instance of Frequent Distinct Tuples sketch with the given

src/main/java/org/apache/datasketches/hll/CouponHashSet.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
* @author Lee Rhodes
4343
* @author Kevin Lang
4444
*/
45-
class CouponHashSet extends CouponList {
45+
final class CouponHashSet extends CouponList {
4646

4747
/**
4848
* Constructs this sketch with the intent of loading it with data

src/main/java/org/apache/datasketches/hll/CouponList.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ class CouponList extends AbstractCoupons {
4141
int couponCount;
4242
int[] couponIntArr;
4343

44+
@Override
45+
protected final void finalize() {
46+
// SpotBugs CT_CONSTUCTOR_THROW, OBJ11-J
47+
}
48+
4449
/**
4550
* New instance constructor for LIST or SET.
4651
* @param lgConfigK the configured Lg K

src/main/java/org/apache/datasketches/hll/DirectAuxHashMap.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
/**
3737
* @author Lee Rhodes
3838
*/
39-
class DirectAuxHashMap implements AuxHashMap {
39+
final class DirectAuxHashMap implements AuxHashMap {
4040
private final DirectHllArray host; //hosts the WritableMemory and read-only Memory
4141
private final boolean readOnly;
4242

src/main/java/org/apache/datasketches/hll/DirectCouponHashSet.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
/**
4343
* @author Lee Rhodes
4444
*/
45-
class DirectCouponHashSet extends DirectCouponList {
45+
final class DirectCouponHashSet extends DirectCouponList {
4646

4747
//Constructs this sketch with data.
4848
DirectCouponHashSet(final int lgConfigK, final TgtHllType tgtHllType,

src/main/java/org/apache/datasketches/hll/DirectCouponList.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ class DirectCouponList extends AbstractCoupons {
6161
Memory mem;
6262
final boolean compact;
6363

64+
@Override
65+
protected final void finalize() {
66+
// SpotBugs CT_CONSTUCTOR_THROW, OBJ11-J
67+
}
68+
6469
//called from newInstance, writableWrap and DirectCouponHashSet
6570
DirectCouponList(final int lgConfigK, final TgtHllType tgtHllType, final CurMode curMode,
6671
final WritableMemory wmem) {

src/main/java/org/apache/datasketches/hll/DirectHllArray.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ abstract class DirectHllArray extends AbstractHllArray {
5959
long memAdd;
6060
final boolean compact;
6161

62+
@Override
63+
protected final void finalize() {
64+
// SpotBugs CT_CONSTUCTOR_THROW, OBJ11-J
65+
}
66+
6267
//Memory must be already initialized and may have data
6368
DirectHllArray(final int lgConfigK, final TgtHllType tgtHllType, final WritableMemory wmem) {
6469
super(lgConfigK, tgtHllType, CurMode.HLL);

src/main/java/org/apache/datasketches/hll/HeapAuxHashMap.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
* @author Lee Rhodes
3434
* @author Kevin Lang
3535
*/
36-
class HeapAuxHashMap implements AuxHashMap {
36+
final class HeapAuxHashMap implements AuxHashMap {
3737
private final int lgConfigK; //required for #slot bits
3838
private int lgAuxArrInts;
3939
private int auxCount;

src/main/java/org/apache/datasketches/hllmap/UniqueCountMap.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
* @author Alexander Saydakov
8181
* @author Kevin Lang
8282
*/
83-
public class UniqueCountMap {
83+
public final class UniqueCountMap {
8484
private static final String LS = System.getProperty("line.separator");
8585
private static final int NUM_LEVELS = 10; // total of single coupon + traverse + coupon maps + hll
8686
private static final int NUM_TRAVERSE_MAPS = 3;

src/main/java/org/apache/datasketches/kll/KllItemsSketchSortedView.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ public class KllItemsSketchSortedView<T> implements GenericSortedView<T>, Partit
5656
private final T minItem;
5757
private final Class<T> clazz;
5858

59+
@Override
60+
protected final void finalize() {
61+
// SpotBugs CT_CONSTUCTOR_THROW, OBJ11-J
62+
}
63+
5964
/**
6065
* Construct from elements for testing only.
6166
* @param quantiles sorted array of quantiles

0 commit comments

Comments
 (0)