Skip to content

Refactoring #1474

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 1 commit into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions driver/src/main/java/org/neo4j/driver/TransactionWork.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
* @deprecated superseded by {@link TransactionCallback}.
*/
@Deprecated
@SuppressWarnings("DeprecatedIsStillUsed")
public interface TransactionWork<T> {
/**
* Executes all given operations against the same transaction.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
* @deprecated superseded by {@link AsyncTransactionCallback}.
*/
@Deprecated
@SuppressWarnings("DeprecatedIsStillUsed")
public interface AsyncTransactionWork<T> {
/**
* Executes all given operations against the same transaction.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ private CompletionStage<ClusterComposition> lookupOnRouter(
});
}

@SuppressWarnings("ThrowableNotThrown")
private ClusterComposition handleRoutingProcedureError(
Throwable error, RoutingTable routingTable, BoltServerAddress routerAddress, Throwable baseError) {
if (mustAbortDiscovery(error)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public void onSuccess(Map<String, Value> metadata) {
}

@Override
@SuppressWarnings("ThrowableNotThrown")
public void onFailure(Throwable error) {
if (tx != null) {
tx.markTerminated(error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public TransactionPullResponseCompletionListener(UnmanagedTransaction tx) {
public void afterSuccess(Map<String, Value> metadata) {}

@Override
@SuppressWarnings("ThrowableNotThrown")
public void afterFailure(Throwable error) {
// always mark transaction as terminated because every error is "acknowledged" with a RESET message
// so database forgets about the transaction after the first error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ private void packLocalDateTime(LocalDateTime localDateTime) throws IOException {
packer.pack(nano);
}

@SuppressWarnings("DuplicatedCode")
private void packZonedDateTimeUsingUtcBaseline(ZonedDateTime zonedDateTime) throws IOException {
var instant = zonedDateTime.toInstant();
var epochSecondLocal = instant.getEpochSecond();
Expand All @@ -196,6 +197,7 @@ private void packZonedDateTimeUsingUtcBaseline(ZonedDateTime zonedDateTime) thro
}
}

@SuppressWarnings("DuplicatedCode")
private void packZonedDateTime(ZonedDateTime zonedDateTime) throws IOException {
var epochSecondLocal = zonedDateTime.toLocalDateTime().toEpochSecond(UTC);
var nano = zonedDateTime.getNano();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ protected Value unpackRelationship() throws IOException {
return new RelationshipValue(adapted);
}

@SuppressWarnings("DuplicatedCode")
protected InternalNode unpackNode() throws IOException {
var urn = unpacker.unpackLong();

Expand All @@ -295,7 +296,7 @@ protected InternalNode unpackNode() throws IOException {
return new InternalNode(urn, String.valueOf(urn), labels, props);
}

@SuppressWarnings("deprecation")
@SuppressWarnings({"deprecation", "DuplicatedCode"})
protected Value unpackPath() throws IOException {
// List of unique nodes
var uniqNodes = new Node[(int) unpacker.unpackListHeader()];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public MessageWriterV4(PackOutput output) {
super(new CommonValuePacker(output, false), buildEncoders());
}

@SuppressWarnings("DuplicatedCode")
private static Map<Byte, MessageEncoder> buildEncoders() {
Map<Byte, MessageEncoder> result = Iterables.newHashMapWithSize(9);
result.put(HelloMessage.SIGNATURE, new HelloMessageEncoder());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public MessageWriterV43(PackOutput output, boolean dateTimeUtcEnabled) {
super(new CommonValuePacker(output, dateTimeUtcEnabled), buildEncoders());
}

@SuppressWarnings("DuplicatedCode")
private static Map<Byte, MessageEncoder> buildEncoders() {
Map<Byte, MessageEncoder> result = Iterables.newHashMapWithSize(9);
result.put(HelloMessage.SIGNATURE, new HelloMessageEncoder());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public MessageWriterV44(PackOutput output, boolean dateTimeUtcEnabled) {
super(new CommonValuePacker(output, dateTimeUtcEnabled), buildEncoders());
}

@SuppressWarnings("DuplicatedCode")
private static Map<Byte, MessageEncoder> buildEncoders() {
Map<Byte, MessageEncoder> result = Iterables.newHashMapWithSize(9);
result.put(HelloMessage.SIGNATURE, new HelloMessageEncoder());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public MessageWriterV5(PackOutput output) {
super(new CommonValuePacker(output, true), buildEncoders());
}

@SuppressWarnings("DuplicatedCode")
private static Map<Byte, MessageEncoder> buildEncoders() {
Map<Byte, MessageEncoder> result = Iterables.newHashMapWithSize(9);
result.put(HelloMessage.SIGNATURE, new HelloMessageEncoder());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ protected int getRelationshipFields() {
return RELATIONSHIP_FIELDS;
}

@SuppressWarnings("DuplicatedCode")
@Override
protected InternalNode unpackNode() throws IOException {
var urn = unpacker.unpackLong();
Expand All @@ -76,6 +77,7 @@ protected InternalNode unpackNode() throws IOException {
return new InternalNode(urn, elementId, labels, props);
}

@SuppressWarnings("DuplicatedCode")
@Override
protected Value unpackPath() throws IOException {
// List of unique nodes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public MessageWriterV51(PackOutput output) {
super(new CommonValuePacker(output, true), buildEncoders());
}

@SuppressWarnings("DuplicatedCode")
private static Map<Byte, MessageEncoder> buildEncoders() {
Map<Byte, MessageEncoder> result = Iterables.newHashMapWithSize(9);
result.put(HelloMessage.SIGNATURE, new HelloMessageEncoder());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ public void packBytesHeader(int size) throws IOException {
}
}

@SuppressWarnings("DuplicatedCode")
private void packStringHeader(int size) throws IOException {
if (size < 0x10) {
out.writeByte((byte) (TINY_STRING | size));
Expand All @@ -358,6 +359,7 @@ private void packStringHeader(int size) throws IOException {
}
}

@SuppressWarnings("DuplicatedCode")
public void packListHeader(int size) throws IOException {
if (size < 0x10) {
out.writeByte((byte) (TINY_LIST | size));
Expand All @@ -370,6 +372,7 @@ public void packListHeader(int size) throws IOException {
}
}

@SuppressWarnings("DuplicatedCode")
public void packMapHeader(int size) throws IOException {
if (size < 0x10) {
out.writeByte((byte) (TINY_MAP | size));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ Publisher<S> doBeginTransaction(TransactionConfig config) {
return doBeginTransaction(config, null);
}

@SuppressWarnings("DuplicatedCode")
protected Publisher<S> doBeginTransaction(TransactionConfig config, String txType) {
return createSingleItemPublisher(
() -> {
Expand All @@ -80,6 +81,7 @@ protected Publisher<S> doBeginTransaction(TransactionConfig config, String txTyp
tx -> Mono.fromDirect(closeTransaction(tx, false)).subscribe());
}

@SuppressWarnings("DuplicatedCode")
private Publisher<S> beginTransaction(AccessMode mode, TransactionConfig config) {
return createSingleItemPublisher(
() -> {
Expand All @@ -101,21 +103,24 @@ private Publisher<S> beginTransaction(AccessMode mode, TransactionConfig config)
@SuppressWarnings("deprecation")
protected <T> Publisher<T> runTransaction(
AccessMode mode, Function<S, ? extends Publisher<T>> work, TransactionConfig config) {
work = work.andThen(publisher -> Flux.from(publisher).map(value -> {
work = work.andThen(publisher -> Flux.from(publisher).handle((value, sink) -> {
if (value instanceof ReactiveResult) {
throw new ClientException(String.format(
sink.error(new ClientException(String.format(
"%s is not a valid return value, it should be consumed before producing a return value",
ReactiveResult.class.getName()));
ReactiveResult.class.getName())));
return;
} else if (value instanceof org.neo4j.driver.reactive.ReactiveResult) {
throw new ClientException(String.format(
sink.error(new ClientException(String.format(
"%s is not a valid return value, it should be consumed before producing a return value",
org.neo4j.driver.reactive.ReactiveResult.class.getName()));
org.neo4j.driver.reactive.ReactiveResult.class.getName())));
return;
} else if (value instanceof RxResult) {
throw new ClientException(String.format(
sink.error(new ClientException(String.format(
"%s is not a valid return value, it should be consumed before producing a return value",
RxResult.class.getName()));
RxResult.class.getName())));
return;
}
return value;
sink.next(value);
}));
var repeatableWork = Flux.usingWhen(
beginTransaction(mode, config),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ protected InternalReactiveTransaction(UnmanagedTransaction tx) {
}

@Override
@SuppressWarnings({"ThrowableNotThrown", "DuplicatedCode"})
public Publisher<ReactiveResult> run(Query query) {
CompletionStage<RxResultCursor> cursorStage;
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import reactor.core.publisher.Mono;

@Deprecated
@SuppressWarnings("DeprecatedIsStillUsed")
public class InternalRxResult implements RxResult {
private Supplier<CompletionStage<RxResultCursor>> cursorFutureSupplier;
private volatile CompletionStage<RxResultCursor> cursorFuture;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.reactivestreams.Publisher;

@Deprecated
@SuppressWarnings("DeprecatedIsStillUsed")
public class InternalRxSession extends AbstractReactiveSession<RxTransaction> implements RxSession {
public InternalRxSession(NetworkSession session) {
super(session);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@
import org.reactivestreams.Publisher;

@Deprecated
@SuppressWarnings("DeprecatedIsStillUsed")
public class InternalRxTransaction extends AbstractReactiveTransaction implements RxTransaction {
public InternalRxTransaction(UnmanagedTransaction tx) {
super(tx);
}

@Override
@SuppressWarnings("ThrowableNotThrown")
public RxResult run(Query query) {
return new InternalRxResult(() -> {
var cursorFuture = new CompletableFuture<RxResultCursor>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ protected InternalReactiveTransaction(UnmanagedTransaction tx) {
}

@Override
@SuppressWarnings({"ThrowableNotThrown", "DuplicatedCode"})
public Publisher<ReactiveResult> run(Query query) {
CompletionStage<RxResultCursor> cursorStage;
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
* @deprecated superseded by {@link org.neo4j.driver.reactive.ReactiveTransactionCallback} and {@link org.neo4j.driver.reactivestreams.ReactiveTransactionCallback}
*/
@Deprecated
@SuppressWarnings("DeprecatedIsStillUsed")
public interface RxTransactionWork<T> {
/**
* Executes all given operations against the same transaction.
Expand Down
2 changes: 2 additions & 0 deletions driver/src/main/java/org/neo4j/driver/types/Relationship.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public interface Relationship extends Entity {
* @deprecated superseded by {@link #startNodeElementId()}
*/
@Deprecated
@SuppressWarnings("DeprecatedIsStillUsed")
long startNodeId();

/**
Expand All @@ -50,6 +51,7 @@ public interface Relationship extends Entity {
* @deprecated superseded by {@link #endNodeElementId()}
*/
@Deprecated
@SuppressWarnings("DeprecatedIsStillUsed")
long endNodeId();

/**
Expand Down
Loading