Skip to content

Commit

Permalink
Added fail on warning lint for Javadoc, and rawtypes fixes for Bytes (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-lawrey committed Apr 29, 2024
1 parent a354a62 commit aa79801
Show file tree
Hide file tree
Showing 76 changed files with 187 additions and 295 deletions.
8 changes: 0 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -425,14 +425,6 @@
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<source>8</source>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/net/openhft/chronicle/queue/ChronicleQueue.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ static SingleChronicleQueueBuilder singleBuilder(@NotNull final Path path) {
* The id is used to persistently store the latest index for the Tailer. Any new Tailer with
* a previously used id will continue where the old one left off.
* <b>
* A Tailer is <em>NOT thread-safe</em>. A Tailer can be created by one Thread and might be used by at most one other Thread.</em>.
* A Tailer is <em>NOT thread-safe</em>. A Tailer can be created by one Thread and might be used by at most one other Thread.
* Sharing a Tailer across threads is unsafe and will inevitably lead to errors and unspecified behaviour.
* </b>
* <p>
Expand Down Expand Up @@ -344,7 +344,7 @@ default void dump(@NotNull OutputStream stream, long fromIndex, long toIndex) {
* @throws NullPointerException if any of the provided parameters are {@code null}.
*/
@NotNull
default <T> T methodWriter(@NotNull final Class<T> tClass, Class... additional) {
default <T> T methodWriter(@NotNull final Class<T> tClass, Class<?>... additional) {
VanillaMethodWriterBuilder<T> builder = methodWriterBuilder(tClass);
Stream.of(additional).forEach(builder::addInterface);
return builder.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public interface ExcerptAppender extends ExcerptCommon<ExcerptAppender>, Marshal
* @param bytes to write to excerpt.
* @throws UnrecoverableTimeoutException if the operation times out.
*/
void writeBytes(@NotNull BytesStore bytes);
void writeBytes(@NotNull BytesStore<?,?> bytes);

/**
* Writes (i.e. appends) the provided {@code bytes} to the queue.
Expand Down Expand Up @@ -109,7 +109,7 @@ default void pretouch() {
*/
@NotNull
@Override
default <T> T methodWriter(@NotNull Class<T> tClass, Class... additional) {
default <T> T methodWriter(@NotNull Class<T> tClass, Class<?>... additional) {
return queue().methodWriter(tClass, additional);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class PipeHandler extends AbstractHandler<PipeHandler> {
private int publishSourceId = 0;

private int subscribeSourceId = 0;
@SuppressWarnings("unchecked")
private Consumer<ExcerptTailer> subscriptionIndexController = SubscribeHandler.NO_OP;

public PipeHandler() {
Expand Down Expand Up @@ -92,6 +93,7 @@ public PipeHandler subscribeSourceId(int subscribeSourceId) {
return this;
}

@SuppressWarnings("try")
@Override
public void run(ChronicleContext context, ChronicleChannel channel) {
Pauser pauser = Pauser.balanced();
Expand Down Expand Up @@ -158,7 +160,7 @@ protected void performClose() {

/**
* @param subscriptionIndexController controls where the subscriptions will start to read from, by allowing the caller to
* {@link net.openhft.chronicle.queue.ExcerptTailer#moveToIndex(long) to control the first read location
* {@link net.openhft.chronicle.queue.ExcerptTailer#moveToIndex(long)} to control the first read location
*/
public PipeHandler subscriptionIndexController(Consumer<ExcerptTailer> subscriptionIndexController) {
this.subscriptionIndexController = subscriptionIndexController;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ public PublishHandler publishSourceId(int publishSourceId) {
return this;
}

@SuppressWarnings("try")
@Override
public void run(ChronicleContext context, ChronicleChannel channel) {
Pauser pauser = Pauser.balanced();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@

public class SubscribeHandler extends AbstractHandler<SubscribeHandler> {

private static class NoOp extends SelfDescribingMarshallable implements Consumer {
private static class NoOp extends SelfDescribingMarshallable implements Consumer<ExcerptTailer> {
@Override
public void accept(Object o) {
public void accept(ExcerptTailer o) {
return;
}
}

public final static Consumer NO_OP = new NoOp();
public final static Consumer<ExcerptTailer> NO_OP = new NoOp();

private String subscribe;
private transient boolean closeWhenRunEnds = true;
Expand Down Expand Up @@ -123,6 +123,7 @@ public SubscribeHandler filter(Predicate<Wire> filter) {
return this;
}

@SuppressWarnings("try")
@Override
public void run(ChronicleContext context, ChronicleChannel channel) {
Pauser pauser = Pauser.balanced();
Expand Down Expand Up @@ -189,7 +190,7 @@ public SubscribeHandler subscribeSourceId(int sourceId) {

/**
* @param subscriptionIndexController controls where the subscriptions will start to read from, by allowing the caller to
* {@link net.openhft.chronicle.queue.ExcerptTailer#moveToIndex(long) to control the first read location
* {@link net.openhft.chronicle.queue.ExcerptTailer#moveToIndex(long)} to control the first read location
*/
public SubscribeHandler subscriptionIndexController(Consumer<ExcerptTailer> subscriptionIndexController) {
this.subscriptionIndexController = subscriptionIndexController;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@

public class PublishQueueChannel implements ChronicleChannel {
private final ChronicleChannelCfg<?> channelCfg;
private final AbstractHandler publishHandler;
private final AbstractHandler<?> publishHandler;
private final ChannelHeader headerOut;
private final ChronicleQueue publishQueue;
private final ExcerptTailer tailer;

public PublishQueueChannel(ChronicleChannelCfg<?> channelCfg, AbstractHandler publishHandler, ChronicleQueue publishQueue) {
public PublishQueueChannel(ChronicleChannelCfg<?> channelCfg, AbstractHandler<?> publishHandler, ChronicleQueue publishQueue) {
this.channelCfg = channelCfg;
this.publishHandler = publishHandler;
this.headerOut = publishHandler.responseHeader(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class QueuesChannel implements ChronicleChannel {
private final PublishQueueChannel publishQueueChannel;
private final SubscribeQueueChannel subscribeQueueChannel;

public QueuesChannel(ChronicleChannelCfg<?> channelCfg, AbstractHandler handler, ChronicleQueue publishQueue, ChronicleQueue subscribeQueue) {
public QueuesChannel(ChronicleChannelCfg<?> channelCfg, AbstractHandler<?> handler, ChronicleQueue publishQueue, ChronicleQueue subscribeQueue) {
publishQueueChannel = new PublishQueueChannel(channelCfg, handler, publishQueue);
subscribeQueueChannel = new SubscribeQueueChannel(channelCfg, handler, subscribeQueue);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@

public class SubscribeQueueChannel implements ChronicleChannel {
private final ChronicleChannelCfg<?> channelCfg;
private final AbstractHandler pipeHandler;
private final AbstractHandler<?> pipeHandler;
private final ChannelHeader headerOut;
private final ChronicleQueue subscribeQueue;
private final ExcerptTailer tailer;
private long lastTestMessage;

public SubscribeQueueChannel(ChronicleChannelCfg<?> channelCfg, AbstractHandler pipeHandler, ChronicleQueue subscribeQueue) {
public SubscribeQueueChannel(ChronicleChannelCfg<?> channelCfg, AbstractHandler<?> pipeHandler, ChronicleQueue subscribeQueue) {
this.channelCfg = channelCfg;
this.pipeHandler = pipeHandler;
this.headerOut = pipeHandler.responseHeader(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
/**
* Creates a buffer for use in async mode. This is an enterprise feature.
*/
public interface AsyncBufferCreator extends ThrowingBiFunction<Long, Integer, BytesStore, Exception> {
public interface AsyncBufferCreator extends ThrowingBiFunction<Long, Integer, BytesStore<?, ?>, Exception> {

@Override
default @NotNull BytesStore apply(Long size, Integer maxReaders) throws Exception {
default @NotNull BytesStore<?, ?> apply(Long size, Integer maxReaders) throws Exception {
throw new UnsupportedOperationException("Call the create function instead");
}

@NotNull BytesStore create(long size, int maxReaders, File file) throws Exception;
@NotNull BytesStore<?, ?> create(long size, int maxReaders, File file) throws Exception;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static java.lang.String.format;

public class IllegalIndexException extends IllegalArgumentException {
private static final long serialVersionUID = 0L;

public IllegalIndexException(long providedIndex, long lastIndex) {
super(format("Index provided is after the next index in the queue, provided index = %x, last index in queue = %x", providedIndex, lastIndex));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package net.openhft.chronicle.queue.impl.single;

public class IndexNotAvailableException extends IllegalStateException {
private static final long serialVersionUID = 0L;
public IndexNotAvailableException(String s) {
super(s);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ public interface InternalAppender extends ExcerptAppender {
* @param bytes bytes the contents of the excerpt to write
* @throws IllegalIndexException if the index specified is larger than the valid next indices of the queue
*/
void writeBytes(long index, BytesStore bytes);
void writeBytes(long index, BytesStore<?, ?> bytes);

}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public boolean execute() {
lastPageTouched = nextPage;
try {
// best effort
final BytesStore bs = bytes.bytesStore();
final BytesStore<?, ?> bs = bytes.bytesStore();
if (bs.inside(nextPage, 8))
touchPage(nextPage, bs);
} catch (Throwable ignored) {
Expand All @@ -71,20 +71,20 @@ public void bgExecute() {
if (bufferWire == null)
return;

BytesStore bytes = bufferWire.bytes().bytesStore();
BytesStore<?, ?> bytes = bufferWire.bytes().bytesStore();
sync(bytes, start, length);
this.lastPageSynced += length;
}

private void sync(BytesStore bytes, long start, long length) {
private void sync(BytesStore<?, ?> bytes, long start, long length) {
if (!bytes.inside(start, length))
return;
// long a = System.nanoTime();
PosixAPI.posix().msync(bytes.addressForRead(start), length, MSyncFlag.MS_ASYNC);
// System.out.println("sync took " + (System.nanoTime() - a) / 1000);
}

protected boolean touchPage(long nextPage, BytesStore bs) {
protected boolean touchPage(long nextPage, BytesStore<?, ?> bs) {
return bs.compareAndSwapLong(nextPage, 0, 0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
* Thrown when a store file we expect to be present is missing (probably because it was deleted)
*/
public class MissingStoreFileException extends IllegalStateException {
private static final long serialVersionUID = 0L;
public MissingStoreFileException(String s) {
super(s);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package net.openhft.chronicle.queue.impl.single;

public class NamedTailerNotAvailableException extends IllegalStateException {

private static final long serialVersionUID = 0L;
private final String tailerName;

private final Reason reason;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
* of the binary search.
*/
public final class NotComparableException extends RuntimeException {
private static final long serialVersionUID = 0L;

public static final NotComparableException INSTANCE = new NotComparableException();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package net.openhft.chronicle.queue.impl.single;

public class NotReachedException extends IllegalStateException {
private static final long serialVersionUID = 0L;
public NotReachedException(final String s) {
super(s);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public class ReferenceCountedCache<K, T extends ReferenceCounted & Closeable, V,
private final ThrowingFunction<K, T, E> creator;
private final ReferenceChangeListener referenceChangeListener;

@SuppressWarnings("this-escape")
public ReferenceCountedCache(final Function<T, V> transformer,
final ThrowingFunction<K, T, E> creator) {
this.transformer = transformer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@
import net.openhft.chronicle.core.Maths;
import net.openhft.chronicle.core.values.LongValue;
import net.openhft.chronicle.core.values.TwoLongValue;
import net.openhft.chronicle.wire.Sequence;

class RollCycleEncodeSequence implements Sequence {
class RollCycleEncodeSequence implements net.openhft.chronicle.wire.Sequence {
private final TwoLongValue writePositionAndSequence;
private final int cycleShift;
private final long sequenceMask;
Expand Down Expand Up @@ -60,10 +59,11 @@ public long toIndex(long headerNumber, long sequence) {
* @param forWritePosition the last write position, expected to be the end of queue
* @return NOT_FOUND_RETRY if the sequence for this write position can not be found, or NOT_FOUND if sequenceValue==null or the sequence for this {@code writePosition}
*/
@SuppressWarnings("deprecation")
public long getSequence(long forWritePosition) {

if (writePositionAndSequence == null)
return Sequence.NOT_FOUND;
return net.openhft.chronicle.wire.Sequence.NOT_FOUND;

// We only deal with the 2nd long in the TwoLongValue, and we use it to keep track of current position
// and current sequence. We use the same encoding as index (cycle number is shifted left by cycleShift
Expand All @@ -74,7 +74,7 @@ public long getSequence(long forWritePosition) {

final long sequenceValue = this.writePositionAndSequence.getVolatileValue2();
if (sequenceValue == 0)
return Sequence.NOT_FOUND;
return net.openhft.chronicle.wire.Sequence.NOT_FOUND;

long writePositionAsCycle = toLongValue(forWritePosition, 0);
long lowerBitsOfWp = toLowerBitsWritePosition(writePositionAsCycle);
Expand All @@ -83,7 +83,7 @@ public long getSequence(long forWritePosition) {
if (lowerBitsOfWp == toLowerBitsWritePosition)
return toSequenceNumber(sequenceValue);

return Sequence.NOT_FOUND_RETRY;
return net.openhft.chronicle.wire.Sequence.NOT_FOUND_RETRY;
}

private long toLongValue(long cycle, long sequenceNumber) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import static net.openhft.chronicle.queue.RollCycle.MAX_INDEX_COUNT;
import static net.openhft.chronicle.wire.Wires.NOT_INITIALIZED;

@SuppressWarnings("deprecation")
class SCQIndexing extends AbstractCloseable implements Indexing, Demarshallable, WriteMarshallable, Closeable {
private static final boolean IGNORE_INDEXING_FAILURE = Jvm.getBoolean("queue.ignoreIndexingFailure");
private static final boolean REPORT_LINEAR_SCAN = Jvm.getBoolean("chronicle.queue.report.linear.scan.latency");
Expand Down Expand Up @@ -484,11 +485,14 @@ long linearScanByPosition0(@NotNull final Wire wire,

int header = bytes.readVolatileInt(bytes.readPosition());
throwIndexNotWritten(toPosition, startAddress, bytes, header);
break;
case META_DATA:
break;
case DATA:
++i;
break;
case EOF:
throw new AssertionError("EOF should have been handled");
}

if (bytes.readPosition() == toPosition)
Expand Down Expand Up @@ -619,6 +623,7 @@ void initIndex(@NotNull Wire wire) throws StreamCorruptedException {
throw new IllegalStateException("Who reset the position?");
}

@SuppressWarnings("try")
private LongArrayValues getIndex2index(@NotNull Wire wire) {

LongArrayValuesHolder holder = getIndex2IndexArray();
Expand Down
Loading

0 comments on commit aa79801

Please sign in to comment.