Skip to content

Enable strict compiler settings #413

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 42 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
15e39ec
enable compiler warnings and linting
bpkroth Dec 7, 2023
d66eaba
address some trailing whitespace warnings
bpkroth Dec 7, 2023
9fde340
Merge branch 'main' into strict-compiler
bpkroth Dec 8, 2023
3b3906c
compiler fixups
bpkroth Dec 8, 2023
092e06d
compiler fixups
bpkroth Dec 8, 2023
8038636
add some warning suppressions for unused variables
bpkroth Dec 8, 2023
139c953
omit those entirely
bpkroth Dec 8, 2023
259cca6
fixups
bpkroth Dec 8, 2023
77c74ae
whitespace
bpkroth Dec 8, 2023
7abe2e8
use autoclose
bpkroth Dec 8, 2023
a3f7fec
remove more suppressed cast issues
bpkroth Dec 8, 2023
554406d
unnecessary cast
bpkroth Dec 8, 2023
79e7187
avoid unused errors
bpkroth Dec 8, 2023
d93caf7
add serialization requirements
bpkroth Dec 8, 2023
7f89237
whitespace
bpkroth Dec 8, 2023
ff5507d
more minor avoid raw type issues
bpkroth Dec 8, 2023
fc97c1e
in the couple of utility classes, just suppress more warnings
bpkroth Dec 8, 2023
5220c3f
convert throw type to avoid InterruptedException handling warnings
bpkroth Dec 8, 2023
df432f3
docs
bpkroth Dec 8, 2023
d93c61d
enable deprecations
bpkroth Dec 8, 2023
b0398b1
more compiler warning fixups
bpkroth Dec 8, 2023
db891e9
Merge branch 'main' into strict-compiler
bpkroth Dec 8, 2023
c53ea80
revert order
bpkroth Dec 8, 2023
e5e9c00
need the col++
bpkroth Dec 8, 2023
94385e7
address some unused and other lint issues
bpkroth Dec 8, 2023
448ca24
fixup
bpkroth Dec 8, 2023
1e411d4
fixup
bpkroth Dec 8, 2023
2937b46
add a readme with additional developer notes per PR suggestion
bpkroth Dec 11, 2023
4b22f8d
tweak comment
bpkroth Dec 11, 2023
fa34754
add more developer notes
bpkroth Dec 11, 2023
be0f414
include some extension recommendations
bpkroth Dec 11, 2023
43b5cee
update extensions
bpkroth Dec 11, 2023
4556f10
address more unused warnings
bpkroth Dec 11, 2023
5939e2d
ignore another error
bpkroth Dec 11, 2023
4f0fe4c
Merge branch 'main' into strict-compiler
bpkroth Dec 13, 2023
ebb52de
addressing some new serialization warnings
bpkroth Dec 13, 2023
adb1a96
comments
bpkroth Dec 13, 2023
acd47aa
adjust constructor to avoid this-escape errors
bpkroth Dec 13, 2023
d350c6e
convert a pile of classes to 'final' to avoid this-escape errors
bpkroth Dec 13, 2023
3437b2d
auto-whitespace
bpkroth Dec 13, 2023
b2e7489
comments about this-escape warnings
bpkroth Dec 13, 2023
b526294
exception
bpkroth Dec 13, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,15 @@
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
<showDeprecation>true</showDeprecation>
<showWarnings>true</showWarnings>
<compilerArgs>
<!-- Enable all linter messages for the compiler. -->
<!-- TODO: Remove annotations preprocess warning exception. -->
<arg>-Xlint:all,-processing</arg>
<!-- Turn all warnings into errors to help keep the code clean. -->
<arg>-Werror</arg>
</compilerArgs>
</configuration>
</plugin>
<plugin>
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/com/oltpbenchmark/api/StatementDialects.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import com.oltpbenchmark.WorkloadConfiguration;
import com.oltpbenchmark.api.dialects.*;
import com.oltpbenchmark.types.DatabaseType;
import com.oltpbenchmark.types.State;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xml.sax.SAXException;
Expand All @@ -30,7 +29,6 @@
import javax.xml.transform.stream.StreamSource;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringWriter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,9 @@
import java.util.List;

public class AuctionMarkBenchmark extends BenchmarkModule {

@SuppressWarnings("unused")
private static final Logger LOG = LoggerFactory.getLogger(AuctionMarkBenchmark.class);


private final RandomGenerator rng = new RandomGenerator((int) System.currentTimeMillis());

public AuctionMarkBenchmark(WorkloadConfiguration workConf) {
Expand Down Expand Up @@ -70,6 +69,4 @@ protected List<Worker<? extends BenchmarkModule>> makeWorkersImpl() {
protected Loader<AuctionMarkBenchmark> makeLoaderImpl() {
return new AuctionMarkLoader(this);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -1195,6 +1195,7 @@ protected class ItemBidGenerator extends SubTableGenerator<LoaderItemInfo> {
private LoaderItemInfo.Bid bid = null;
private float currentBidPriceAdvanceStep;
private long currentCreateDateAdvanceStep;
@SuppressWarnings("unused") // spurious
private float currentPrice;
private boolean new_item;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public class AuctionMarkProfile {
// ----------------------------------------------------------------
// SERIALIZABLE DATA MEMBERS
// ----------------------------------------------------------------
static final long serialVersionUID = 0;

/**
* Database Scale Factor
Expand Down Expand Up @@ -108,6 +109,14 @@ public class AuctionMarkProfile {
*/
protected transient Histogram<Integer> items_per_category = new Histogram<>();

/**
* Simple generic class overload to avoid some cast warnings below.
*/
class ItemInfoList extends LinkedList<ItemInfo> {
// Required serialization field.
static final long serialVersionUID = 0;
}

/**
* Three status types for an item:
* (1) Available - The auction of this item is still open
Expand All @@ -117,13 +126,13 @@ public class AuctionMarkProfile {
* (3) Complete (The auction is closed and (There is no bid winner or
* the bid winner has already purchased the item)
*/
private transient final LinkedList<ItemInfo> items_available = new LinkedList<>();
private transient final LinkedList<ItemInfo> items_endingSoon = new LinkedList<>();
private transient final LinkedList<ItemInfo> items_waitingForPurchase = new LinkedList<>();
private transient final LinkedList<ItemInfo> items_completed = new LinkedList<>();
private transient final ItemInfoList items_available = new ItemInfoList();
private transient final ItemInfoList items_endingSoon = new ItemInfoList();
private transient final ItemInfoList items_waitingForPurchase = new ItemInfoList();
private transient final ItemInfoList items_completed = new ItemInfoList();


@SuppressWarnings("unchecked")
protected transient final LinkedList<ItemInfo>[] allItemSets = new LinkedList[]{
protected transient final ItemInfoList allItemSets[] = new ItemInfoList[]{
this.items_available,
this.items_endingSoon,
this.items_waitingForPurchase,
Expand Down Expand Up @@ -286,7 +295,7 @@ private AuctionMarkProfile copyProfile(AuctionMarkWorker worker, AuctionMarkProf
this.items_per_category = other.items_per_category;
this.gag_ids = other.gag_ids;

// Initialize the UserIdGenerator so we can figure out whether our
// Initialize the UserIdGenerator so we can figure out whether our
// client should even have these ids
this.initializeUserIdGenerator(this.client_id);

Expand Down Expand Up @@ -455,7 +464,6 @@ private static void loadItems(AuctionMarkProfile profile, List<Object[]> vt) {

private static void loadPendingItemComments(AuctionMarkProfile profile, List<Object[]> vt) {
for (Object[] row : vt) {
int col = 1;
long ic_id = SQLUtil.getLong(row[0]);
String ic_i_id = SQLUtil.getString(row[1]);
String ic_u_id = SQLUtil.getString(row[2]);
Expand Down Expand Up @@ -712,6 +720,7 @@ private boolean addItem(LinkedList<ItemInfo> items, ItemInfo itemInfo) {
// HACK: Always swap existing ItemInfos with our new one, since it will
// more up-to-date information
ItemInfo existing = items.set(idx, itemInfo);
assert existing != null;

return (true);
}
Expand Down Expand Up @@ -861,7 +870,7 @@ private ItemInfo getRandomItem(LinkedList<ItemInfo> itemSet, boolean needCurrent
continue;
}

// If they want an item that is ending in the future, then we compare it with
// If they want an item that is ending in the future, then we compare it with
// the current timestamp
if (needFutureEndDate) {
boolean compareTo = (temp.getEndDate().compareTo(currentTime) < 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,10 @@ protected TransactionStatus executeWork(Connection conn, TransactionType txnType
public ItemId processItemRecord(Object[] row) {
int col = 0;
ItemId i_id = new ItemId(SQLUtil.getString(row[col++])); // i_id
String i_u_id = SQLUtil.getString(row[col++]); // i_u_id
String i_name = (String) row[col++]; // i_name
String i_u_id = SQLUtil.getString(row[col++]); // i_u_id
assert i_u_id != null;
@SuppressWarnings("unused")
String i_name = (String) row[col++]; // i_name
double i_current_price = SQLUtil.getDouble(row[col++]); // i_current_price
long i_num_bids = SQLUtil.getLong(row[col++]); // i_num_bids
Timestamp i_end_date = SQLUtil.getTimestamp(row[col++]);// i_end_date
Expand Down Expand Up @@ -452,7 +454,7 @@ protected boolean executeCloseAuctions(Connection conn, CloseAuctions proc) thro

for (Object[] row : results) {
ItemId itemId = this.processItemRecord(row);

assert itemId != null;
}
profile.updateItemQueues();

Expand All @@ -476,7 +478,7 @@ protected boolean executeGetItem(Connection conn, GetItem proc) throws SQLExcept
// The first row will have our item data that we want
// We don't care about the user information...
ItemId itemId = this.processItemRecord(results[0]);

assert itemId != null;

return (true);
}
Expand Down Expand Up @@ -534,14 +536,17 @@ protected boolean executeGetUserInfo(Connection conn, GetUserInfo proc) throws S

for (Object[] row : results.getSellerItems()) {
ItemId itemId = this.processItemRecord(row);
assert itemId != null;
}

for (Object[] row : results.getBuyerItems()) {
ItemId itemId = this.processItemRecord(row);
assert itemId != null;
}

for (Object[] row : results.getWatchedItems()) {
ItemId itemId = this.processItemRecord(row);
assert itemId != null;
}


Expand Down Expand Up @@ -614,7 +619,7 @@ protected boolean executeNewBid(Connection conn, NewBid proc) throws SQLExceptio
itemInfo.getEndDate());

ItemId itemId = this.processItemRecord(results);

assert itemId != null;

return (true);
}
Expand Down Expand Up @@ -797,7 +802,7 @@ protected boolean executeNewPurchase(Connection conn, NewPurchase proc) throws S
buyer_credit);

ItemId itemId = this.processItemRecord(results);

assert itemId != null;

return (true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.sql.Timestamp;

public abstract class AuctionMarkUtil {
@SuppressWarnings("unused")
private static final Logger LOG = LoggerFactory.getLogger(AuctionMarkUtil.class);

private static final long ITEM_ID_MASK = 0xFFFFFFFFFFFFFFL; // 56 bits (ITEM_ID)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.io.InputStream;
import java.nio.charset.Charset;
import java.util.List;
Expand All @@ -31,6 +30,7 @@


public class CategoryParser {
@SuppressWarnings("unused")
private static final Logger LOG = LoggerFactory.getLogger(CategoryParser.class);

Map<String, Category> _categoryMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
import com.oltpbenchmark.util.RandomGenerator;
import org.apache.commons.io.IOUtils;

import java.io.BufferedReader;
import java.io.File;
import java.io.InputStream;
import java.nio.charset.Charset;
import java.sql.Connection;
Expand Down Expand Up @@ -143,11 +141,7 @@ private void truncateTable(Connection conn, String strTable) {
}

private int loadRegions(Connection conn, PreparedStatement statement) throws SQLException {

int k = 0;
int t = 0;
BufferedReader br = null;


truncateTable(conn, "region");
truncateTable(conn, "nation");
Expand Down Expand Up @@ -208,9 +202,7 @@ private int loadRegions(Connection conn, PreparedStatement statement) throws SQL
}

private int loadNations(Connection conn, PreparedStatement statement) {

int k = 0;
int t = 0;

Nation nation = new Nation();

Expand Down Expand Up @@ -274,9 +266,7 @@ private int loadNations(Connection conn, PreparedStatement statement) {
}

private int loadSuppliers(Connection conn, PreparedStatement statement) {

int k = 0;
int t = 0;

try {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,13 @@
import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Random;

public class EpinionsWorker extends Worker<EpinionsBenchmark> {

@SuppressWarnings("unused")
private static final Logger LOG = LoggerFactory.getLogger(EpinionsWorker.class);

private final ArrayList<String> user_ids;
private final ArrayList<String> item_ids;
private final Random rand = new Random(System.currentTimeMillis());

public EpinionsWorker(EpinionsBenchmark benchmarkModule, int id, ArrayList<String> user_ids, ArrayList<String> item_ids) {
super(benchmarkModule, id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public void load(Connection conn) throws SQLException {
total++;
if (++batch >= workConf.getBatchSize()) {
int[] result = stmt.executeBatch();
assert result != null;

batch = 0;
LOG.info(String.format("Records Loaded %d / %d", total, num_record));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* @author pavlo
*/
public class OTMetricsBenchmark extends BenchmarkModule {

@SuppressWarnings("unused")
private static final Logger LOG = LoggerFactory.getLogger(OTMetricsBenchmark.class);

protected final int num_sources;
Expand All @@ -45,7 +45,7 @@ public OTMetricsBenchmark(WorkloadConfiguration workConf) {
// Compute the number of records per table.
this.num_sources = (int) Math.round(OTMetricsConstants.NUM_SOURCES * workConf.getScaleFactor());
this.num_sessions = (int) Math.round(OTMetricsConstants.NUM_SESSIONS * workConf.getScaleFactor());
this.num_observations = (long) Math.round(OTMetricsConstants.NUM_OBSERVATIONS * workConf.getScaleFactor());
this.num_observations = Math.round(OTMetricsConstants.NUM_OBSERVATIONS * workConf.getScaleFactor());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ private void loadTable(Connection conn, String tableName) throws SQLException {
stmt.addBatch();
if (++batch >= workConf.getBatchSize()) {
int[] result = stmt.executeBatch();
assert result != null;

batch = 0;
if (LOG.isDebugEnabled()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public void run(Connection conn, int howManyPerTransaction, int sleepLength, int

// TODO: Is this the right place to sleep? With rs open???
try (ResultSet rs = stmt.executeQuery()) {
assert rs != null;
try {
Thread.sleep(sleepLength);
} catch (InterruptedException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public void run(Connection conn, int howManyPerTransaction, int sleepLength, int

// TODO: Is this the right place to sleep? With rs open???
try (ResultSet rs = stmt.executeQuery()) {
assert rs != null;
try {
Thread.sleep(sleepLength);
} catch (InterruptedException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void run(Connection conn, long s_id, byte ai_type) throws SQLException {
stmt.setLong(1, s_id);
stmt.setByte(2, ai_type);
try (ResultSet results = stmt.executeQuery()) {

assert results != null;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void run(Connection conn, long s_id, byte sf_type, byte start_time, byte
stmt.setByte(3, start_time);
stmt.setByte(4, end_time);
try (ResultSet results = stmt.executeQuery()) {

assert results != null;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void run(Connection conn, long s_id) throws SQLException {
try (PreparedStatement stmt = this.getPreparedStatement(conn, getSubscriber)) {
stmt.setLong(1, s_id);
try (ResultSet results = stmt.executeQuery()) {

assert results != null;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public long run(Connection conn, String sub_nbr, byte sf_type, byte start_time,
try (PreparedStatement stmt = this.getPreparedStatement(conn, getSpecialFacility)) {
stmt.setLong(1, s_id);
try (ResultSet results = stmt.executeQuery()) {

assert results != null;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.io.Serializable;

public class District implements Serializable {
static final long serialVersionUID = 0;

public int d_id;
public int d_w_id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.io.Serializable;

public class NewOrder implements Serializable {
private static final long serialVersionUID = 1L;

public int no_w_id;
public int no_d_id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.io.Serializable;

public class Stock implements Serializable {
static final long serialVersionUID = 0;

public int s_i_id; // PRIMARY KEY 2
public int s_w_id; // PRIMARY KEY 1
Expand Down
Loading