Skip to content

Commit 08802b8

Browse files
author
Zhen Li
committed
Only suppress error if it is different from the original one
1 parent 5d335cb commit 08802b8

File tree

6 files changed

+17
-12
lines changed

6 files changed

+17
-12
lines changed

driver/src/main/java/org/neo4j/driver/internal/DriverFactory.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import org.neo4j.driver.internal.async.ChannelConnectorImpl;
3232
import org.neo4j.driver.internal.async.pool.ConnectionPoolImpl;
3333
import org.neo4j.driver.internal.async.pool.PoolSettings;
34-
import org.neo4j.driver.internal.cluster.IdentityResolver;
3534
import org.neo4j.driver.internal.cluster.RoutingContext;
3635
import org.neo4j.driver.internal.cluster.RoutingSettings;
3736
import org.neo4j.driver.internal.cluster.loadbalancing.LeastConnectedLoadBalancingStrategy;
@@ -66,6 +65,7 @@
6665
import static org.neo4j.driver.internal.metrics.InternalAbstractMetrics.DEV_NULL_METRICS;
6766
import static org.neo4j.driver.internal.metrics.spi.Metrics.isMetricsEnabled;
6867
import static org.neo4j.driver.internal.security.SecurityPlan.insecure;
68+
import static org.neo4j.driver.internal.util.ErrorUtil.addSuppressed;
6969

7070
public class DriverFactory
7171
{
@@ -371,10 +371,7 @@ private static void closeConnectionPoolAndSuppressError( ConnectionPool connecti
371371
}
372372
catch ( Throwable closeError )
373373
{
374-
if ( mainError != closeError )
375-
{
376-
mainError.addSuppressed( closeError );
377-
}
374+
addSuppressed( mainError, closeError );
378375
}
379376
}
380377

driver/src/main/java/org/neo4j/driver/internal/NetworkSession.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343

4444
import static java.util.Collections.emptyMap;
4545
import static java.util.concurrent.CompletableFuture.completedFuture;
46+
import static org.neo4j.driver.internal.util.ErrorUtil.addSuppressed;
4647
import static org.neo4j.driver.internal.util.Futures.completedWithNull;
4748
import static org.neo4j.driver.internal.util.Futures.failedFuture;
4849

@@ -403,7 +404,7 @@ private <T> void rollbackTxAfterFailedTransactionWork( ExplicitTransaction tx, C
403404
{
404405
if ( rollbackError != null )
405406
{
406-
error.addSuppressed( rollbackError );
407+
addSuppressed( error, rollbackError );
407408
}
408409
resultFuture.completeExceptionally( error );
409410
} );

driver/src/main/java/org/neo4j/driver/internal/async/inbound/InboundMessageDispatcher.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737

3838
import static java.util.Objects.requireNonNull;
3939
import static org.neo4j.driver.internal.messaging.request.ResetMessage.RESET;
40+
import static org.neo4j.driver.internal.util.ErrorUtil.addSuppressed;
4041

4142
public class InboundMessageDispatcher implements ResponseMessageHandler
4243
{
@@ -146,7 +147,7 @@ public void handleChannelError( Throwable error )
146147
if ( currentError != null )
147148
{
148149
// we already have an error, this new error probably is caused by the existing one, thus we chain the new error on this current error
149-
currentError.addSuppressed( error );
150+
addSuppressed( currentError, error );
150151
}
151152
else
152153
{

driver/src/main/java/org/neo4j/driver/internal/async/pool/NettyChannelTracker.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public NettyChannelTracker( MetricsListener metricsListener, ChannelGroup channe
6262
@Override
6363
public void channelReleased( Channel channel )
6464
{
65-
log.debug( "Channel [%s] released back to the pool", channel.id() );
65+
log.debug( "Channel [0x%s] released back to the pool", channel.id() );
6666
decrementInUse( channel );
6767
incrementIdle( channel );
6868
channel.closeFuture().addListener( closeListener );

driver/src/main/java/org/neo4j/driver/internal/util/ErrorUtil.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,14 @@ private static String extractClassification( String code )
127127
return parts[1];
128128
}
129129

130+
public static void addSuppressed( Throwable mainError, Throwable error )
131+
{
132+
if ( mainError != error )
133+
{
134+
mainError.addSuppressed( error );
135+
}
136+
}
137+
130138
/**
131139
* Exception which is merely a holder of an async stacktrace, which is not the primary stacktrace users are interested in.
132140
* Used for blocking API calls that block on async API calls.

driver/src/main/java/org/neo4j/driver/internal/util/Futures.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.neo4j.driver.internal.async.EventLoopGroupFactory;
3030

3131
import static java.util.concurrent.CompletableFuture.completedFuture;
32+
import static org.neo4j.driver.internal.util.ErrorUtil.addSuppressed;
3233

3334
public final class Futures
3435
{
@@ -184,10 +185,7 @@ public static CompletionException combineErrors( Throwable error1, Throwable err
184185
{
185186
Throwable cause1 = completionExceptionCause( error1 );
186187
Throwable cause2 = completionExceptionCause( error2 );
187-
if ( cause1 != cause2 )
188-
{
189-
cause1.addSuppressed( cause2 );
190-
}
188+
addSuppressed( cause1, cause2 );
191189
return asCompletionException( cause1 );
192190
}
193191
else if ( error1 != null )

0 commit comments

Comments
 (0)