Skip to content

Commit 40db7b6

Browse files
committed
Merge branch '5.0' into micrometer-metrics
2 parents 85cbcd0 + 10fc7a0 commit 40db7b6

34 files changed

+322
-1340
lines changed

driver/clirr-ignored-differences.xml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,41 @@
4949
<method>java.lang.String version()</method>
5050
</difference>
5151

52+
<difference>
53+
<className>org/neo4j/driver/Record</className>
54+
<differenceType>7012</differenceType>
55+
<method>java.lang.Iterable keys()</method>
56+
</difference>
57+
58+
<difference>
59+
<className>org/neo4j/driver/Record</className>
60+
<differenceType>7012</differenceType>
61+
<method>java.lang.Iterable values()</method>
62+
</difference>
63+
64+
<difference>
65+
<className>org/neo4j/driver/Session</className>
66+
<differenceType>7002</differenceType>
67+
<method>void reset()</method>
68+
</difference>
69+
70+
<difference>
71+
<className>org/neo4j/driver/Config$ConfigBuilder</className>
72+
<differenceType>7002</differenceType>
73+
<method>org.neo4j.driver.Config$ConfigBuilder withRoutingFailureLimit(int)</method>
74+
</difference>
75+
76+
<difference>
77+
<className>org/neo4j/driver/Config$ConfigBuilder</className>
78+
<differenceType>7002</differenceType>
79+
<method>org.neo4j.driver.Config$ConfigBuilder withRoutingRetryDelay(long, java.util.concurrent.TimeUnit)</method>
80+
</difference>
81+
82+
<difference>
83+
<className>org/neo4j/driver/Config$TrustStrategy</className>
84+
<differenceType>7005</differenceType>
85+
<method>org.neo4j.driver.Config$TrustStrategy trustCustomCertificateSignedBy(java.io.File)</method>
86+
<to>org.neo4j.driver.Config$TrustStrategy trustCustomCertificateSignedBy(java.io.File[])</to>
87+
</difference>
88+
5289
</differences>

driver/src/main/java/org/neo4j/driver/Config.java

Lines changed: 31 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
import java.io.File;
2222
import java.io.Serializable;
2323
import java.net.InetAddress;
24+
import java.util.ArrayList;
25+
import java.util.Arrays;
26+
import java.util.Collections;
27+
import java.util.List;
2428
import java.util.Objects;
2529
import java.util.concurrent.TimeUnit;
2630
import java.util.logging.Level;
@@ -84,8 +88,6 @@ public class Config implements Serializable
8488

8589
private final SecuritySettings securitySettings;
8690

87-
private final int routingFailureLimit;
88-
private final long routingRetryDelayMillis;
8991
private final long fetchSize;
9092
private final long routingTablePurgeDelayMillis;
9193

@@ -110,8 +112,6 @@ private Config( ConfigBuilder builder )
110112

111113
this.securitySettings = builder.securitySettingsBuilder.build();
112114

113-
this.routingFailureLimit = builder.routingFailureLimit;
114-
this.routingRetryDelayMillis = builder.routingRetryDelayMillis;
115115
this.connectionTimeoutMillis = builder.connectionTimeoutMillis;
116116
this.routingTablePurgeDelayMillis = builder.routingTablePurgeDelayMillis;
117117
this.retrySettings = builder.retrySettings;
@@ -234,7 +234,7 @@ SecuritySettings securitySettings()
234234

235235
RoutingSettings routingSettings()
236236
{
237-
return new RoutingSettings( routingFailureLimit, routingRetryDelayMillis, routingTablePurgeDelayMillis );
237+
return new RoutingSettings( routingTablePurgeDelayMillis );
238238
}
239239

240240
RetrySettings retrySettings()
@@ -286,8 +286,6 @@ public static class ConfigBuilder
286286
private long connectionAcquisitionTimeoutMillis = PoolSettings.DEFAULT_CONNECTION_ACQUISITION_TIMEOUT;
287287
private String userAgent = format( "neo4j-java/%s", driverVersion() );
288288
private final SecuritySettings.SecuritySettingsBuilder securitySettingsBuilder = new SecuritySettings.SecuritySettingsBuilder();
289-
private int routingFailureLimit = RoutingSettings.DEFAULT.maxRoutingFailures();
290-
private long routingRetryDelayMillis = RoutingSettings.DEFAULT.retryTimeoutDelay();
291289
private long routingTablePurgeDelayMillis = RoutingSettings.DEFAULT.routingTablePurgeDelayMs();
292290
private int connectionTimeoutMillis = (int) TimeUnit.SECONDS.toMillis( 30 );
293291
private RetrySettings retrySettings = RetrySettings.DEFAULT;
@@ -475,7 +473,7 @@ public ConfigBuilder withoutEncryption()
475473

476474
/**
477475
* Specify how to determine the authenticity of an encryption certificate provided by the Neo4j instance we are connecting to. This defaults to {@link
478-
* TrustStrategy#trustSystemCertificates()}. See {@link TrustStrategy#trustCustomCertificateSignedBy(File)} for using certificate signatures instead to
476+
* TrustStrategy#trustSystemCertificates()}. See {@link TrustStrategy#trustCustomCertificateSignedBy(File...)} for using certificate signatures instead to
479477
* verify trust.
480478
* <p>
481479
* This is an important setting to understand, because unless we know that the remote server we have an encrypted connection to is really Neo4j, there
@@ -493,86 +491,6 @@ public ConfigBuilder withTrustStrategy( TrustStrategy trustStrategy )
493491
return this;
494492
}
495493

496-
/**
497-
* Specify how many times the client should attempt to reconnect to the routing servers before declaring the
498-
* cluster unavailable.
499-
* <p>
500-
* The routing servers are tried in order. If connecting any of them fails, they are all retried after
501-
* {@linkplain #withRoutingRetryDelay a delay}. This process of retrying all servers is then repeated for the
502-
* number of times specified here before considering the cluster unavailable.
503-
* <p>
504-
* The default value of this parameter is {@code 1}, which means that the the driver will not re-attempt to
505-
* connect to the cluster when connecting has failed to each individual server in the list of routers. This
506-
* default value is sensible under this assumption that if the attempt to connect fails for all servers, then
507-
* the entire cluster is down, or the client is disconnected from the network, and retrying to connect will
508-
* not bring it back up, in which case it is better to report the failure sooner.
509-
*
510-
* @param routingFailureLimit
511-
* the number of times to retry each server in the list of routing servers
512-
* @return this builder
513-
* @deprecated in 1.2 because driver memorizes seed URI used during construction and falls back to it at
514-
* runtime when all other known router servers failed to respond. Driver is also able to perform DNS lookup
515-
* for the seed URI during rediscovery. This means updates of cluster members will be picked up if they are
516-
* reflected in a DNS record. This configuration allowed driver to retry rediscovery procedure and postpone
517-
* failure. Currently there exists a better way of doing retries via
518-
* {@link Session#readTransaction(TransactionWork)} and {@link Session#writeTransaction(TransactionWork)}.
519-
* <b>Method will be removed in the next major release.</b>
520-
*/
521-
@Deprecated
522-
public ConfigBuilder withRoutingFailureLimit( int routingFailureLimit )
523-
{
524-
if ( routingFailureLimit < 1 )
525-
{
526-
throw new IllegalArgumentException(
527-
"The failure limit may not be smaller than 1, but was: " + routingFailureLimit );
528-
}
529-
this.routingFailureLimit = routingFailureLimit;
530-
return this;
531-
}
532-
533-
/**
534-
* Specify how long to wait before retrying to connect to a routing server.
535-
* <p>
536-
* When connecting to all routing servers fail, connecting will be retried after the delay specified here.
537-
* The delay is measured from when the first attempt to connect was made, so that the delay time specifies a
538-
* retry interval.
539-
* <p>
540-
* For each {@linkplain #withRoutingFailureLimit retry attempt} the delay time will be doubled. The time
541-
* specified here is the base time, i.e. the time to wait before the first retry. If that attempt (on all
542-
* servers) also fails, the delay before the next retry will be double the time specified here, and the next
543-
* attempt after that will be double that, et.c. So if, for example, the delay specified here is
544-
* {@code 5 SECONDS}, then after attempting to connect to each server fails reconnecting will be attempted
545-
* 5 seconds after the first connection attempt to the first server. If that attempt also fails to connect to
546-
* all servers, the next attempt will start 10 seconds after the second attempt started.
547-
* <p>
548-
* The default value of this parameter is {@code 5 SECONDS}.
549-
*
550-
* @param delay
551-
* the amount of time between attempts to reconnect to the same server
552-
* @param unit
553-
* the unit in which the duration is given
554-
* @return this builder
555-
* @deprecated in 1.2 because driver memorizes seed URI used during construction and falls back to it at
556-
* runtime when all other known router servers failed to respond. Driver is also able to perform DNS lookup
557-
* for the seed URI during rediscovery. This means updates of cluster members will be picked up if they are
558-
* reflected in a DNS record. This configuration allowed driver to retry rediscovery procedure and postpone
559-
* failure. Currently there exists a better way of doing retries via
560-
* {@link Session#readTransaction(TransactionWork)} and {@link Session#writeTransaction(TransactionWork)}.
561-
* <b>Method will be removed in the next major release.</b>
562-
*/
563-
@Deprecated
564-
public ConfigBuilder withRoutingRetryDelay( long delay, TimeUnit unit )
565-
{
566-
long routingRetryDelayMillis = unit.toMillis( delay );
567-
if ( routingRetryDelayMillis < 0 )
568-
{
569-
throw new IllegalArgumentException( String.format(
570-
"The retry delay may not be smaller than 0, but was %d %s.", delay, unit ) );
571-
}
572-
this.routingRetryDelayMillis = routingRetryDelayMillis;
573-
return this;
574-
}
575-
576494
/**
577495
* Specify how long to wait before purging stale routing tables.
578496
* <p>
@@ -833,19 +751,20 @@ public enum Strategy
833751
}
834752

835753
private final Strategy strategy;
836-
private final File certFile;
754+
private final List<File> certFiles;
837755
private boolean hostnameVerificationEnabled = true;
838756
private RevocationStrategy revocationStrategy = RevocationStrategy.NO_CHECKS;
839757

840758
private TrustStrategy( Strategy strategy )
841759
{
842-
this( strategy, null );
760+
this( strategy, Collections.emptyList() );
843761
}
844762

845-
private TrustStrategy( Strategy strategy, File certFile )
763+
private TrustStrategy( Strategy strategy, List<File> certFiles )
846764
{
765+
Objects.requireNonNull( certFiles, "certFiles can't be null" );
847766
this.strategy = strategy;
848-
this.certFile = certFile;
767+
this.certFiles = Collections.unmodifiableList( new ArrayList<>( certFiles ) );
849768
}
850769

851770
/**
@@ -862,10 +781,22 @@ public Strategy strategy()
862781
* Return the configured certificate file.
863782
*
864783
* @return configured certificate or {@code null} if trust strategy does not require a certificate.
784+
* @deprecated superseded by {@link TrustStrategy#certFiles()}
865785
*/
786+
@Deprecated
866787
public File certFile()
867788
{
868-
return certFile;
789+
return certFiles.isEmpty() ? null : certFiles.get( 0 );
790+
}
791+
792+
/**
793+
* Return the configured certificate files.
794+
*
795+
* @return configured certificate files or empty list if trust strategy does not require certificates.
796+
*/
797+
public List<File> certFiles()
798+
{
799+
return certFiles;
869800
}
870801

871802
/**
@@ -901,18 +832,18 @@ public TrustStrategy withoutHostnameVerification()
901832
}
902833

903834
/**
904-
* Only encrypted connections to Neo4j instances with certificates signed by a trusted certificate will be accepted.
905-
* The file specified should contain one or more trusted X.509 certificates.
835+
* Only encrypted connections to Neo4j instances with certificates signed by a trusted certificate will be accepted. The file(s) specified should
836+
* contain one or more trusted X.509 certificates.
906837
* <p>
907-
* The certificate(s) in the file must be encoded using PEM encoding, meaning the certificates in the file should be encoded using Base64,
908-
* and each certificate is bounded at the beginning by "-----BEGIN CERTIFICATE-----", and bounded at the end by "-----END CERTIFICATE-----".
838+
* The certificate(s) in the file(s) must be encoded using PEM encoding, meaning the certificates in the file(s) should be encoded using Base64, and
839+
* each certificate is bounded at the beginning by "-----BEGIN CERTIFICATE-----", and bounded at the end by "-----END CERTIFICATE-----".
909840
*
910-
* @param certFile the trusted certificate file
841+
* @param certFiles the trusted certificate files
911842
* @return an authentication config
912843
*/
913-
public static TrustStrategy trustCustomCertificateSignedBy( File certFile )
844+
public static TrustStrategy trustCustomCertificateSignedBy( File... certFiles )
914845
{
915-
return new TrustStrategy( Strategy.TRUST_CUSTOM_CA_SIGNED_CERTIFICATES, certFile );
846+
return new TrustStrategy( Strategy.TRUST_CUSTOM_CA_SIGNED_CERTIFICATES, Arrays.asList( certFiles ) );
916847
}
917848

918849
/**

driver/src/main/java/org/neo4j/driver/Record.java

Lines changed: 2 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,10 @@
1919
package org.neo4j.driver;
2020

2121
import java.util.List;
22-
import java.util.Map;
2322

24-
import org.neo4j.driver.internal.value.NullValue;
2523
import org.neo4j.driver.exceptions.ClientException;
2624
import org.neo4j.driver.exceptions.NoSuchRecordException;
2725
import org.neo4j.driver.types.MapAccessorWithDefaultValue;
28-
import java.util.function.Function;
2926
import org.neo4j.driver.util.Immutable;
3027
import org.neo4j.driver.util.Pair;
3128

@@ -49,23 +46,17 @@ public interface Record extends MapAccessorWithDefaultValue
4946
*
5047
* @return all field keys in order
5148
*/
49+
@Override
5250
List<String> keys();
5351

5452
/**
5553
* Retrieve the values of the underlying map
5654
*
5755
* @return all field keys in order
5856
*/
57+
@Override
5958
List<Value> values();
6059

61-
/**
62-
* Check if the list of keys contains the given key
63-
*
64-
* @param key the key
65-
* @return {@code true} if this map keys contains the given key otherwise {@code false}
66-
*/
67-
boolean containsKey( String key );
68-
6960
/**
7061
* Retrieve the index of the field with the given key
7162
*
@@ -75,15 +66,6 @@ public interface Record extends MapAccessorWithDefaultValue
7566
*/
7667
int index( String key );
7768

78-
/**
79-
* Retrieve the value of the property with the given key
80-
*
81-
* @param key the key of the property
82-
* @return the property's value or a {@link NullValue} if no such key exists
83-
* @throws NoSuchRecordException if the associated underlying record is not available
84-
*/
85-
Value get( String key );
86-
8769
/**
8870
* Retrieve the value at the given field index
8971
*
@@ -93,40 +75,11 @@ public interface Record extends MapAccessorWithDefaultValue
9375
*/
9476
Value get( int index );
9577

96-
/**
97-
* Retrieve the number of fields in this record
98-
*
99-
* @return the number of fields in this record
100-
*/
101-
int size();
102-
103-
/**
104-
* Return this record as a map, where each value has been converted to a default
105-
* java object using {@link Value#asObject()}.
106-
*
107-
* This is equivalent to calling {@link #asMap(Function)} with {@link Values#ofObject()}.
108-
*
109-
* @return this record as a map
110-
*/
111-
Map<String, Object> asMap();
112-
113-
/**
114-
* Return this record as a map, where each value has been converted using the provided
115-
* mapping function. You can find a library of common mapping functions in {@link Values}.
116-
*
117-
* @see Values for a long list of built-in conversion functions
118-
* @param mapper the mapping function
119-
* @param <T> the type to convert to
120-
* @return this record as a map
121-
*/
122-
<T> Map<String, T> asMap( Function<Value, T> mapper );
123-
12478
/**
12579
* Retrieve all record fields
12680
*
12781
* @return all fields in key order
12882
* @throws NoSuchRecordException if the associated underlying record is not available
12983
*/
13084
List<Pair<String, Value>> fields();
131-
13285
}

driver/src/main/java/org/neo4j/driver/Session.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -222,23 +222,6 @@ public interface Session extends Resource, QueryRunner
222222
*/
223223
Bookmark lastBookmark();
224224

225-
/**
226-
* Reset the current session. This sends an immediate RESET signal to the server which both interrupts
227-
* any query that is currently executing and ignores any subsequently queued queries. Following
228-
* the reset, the current transaction will have been rolled back and any outstanding failures will
229-
* have been acknowledged.
230-
*
231-
* @deprecated This method should not be used and violates the expected usage pattern of {@link Session} objects.
232-
* They are expected to be not thread-safe and should not be shared between thread. However this method is only
233-
* useful when {@link Session} object is passed to another monitoring thread that calls it when appropriate.
234-
* It is not useful when {@link Session} is used in a single thread because in this case {@link #close()}
235-
* can be used. Since version 3.1, Neo4j database allows users to specify maximum transaction execution time and
236-
* contains procedures to list and terminate running queries. These functions should be used instead of calling
237-
* this method.
238-
*/
239-
@Deprecated
240-
void reset();
241-
242225
/**
243226
* Signal that you are done using this session. In the default driver usage, closing and accessing sessions is
244227
* very low cost.

0 commit comments

Comments
 (0)