File tree Expand file tree Collapse file tree 5 files changed +84
-8
lines changed
algoliasearch-java-net/src
main/java/com/algolia/search
test/java/com/algolia/search Expand file tree Collapse file tree 5 files changed +84
-8
lines changed Original file line number Diff line number Diff line change 61
61
paths :
62
62
- " ~/.m2"
63
63
64
+ test-java-17 :
65
+ docker :
66
+ - image : cimg/openjdk:17.0
67
+ steps :
68
+ - checkout
69
+ - restore_cache :
70
+ key : mvn-cache-11
71
+ - credentials
72
+ - run :
73
+ name : " Compile project"
74
+ command : mvn clean compile
75
+ - run :
76
+ name : " Run the tests"
77
+ command : mvn clean test
78
+ - save_cache :
79
+ key : mvn-cache-11
80
+ paths :
81
+ - " ~/.m2"
82
+
64
83
release :
65
84
docker :
66
85
- image : cimg/openjdk:11.0
@@ -104,11 +123,18 @@ workflows:
104
123
filters :
105
124
tags :
106
125
only : /.*/
126
+ - test-java-17 :
127
+ requires :
128
+ - test-java-11
129
+ filters :
130
+ tags :
131
+ only : /.*/
107
132
- release :
108
133
requires :
109
134
- format
110
135
- test-java-8
111
136
- test-java-11
137
+ - test-java-17
112
138
filters :
113
139
tags :
114
140
only : /^[1-9]+.[0-9]+.[0-9]+.*/
Original file line number Diff line number Diff line change @@ -36,12 +36,25 @@ public final class JavaNetHttpRequester implements HttpRequester {
36
36
* @param config HTTPClient agnostic Algolia's configuration.
37
37
*/
38
38
public JavaNetHttpRequester (@ Nonnull ConfigBase config ) {
39
+ this (
40
+ config ,
41
+ config .getUseSystemProxy ()
42
+ ? HttpClient .newBuilder ().proxy (ProxySelector .getDefault ())
43
+ : HttpClient .newBuilder ());
44
+ }
45
+
46
+ /**
47
+ * Build the reusable instance of httpClient with the given configuration.
48
+ *
49
+ * @param config HTTPClient agnostic Algolia's configuration
50
+ * @param builder Builder for {@linkplain HttpClient HTTP Clients}
51
+ */
52
+ public JavaNetHttpRequester (@ Nonnull ConfigBase config , HttpClient .Builder builder ) {
39
53
client =
40
- HttpClient . newBuilder ()
54
+ builder
41
55
.executor (config .getExecutor ())
42
56
.version (HttpClient .Version .HTTP_2 )
43
57
.followRedirects (HttpClient .Redirect .NEVER )
44
- .proxy (ProxySelector .getDefault ())
45
58
.connectTimeout (Duration .ofMillis (config .getConnectTimeOut ()))
46
59
.build ();
47
60
}
Original file line number Diff line number Diff line change
1
+ package com .algolia .search ;
2
+
3
+ import com .algolia .search .exceptions .AlgoliaRuntimeException ;
4
+ import java .security .NoSuchAlgorithmException ;
5
+ import javax .net .ssl .SSLContext ;
6
+ import javax .net .ssl .SSLParameters ;
7
+
8
+ public class SSLUtils {
9
+
10
+ // Suppress default constructor for noninstantiability
11
+ private SSLUtils () {
12
+ throw new AssertionError ();
13
+ }
14
+
15
+ /** Default SSL parameters without specifying protocols */
16
+ public static SSLParameters getDefaultSSLParameters () {
17
+ SSLParameters sslParameters = getDefaultSSLContext ().getSupportedSSLParameters ();
18
+ sslParameters .setProtocols (null );
19
+ return sslParameters ;
20
+ }
21
+
22
+ /** Get default SSL Context */
23
+ private static SSLContext getDefaultSSLContext () {
24
+ try {
25
+ return SSLContext .getDefault ();
26
+ } catch (NoSuchAlgorithmException ex ) {
27
+ throw new AlgoliaRuntimeException (ex );
28
+ }
29
+ }
30
+ }
Original file line number Diff line number Diff line change 5
5
6
6
import com .algolia .search .*;
7
7
import java .io .IOException ;
8
+ import java .net .http .HttpClient ;
8
9
import org .junit .jupiter .api .AfterAll ;
9
10
import org .junit .jupiter .api .extension .ExtendWith ;
10
11
@@ -14,7 +15,11 @@ class AnalyticsTest extends com.algolia.search.integration.analytics.AnalyticsTe
14
15
private static AnalyticsConfig analyticsConfig =
15
16
new AnalyticsConfig .Builder (ALGOLIA_APPLICATION_ID_1 , ALGOLIA_ADMIN_KEY_1 ).build ();
16
17
private static AnalyticsClient analyticsClient =
17
- new AnalyticsClient (analyticsConfig , new JavaNetHttpRequester (analyticsConfig ));
18
+ new AnalyticsClient (
19
+ analyticsConfig ,
20
+ new JavaNetHttpRequester (
21
+ analyticsConfig ,
22
+ HttpClient .newBuilder ().sslParameters (SSLUtils .getDefaultSSLParameters ())));
18
23
19
24
AnalyticsTest () {
20
25
super (IntegrationTestExtension .searchClient , analyticsClient );
Original file line number Diff line number Diff line change 3
3
import static com .algolia .search .integration .TestHelpers .ALGOLIA_ADMIN_KEY_1 ;
4
4
import static com .algolia .search .integration .TestHelpers .ALGOLIA_APPLICATION_ID_1 ;
5
5
6
- import com .algolia .search .InsightsClient ;
7
- import com .algolia .search .InsightsConfig ;
8
- import com .algolia .search .IntegrationTestExtension ;
9
- import com .algolia .search .JavaNetHttpRequester ;
6
+ import com .algolia .search .*;
7
+ import java .net .http .HttpClient ;
10
8
import org .junit .jupiter .api .extension .ExtendWith ;
11
9
12
10
@ ExtendWith ({IntegrationTestExtension .class })
@@ -18,6 +16,10 @@ class InsightsTest extends com.algolia.search.integration.insights.InsightsTest
18
16
InsightsTest () {
19
17
super (
20
18
IntegrationTestExtension .searchClient ,
21
- new InsightsClient (config , new JavaNetHttpRequester (config )));
19
+ new InsightsClient (
20
+ config ,
21
+ new JavaNetHttpRequester (
22
+ config ,
23
+ HttpClient .newBuilder ().sslParameters (SSLUtils .getDefaultSSLParameters ()))));
22
24
}
23
25
}
You can’t perform that action at this time.
0 commit comments