import com.google.common.annotations.Beta;
import java.util.Optional;
-import javax.annotation.concurrent.NotThreadSafe;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
/**
* Abstract {@link DataTreeModificationCursor} which tracks the current path. Subclasses can get the current path
- * via {@link #current()}.
+ * via {@link #current()}. This class is NOT thread-safe.
*
* @author Thomas Pantelis
*/
@Beta
-@NotThreadSafe
public abstract class AbstractDataTreeModificationCursor implements DataTreeModificationCursor {
private YangInstanceIdentifier current = YangInstanceIdentifier.EMPTY;
import java.nio.file.Files;
import java.util.Iterator;
import java.util.Set;
-import javax.annotation.concurrent.GuardedBy;
-import javax.annotation.concurrent.ThreadSafe;
+import org.checkerframework.checker.lock.qual.GuardedBy;
+import org.checkerframework.checker.lock.qual.Holding;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.slf4j.Logger;
*
* @author Thomas Pantelis
*/
-@ThreadSafe
public class FileBackedOutputStream extends OutputStream {
private static final Logger LOG = LoggerFactory.getLogger(FileBackedOutputStream.class);
* @param fileDirectory the directory in which to create the file if needed. If null, the default temp file
* location is used.
*/
- public FileBackedOutputStream(int fileThreshold, @Nullable String fileDirectory) {
+ public FileBackedOutputStream(final int fileThreshold, @Nullable final String fileDirectory) {
this.fileThreshold = fileThreshold;
this.fileDirectory = fileDirectory;
}
@Override
@SuppressFBWarnings(value = "VO_VOLATILE_INCREMENT", justification = "Findbugs erroneously complains that the "
+ "increment of count needs to be atomic even though it is inside a synchronized block.")
- public synchronized void write(int value) throws IOException {
+ public synchronized void write(final int value) throws IOException {
possiblySwitchToFile(1);
out.write(value);
count++;
}
@Override
- public synchronized void write(byte[] bytes) throws IOException {
+ public synchronized void write(final byte[] bytes) throws IOException {
write(bytes, 0, bytes.length);
}
@Override
- public synchronized void write(byte[] bytes, int off, int len) throws IOException {
+ public synchronized void write(final byte[] bytes, final int off, final int len) throws IOException {
possiblySwitchToFile(len);
out.write(bytes, off, len);
count += len;
}
}
- @GuardedBy("this")
+ @Holding("this")
private void closeQuietly() {
try {
close();
/**
* Checks if writing {@code len} bytes would go over threshold, and switches to file buffering if so.
*/
- @GuardedBy("this")
- private void possiblySwitchToFile(int len) throws IOException {
+ @Holding("this")
+ private void possiblySwitchToFile(final int len) throws IOException {
if (out == null) {
throw new IOException("Stream already closed");
}
}
}
- private static void deleteFile(File file) {
+ private static void deleteFile(final File file) {
if (!file.delete()) {
LOG.warn("Could not delete temp file {}", file);
}
private static class Cleanup extends FinalizablePhantomReference<FileBackedOutputStream> {
private final File file;
- Cleanup(FileBackedOutputStream referent, File file) {
+ Cleanup(final FileBackedOutputStream referent, final File file) {
super(referent, REFERENCE_QUEUE);
this.file = file;
import java.io.BufferedOutputStream;
import java.io.IOException;
import java.util.Arrays;
-import javax.annotation.concurrent.NotThreadSafe;
import org.opendaylight.controller.cluster.io.FileBackedOutputStream;
import org.opendaylight.controller.cluster.io.FileBackedOutputStreamFactory;
import org.opendaylight.yangtools.concepts.Identifier;
import org.slf4j.LoggerFactory;
/**
- * Maintains the state of an assembled message.
+ * Maintains the state of an assembled message. This class is NOT thread-safe.
*
* @author Thomas Pantelis
*/
-@NotThreadSafe
public class AssembledMessageState implements AutoCloseable {
private static final Logger LOG = LoggerFactory.getLogger(AssembledMessageState.class);
import java.io.InputStream;
import java.util.Arrays;
import java.util.function.Consumer;
-import javax.annotation.concurrent.NotThreadSafe;
import org.opendaylight.controller.cluster.io.FileBackedOutputStream;
import org.opendaylight.yangtools.concepts.Identifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * Maintains the state of a sliced message.
+ * Maintains the state of a sliced message. This class is NOT thread-safe.
*
* @author Thomas Pantelis
* @see MessageSlicer
*/
-@NotThreadSafe
public class SlicedMessageState<T> implements AutoCloseable {
private static final Logger LOG = LoggerFactory.getLogger(SlicedMessageState.class);
* @param index the slice index to test
* @return true if the index is the last slice, false otherwise
*/
- public boolean isLastSlice(int index) {
+ public boolean isLastSlice(final int index) {
return totalSlices == index;
}