Skip to content

Commit

Permalink
fix build warning messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher Gross cogross committed Mar 12, 2024
1 parent 25da5cf commit 8e9f7e7
Show file tree
Hide file tree
Showing 103 changed files with 343 additions and 308 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1994,9 +1994,9 @@
<id>clover</id>
<dependencies>
<dependency>
<groupId>com.cenqua.clover</groupId>
<groupId>org.openclover</groupId>
<artifactId>clover</artifactId>
<version>RELEASE</version>
<version>4.5.1</version>
</dependency>
</dependencies>
</profile>
Expand Down
2 changes: 1 addition & 1 deletion warehouse/accumulo-extensions/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
<id>clover</id>
<dependencies>
<dependency>
<groupId>com.cenqua.clover</groupId>
<groupId>org.openclover</groupId>
<artifactId>clover</artifactId>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;

public class MultiComparator<T> implements Comparator<T>, Serializable {
Expand All @@ -15,6 +16,8 @@ public MultiComparator(Collection<Comparator<T>> comparators) {
this.comparators = comparators;
}

@SafeVarargs
@SuppressWarnings("varargs")
public MultiComparator(Comparator<T>... comparators) {
this((comparators != null && comparators.length > 0) ? Arrays.asList(comparators) : new ArrayList<>());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public UID_TYPE newId(final UID template, final String... extras) {
} else if (template.getClass() == SnowflakeUID.class) {
validatedTemplate = template;
} else {
validatedTemplate = template.parse(template.toString());
validatedTemplate = UID.parse(template.toString());
}
} else {
validatedTemplate = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import java.io.DataInput;
import java.io.IOException;
import java.io.Serializable;
import java.math.BigInteger;

import org.apache.commons.lang.builder.CompareToBuilder;
Expand Down
2 changes: 2 additions & 0 deletions warehouse/core/src/main/java/datawave/data/hash/UID.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public abstract class UID implements Comparable<UID>, Comparator<UID>, Writable,

private static final Logger LOGGER = Logger.getLogger(UID.class);

private static final long serialVersionUID = 0L;

protected static final String[] EMPTY_EXTRAS = {};
protected static final String NULL = "" + null;
protected static final int RADIX = Character.MAX_RADIX;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
* Description: Keys consist of objects that are Reloadable, which identify if their underlying value has changed and enable it to reload the value
*
* Justification: Based upon Loader, which is further based upon CacheLoader. This enables us to have customized techniques for loading GUAVA caches, and
* reloading this elements when necessary
* reloading these elements when necessary
*/
public class ReloadableCacheBuilder<K extends Reloadable,V> extends Loader<K,V> {
public class ReloadableCacheBuilder<K extends Reloadable<?>,V> extends Loader<K,V> {

private static final Logger log = Logger.getLogger(ReloadableCacheBuilder.class);

Expand Down Expand Up @@ -62,14 +62,15 @@ public ListenableFuture<V> reload(K key, V oldValue) {
* @see datawave.ingest.util.cache.Loader#build(java.lang.Object)
*/
@Override
@SuppressWarnings("unchecked")
protected void build(K key) throws Exception {

if (null == key) {
if (log.isTraceEnabled())
log.trace("Rebuild all");
Collection<K> watchers = entryCache.keySet();
for (K keyWatcher : watchers) {
Reloadable watcher = Reloadable.class.cast(keyWatcher);
Reloadable<V> watcher = (Reloadable<V>) keyWatcher;

if (log.isTraceEnabled())
log.trace("rebuild " + watcher + " ? " + watcher.hasChanged());
Expand All @@ -78,13 +79,13 @@ protected void build(K key) throws Exception {
if (log.isTraceEnabled())
log.trace("rebuild " + watcher + " ? " + watcher.hasChanged() + " " + watcher.reload());

entryCache.put(keyWatcher, (V) watcher.reload());
entryCache.put(keyWatcher, watcher.reload());

}
}
}
} else {
Reloadable watcher = Reloadable.class.cast(key);
Reloadable<K> watcher = (Reloadable<K>) key;
synchronized (entryCache) {
entryCache.put(key, (V) watcher.reload());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public abstract class TokenSpecParser<B extends TokenSpecParser> {
*
* @return TokenSpecParser child object
*/
@SuppressWarnings("unchecked")
public B parse(String configuration) {
ParserState parser = new ParserState(configuration);
parser.parseTo(this);
Expand Down Expand Up @@ -176,7 +177,7 @@ protected String expect(ParseTokenType type) {
* @param builder
* token spec parser
*/
protected void parseTo(TokenSpecParser builder) {
protected void parseTo(TokenSpecParser<?> builder) {
ParseToken initialToken;
while ((initialToken = peek()) != null) {
String tokenStr = parseStrliteral();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public FilterRule deepCopy(AgeOffPeriod period, IteratorEnvironment iterEnv) {
public FilterRule deepCopy(long scanStart, IteratorEnvironment iterEnv) {
AppliedRule newFilter;
try {
newFilter = (AppliedRule) super.getClass().newInstance();
newFilter = (AppliedRule) super.getClass().getDeclaredConstructor().newInstance();
FilterOptions newOptions = new FilterOptions(currentOptions);
newOptions.setOption(AgeOffConfigParams.SCAN_START_TIMESTAMP, Long.toString(scanStart));
newFilter.iterEnv = iterEnv;
Expand All @@ -139,7 +139,7 @@ public FilterRule deepCopy(long scanStart, IteratorEnvironment iterEnv) {
newFilter.ageOffPeriod = new AgeOffPeriod(scanStart, currentOptions.ttl, currentOptions.ttlUnits);
log.trace("Age off is " + newFilter.ageOffPeriod.getCutOffMilliseconds());
return newFilter;
} catch (InstantiationException | IllegalAccessException e) {
} catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
log.error(e);
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public BulkIteratorEnvironment(IteratorScope scope) {
}

@Override
@Deprecated
public AccumuloConfiguration getConfig() {
return conf;
}
Expand All @@ -41,6 +42,7 @@ public boolean isFullMajorCompaction() {
}

@Override
@Deprecated
public void registerSideChannel(SortedKeyValueIterator<Key,Value> iter) {
throw new UnsupportedOperationException();
}
Expand All @@ -66,12 +68,14 @@ public SamplerConfiguration getSamplerConfiguration() {
}

@Override
@Deprecated
public SortedKeyValueIterator<Key,Value> reserveMapFileReader(String mapFileName) throws IOException {
// TODO Auto-generated method stub
return null;
}

@Override
@Deprecated
public ServiceEnvironment getServiceEnv() {
return null;
}
Expand Down
4 changes: 2 additions & 2 deletions warehouse/core/src/main/java/datawave/util/ObjectFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public static Object create(String className, Object... args) {

// Look for exact match
try {
constructor = clazz.getConstructor(types.toArray(new Class[0]));
constructor = clazz.getConstructor(types.toArray(new Class<?>[0]));
} catch (NoSuchMethodException e) {
logger.debug("No constructor for [" + className + "] in ObjectFactory.create())");
}
Expand All @@ -59,7 +59,7 @@ public static Object create(String className, Object... args) {
Constructor<?>[] constructors = clazz.getConstructors();
for (int i = 0; i < constructors.length && constructor == null; i++) {
Constructor<?> c = constructors[i];
Class<?> ctypes[] = c.getParameterTypes();
Class<?>[] ctypes = c.getParameterTypes();

if (logger.isDebugEnabled()) {
logger.debug("Checking:" + className + ", " + clazz);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void testBuilder() throws ParseException {
SnowflakeUIDBuilder result1 = (SnowflakeUIDBuilder) ((UIDBuilder) SnowflakeUID.builder());
assertNotNull(result1);
assertNotNull(result1.toString());
assertNull(((SnowflakeUID) result1.newId()).getSnowflake());
assertNull((result1.newId()).getSnowflake());
assertNull(result1.newId(0).getSnowflake());
assertNull(result1.newId(System.currentTimeMillis(), 0).getSnowflake());
assertNull(result1.newId(System.currentTimeMillis()).getSnowflake());
Expand Down
8 changes: 8 additions & 0 deletions warehouse/core/src/test/java/datawave/data/hash/UIDTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -477,10 +477,13 @@ public void testMiscellaneous() {
* Test subclass akin to the StringUID
*/
private static class CustomHashUID extends HashUID {
private static final long serialVersionUID = 0L;

public CustomHashUID(HashUID template, String... extras) {
super(template, extras);
}

@SuppressWarnings("unchecked")
public static HashUID parse(String s) {
HashUID hashUid = HashUID.parse(s);
if (null != hashUid) {
Expand All @@ -495,10 +498,13 @@ public static HashUID parse(String s) {
* Another test subclass akin to the StringUID
*/
private static class CustomSnowflakeUID extends SnowflakeUID {
private static final long serialVersionUID = 0L;

public CustomSnowflakeUID(SnowflakeUID template, String... extras) {
super(template, extras);
}

@SuppressWarnings("unchecked")
public static SnowflakeUID parse(String s) {
SnowflakeUID hashUid = SnowflakeUID.parse(s);
if (null != hashUid) {
Expand All @@ -510,6 +516,8 @@ public static SnowflakeUID parse(String s) {
}

private class TestUID extends UID {
private static final long serialVersionUID = 0L;

public TestUID(String prefix, boolean isPrefixOptional, String... extras) {
super(prefix, isPrefixOptional, extras);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ public void testReadOldActivity() {
fail("Failed to encode variable length long array: " + e.getMessage());
}
List<Long> oldAsList = EdgeValueHelper.decodeActivityHistogram(new Value(oldBytes));
assertEquals(new Long(1l), oldAsList.get(6));
assertEquals(Long.valueOf(1l), oldAsList.get(6));
}

private static final Value NULL_VALUE = new Value(new byte[0]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public void testBuilderReset() {

@Test
public void testPositionScoreToTermWeightScore() {
Float positionScore = new Float(-.0552721);
Float positionScore = Float.valueOf(-.0552721F);
Integer twScore = TermWeightPosition.positionScoreToTermWeightScore(positionScore);
Float result = TermWeightPosition.termWeightScoreToPositionScore(twScore);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package datawave.ingest.util.cache.watch;

import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;

import java.io.IOException;
import java.util.Collection;
Expand Down Expand Up @@ -54,22 +52,22 @@ public void verifyOverridenValues() throws IOException {
// <zip ttl="123"/>

// verify original values
assertThat(parentFilter.options.getOption("foo.ttl"), is("600"));
assertThat(parentFilter.options.getOption("bar.ttl"), is("500"));
assertThat(parentFilter.options.getOption("baz.ttl"), is("400"));
assertEquals(parentFilter.options.getOption("foo.ttl"), "600");
assertEquals(parentFilter.options.getOption("bar.ttl"), "500");
assertEquals(parentFilter.options.getOption("baz.ttl"), "400");

// check overrides
assertThat(childFilter.options.getOption("bar.ttl"), is("500"));
assertThat(childFilter.options.getOption("baz.ttl"), is("400"));
assertEquals(childFilter.options.getOption("bar.ttl"), "500");
assertEquals(childFilter.options.getOption("baz.ttl"), "400");
// these are overridden
assertThat(childFilter.options.getOption("foo.ttl"), is("123"));
assertThat(childFilter.options.getOption("zip.ttl"), is("123"));
assertEquals(childFilter.options.getOption("foo.ttl"), "123");
assertEquals(childFilter.options.getOption("zip.ttl"), "123");
}

private static FilterRule loadRulesFromFile(FileRuleWatcher watcher, FileSystem fs, Path filePath) throws IOException {
Collection<FilterRule> rules = watcher.loadContents(fs.open(filePath));
// should only have the single rule
assertThat(rules.size(), is(1));
assertEquals(rules.size(), 1);
for (FilterRule rule : rules) {
assertEquals(TestDataTypeFilter.class, rule.getClass());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ public void before() throws IOException {

@Test
public void verifyIsIndexOnlyForChild() throws IOException {
assertThat(isIndexTable(parentFilter), is(false));
assertEquals(isIndexTable(parentFilter), false);

assertThat(isIndexTable(childFilter), is(true));
assertEquals(isIndexTable(childFilter), true);
}

@Test
Expand All @@ -52,10 +52,10 @@ public void verifyInheritedParentConfigs() throws IOException {
// <fields>alpha,beta,gamma,delta</fields>
// since child is index config, field should be in the column family
Key key = new Key("row", "alpha", "cq", "vis", 0);
assertThat(childFilter.accept(key, new Value()), is(false));
assertEquals(childFilter.accept(key, new Value()), false);

key = new Key("row", "beta", "cq", "vis", Long.MAX_VALUE);
assertThat(childFilter.accept(key, new Value()), is(true));
assertEquals(childFilter.accept(key, new Value()), true);
}

private Boolean isIndexTable(TestFieldFilter filter) {
Expand All @@ -65,7 +65,7 @@ private Boolean isIndexTable(TestFieldFilter filter) {
private static FilterRule loadRulesFromFile(FileRuleWatcher watcher, FileSystem fs, Path filePath) throws IOException {
Collection<FilterRule> rules = watcher.loadContents(fs.open(filePath));
// should only have the single rule
assertThat(rules.size(), is(1));
assertEquals(rules.size(), 1);
for (FilterRule rule : rules) {
assertEquals(TestFieldFilter.class, rule.getClass());
}
Expand Down
Loading

0 comments on commit 8e9f7e7

Please sign in to comment.