Skip to content

Commit 9ef8181

Browse files
author
a-brandt
committed
fixed sonarlint issue
1 parent a2a901c commit 9ef8181

File tree

3 files changed

+169
-161
lines changed

3 files changed

+169
-161
lines changed

src/main/java/com/arangodb/ArangoClient.java

Lines changed: 47 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -27,45 +27,53 @@
2727
*
2828
*/
2929
public class ArangoClient {
30-
31-
public static final int DEFAULT_IMPORT_BUFFER_SIZE = 1000;
32-
33-
protected ArangoDriver driver;
34-
35-
public ArangoClient(ArangoConfigure configure) {
36-
driver = new ArangoDriver(configure);
37-
}
3830

31+
public static final int DEFAULT_IMPORT_BUFFER_SIZE = 1000;
32+
33+
protected ArangoDriver driver;
34+
35+
public ArangoClient(ArangoConfigure configure) {
36+
driver = new ArangoDriver(configure);
37+
}
38+
39+
private void importDocumentsImpl(
40+
String collectionName,
41+
boolean createCollection,
42+
List<String> values,
43+
ImportResultEntity total) throws ArangoException {
44+
ImportResultEntity result = driver.importDocuments(collectionName, createCollection, values);
45+
total.setCreated(total.getCreated() + result.getCreated());
46+
total.setErrors(total.getErrors() + result.getErrors());
47+
total.setEmpty(total.getEmpty() + result.getEmpty());
48+
}
49+
50+
public ImportResultEntity importRawJsonDocuments(
51+
String collectionName,
52+
boolean createCollection,
53+
Iterator<String> itr,
54+
int bufferCount) throws ArangoException {
55+
56+
int tmpBufferCount = bufferCount;
57+
if (tmpBufferCount <= 0) {
58+
tmpBufferCount = DEFAULT_IMPORT_BUFFER_SIZE;
59+
}
60+
61+
ImportResultEntity total = new ImportResultEntity();
62+
63+
ArrayList<String> buffers = new ArrayList<String>(tmpBufferCount);
64+
while (itr.hasNext()) {
65+
buffers.add(itr.next());
66+
if (buffers.size() % tmpBufferCount == 0) {
67+
importDocumentsImpl(collectionName, createCollection, buffers, total);
68+
buffers.clear();
69+
}
70+
}
71+
if (!buffers.isEmpty()) {
72+
importDocumentsImpl(collectionName, createCollection, buffers, total);
73+
}
74+
75+
return total;
76+
77+
}
3978

40-
private void importDocumentsImpl(String collectionName, boolean createCollection, List<String> values, ImportResultEntity total) throws ArangoException {
41-
ImportResultEntity result = driver.importDocuments(collectionName, createCollection, values);
42-
total.setCreated(total.getCreated() + result.getCreated());
43-
total.setErrors(total.getErrors() + result.getErrors());
44-
total.setEmpty(total.getEmpty() + result.getEmpty());
45-
}
46-
47-
public ImportResultEntity importRawJsonDocuments(String collectionName, boolean createCollection, Iterator<String> itr, int bufferCount) throws ArangoException {
48-
49-
if (bufferCount <= 0) {
50-
bufferCount = DEFAULT_IMPORT_BUFFER_SIZE;
51-
}
52-
53-
ImportResultEntity total = new ImportResultEntity();
54-
55-
ArrayList<String> buffers = new ArrayList<String>(bufferCount);
56-
while (itr.hasNext()) {
57-
buffers.add(itr.next());
58-
if (buffers.size() % bufferCount == 0) {
59-
importDocumentsImpl(collectionName, createCollection, buffers, total);
60-
buffers.clear();
61-
}
62-
}
63-
if (!buffers.isEmpty()) {
64-
importDocumentsImpl(collectionName, createCollection, buffers, total);
65-
}
66-
67-
return total;
68-
69-
}
70-
7179
}

src/main/java/com/arangodb/ArangoConfigure.java

Lines changed: 121 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public class ArangoConfigure {
4747
private static final int DEFAULT_PORT = 8529;
4848

4949
/** default */
50-
private static final int DEFAULT_MAX_PER_CONNECTION = 20; // 2;
50+
private static final int DEFAULT_MAX_PER_CONNECTION = 20;
5151
/** default maximum conections */
5252
private static final int DEFAULT_MAX_CONNECTION = 20;
5353

@@ -146,125 +146,9 @@ public void loadProperties(String propertyPath) {
146146
try {
147147
in = getClass().getResourceAsStream(propertyPath);
148148
if (in != null) {
149-
150149
logger.debug("load property: file={}", propertyPath);
151150

152-
Properties prop = new Properties();
153-
prop.load(in);
154-
155-
//
156-
String port = prop.getProperty("port");
157-
if (port != null) {
158-
arangoHosts.get(0).setPort(Integer.parseInt(port));
159-
}
160-
161-
String host = prop.getProperty("host");
162-
if (host != null) {
163-
arangoHosts.get(0).setHost(host);
164-
}
165-
166-
String arangoHost = prop.getProperty("arangoHost");
167-
if (arangoHost != null) {
168-
ArangoHost ah = parseArangoHost(arangoHost);
169-
if (ah != null) {
170-
arangoHosts.get(0).setHost(ah.getHost());
171-
arangoHosts.get(0).setPort(ah.getPort());
172-
}
173-
}
174-
175-
String fallbackArangoHost = prop.getProperty("fallbackArangoHost");
176-
if (fallbackArangoHost != null) {
177-
ArangoHost ah = parseArangoHost(fallbackArangoHost);
178-
if (ah != null) {
179-
addFallbackArangoHost(ah);
180-
}
181-
}
182-
183-
String timeout = prop.getProperty("timeout");
184-
if (timeout != null) {
185-
setTimeout(Integer.parseInt(timeout));
186-
}
187-
188-
String connectionTimeout = prop.getProperty("connectionTimeout");
189-
if (connectionTimeout != null) {
190-
setConnectionTimeout(Integer.parseInt(connectionTimeout));
191-
}
192-
193-
String proxyHost = prop.getProperty("proxy.host");
194-
if (proxyHost != null) {
195-
setProxyHost(proxyHost);
196-
}
197-
198-
String proxyPort = prop.getProperty("proxy.port");
199-
if (proxyPort != null) {
200-
setProxyPort(Integer.parseInt(proxyPort));
201-
}
202-
203-
String maxPerConnection = prop.getProperty("maxPerConnection");
204-
if (maxPerConnection != null) {
205-
setMaxPerConnection(Integer.parseInt(maxPerConnection));
206-
}
207-
208-
String maxTotalConnection = prop.getProperty("maxTotalConnection");
209-
if (maxTotalConnection != null) {
210-
setMaxTotalConnection(Integer.parseInt(maxTotalConnection));
211-
}
212-
213-
String retryCount = prop.getProperty("retryCount");
214-
if (retryCount != null) {
215-
setRetryCount(Integer.parseInt(retryCount));
216-
}
217-
218-
String connnectRetryCount = prop.getProperty("connnectRetryCount");
219-
if (connnectRetryCount != null) {
220-
setConnectRetryCount(Integer.parseInt(connnectRetryCount));
221-
}
222-
223-
String connectRetryWait = prop.getProperty("connectRetryWait");
224-
if (connectRetryWait != null) {
225-
setConnectRetryWait(Integer.parseInt(connectRetryWait));
226-
}
227-
228-
String user = prop.getProperty("user");
229-
if (user != null) {
230-
setUser(user);
231-
}
232-
233-
String password = prop.getProperty("password");
234-
if (password != null) {
235-
setPassword(password);
236-
}
237-
238-
String defaultDatabase = prop.getProperty("defaultDatabase");
239-
if (defaultDatabase != null) {
240-
setDefaultDatabase(defaultDatabase);
241-
}
242-
243-
String enableCURLLogger = prop.getProperty("enableCURLLogger");
244-
if (enableCURLLogger != null) {
245-
setEnableCURLLogger(Boolean.parseBoolean(enableCURLLogger));
246-
}
247-
248-
String staleConnectionCheck = prop.getProperty("staleConnectionCheck");
249-
if (staleConnectionCheck != null) {
250-
setStaleConnectionCheck(Boolean.parseBoolean(staleConnectionCheck));
251-
}
252-
253-
String batchSize = prop.getProperty("batchSize");
254-
if (batchSize != null) {
255-
setBatchSize(Integer.parseInt(batchSize));
256-
}
257-
258-
String useSsl = prop.getProperty("useSsl");
259-
if (useSsl != null) {
260-
setUseSsl(Boolean.parseBoolean(useSsl));
261-
}
262-
263-
String sslTrustStore = prop.getProperty("sslTrustStore");
264-
if (sslTrustStore != null) {
265-
setSslTrustStore(sslTrustStore);
266-
}
267-
151+
loadProperties(in);
268152
}
269153
} catch (IOException e) {
270154
logger.warn("load property error", e);
@@ -275,6 +159,125 @@ public void loadProperties(String propertyPath) {
275159
}
276160
}
277161

162+
private void loadProperties(InputStream in) throws IOException {
163+
164+
Properties prop = new Properties();
165+
prop.load(in);
166+
167+
//
168+
String port = prop.getProperty("port");
169+
if (port != null) {
170+
arangoHosts.get(0).setPort(Integer.parseInt(port));
171+
}
172+
173+
String host = prop.getProperty("host");
174+
if (host != null) {
175+
arangoHosts.get(0).setHost(host);
176+
}
177+
178+
String arangoHost = prop.getProperty("arangoHost");
179+
if (arangoHost != null) {
180+
ArangoHost ah = parseArangoHost(arangoHost);
181+
if (ah != null) {
182+
arangoHosts.get(0).setHost(ah.getHost());
183+
arangoHosts.get(0).setPort(ah.getPort());
184+
}
185+
}
186+
187+
String fallbackArangoHost = prop.getProperty("fallbackArangoHost");
188+
if (fallbackArangoHost != null) {
189+
ArangoHost ah = parseArangoHost(fallbackArangoHost);
190+
if (ah != null) {
191+
addFallbackArangoHost(ah);
192+
}
193+
}
194+
195+
String timeoutProperty = prop.getProperty("timeout");
196+
if (timeoutProperty != null) {
197+
setTimeout(Integer.parseInt(timeoutProperty));
198+
}
199+
200+
String connectionTimeoutProperty = prop.getProperty("connectionTimeout");
201+
if (connectionTimeoutProperty != null) {
202+
setConnectionTimeout(Integer.parseInt(connectionTimeoutProperty));
203+
}
204+
205+
String proxyHostProperty = prop.getProperty("proxy.host");
206+
if (proxyHostProperty != null) {
207+
setProxyHost(proxyHostProperty);
208+
}
209+
210+
String proxyPortProperty = prop.getProperty("proxy.port");
211+
if (proxyPortProperty != null) {
212+
setProxyPort(Integer.parseInt(proxyPortProperty));
213+
}
214+
215+
String maxPerConnectionProperty = prop.getProperty("maxPerConnection");
216+
if (maxPerConnectionProperty != null) {
217+
setMaxPerConnection(Integer.parseInt(maxPerConnectionProperty));
218+
}
219+
220+
String maxTotalConnectionProperty = prop.getProperty("maxTotalConnection");
221+
if (maxTotalConnectionProperty != null) {
222+
setMaxTotalConnection(Integer.parseInt(maxTotalConnectionProperty));
223+
}
224+
225+
String retryCountProperty = prop.getProperty("retryCount");
226+
if (retryCountProperty != null) {
227+
setRetryCount(Integer.parseInt(retryCountProperty));
228+
}
229+
230+
String connnectRetryCount = prop.getProperty("connnectRetryCount");
231+
if (connnectRetryCount != null) {
232+
setConnectRetryCount(Integer.parseInt(connnectRetryCount));
233+
}
234+
235+
String connectRetryWaitProperty = prop.getProperty("connectRetryWait");
236+
if (connectRetryWaitProperty != null) {
237+
setConnectRetryWait(Integer.parseInt(connectRetryWaitProperty));
238+
}
239+
240+
String userProperty = prop.getProperty("user");
241+
if (userProperty != null) {
242+
setUser(userProperty);
243+
}
244+
245+
String passwordProperty = prop.getProperty("password");
246+
if (passwordProperty != null) {
247+
setPassword(passwordProperty);
248+
}
249+
250+
String defaultDatabaseProperty = prop.getProperty("defaultDatabase");
251+
if (defaultDatabaseProperty != null) {
252+
setDefaultDatabase(defaultDatabaseProperty);
253+
}
254+
255+
String enableCURLLoggerProperty = prop.getProperty("enableCURLLogger");
256+
if (enableCURLLoggerProperty != null) {
257+
setEnableCURLLogger(Boolean.parseBoolean(enableCURLLoggerProperty));
258+
}
259+
260+
String staleConnectionCheckProperty = prop.getProperty("staleConnectionCheck");
261+
if (staleConnectionCheckProperty != null) {
262+
setStaleConnectionCheck(Boolean.parseBoolean(staleConnectionCheckProperty));
263+
}
264+
265+
String batchSizeProperty = prop.getProperty("batchSize");
266+
if (batchSizeProperty != null) {
267+
setBatchSize(Integer.parseInt(batchSizeProperty));
268+
}
269+
270+
String useSslProperty = prop.getProperty("useSsl");
271+
if (useSslProperty != null) {
272+
setUseSsl(Boolean.parseBoolean(useSslProperty));
273+
}
274+
275+
String sslTrustStoreProperty = prop.getProperty("sslTrustStore");
276+
if (sslTrustStoreProperty != null) {
277+
setSslTrustStore(sslTrustStoreProperty);
278+
}
279+
}
280+
278281
private ArangoHost parseArangoHost(String str) {
279282
if (str == null) {
280283
return null;

src/main/java/com/arangodb/ArangoDriver.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5361,10 +5361,7 @@ public <T> CursorEntity<T> graphGetEdges(String graphName, Class<T> clazz, Strin
53615361
Map<String, Object> bindVars = new MapBuilder().put("graphName", graphName)
53625362
.put("vertexDocumentHandle", vertexDocumentHandle).get();
53635363

5364-
CursorEntity<T> result = this.executeQuery(query, bindVars, clazz, true, 20);
5365-
5366-
return result;
5367-
5364+
return this.executeQuery(query, bindVars, clazz, true, 20);
53685365
}
53695366

53705367
/**

0 commit comments

Comments
 (0)