Skip to content

Commit 709b815

Browse files
Merge pull request #187 from casz/chore/overallCodeHealth
Overall code health improvements
2 parents 1191abd + ace3e0f commit 709b815

File tree

94 files changed

+848
-702
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+848
-702
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto eol=lf

.github/workflows/gradle.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: CI
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build:
7+
name: Build on JDK ${{ matrix.java }} and ${{ matrix.os }}
8+
runs-on: ${{ matrix.os }}
9+
strategy:
10+
matrix:
11+
java: [9, 11, 12]
12+
os: [ubuntu-latest, windows-latest]
13+
include:
14+
# TODO(casz) remove once https://github.com/testcontainers/testcontainers-java/pull/1780 is available
15+
- os: 'ubuntu-latest'
16+
tasks: 'integrationTest'
17+
18+
steps:
19+
- uses: actions/checkout@v1
20+
- name: Set up JDK ${{ matrix.java }}
21+
uses: actions/setup-java@v1
22+
with:
23+
java-version: ${{ matrix.java }}
24+
- name: Build with Gradle
25+
run: ./gradlew build ${{ matrix.tasks }} -s --info

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
.gradle
2-
.idea
2+
.idea/*
3+
!.idea/codeStyles/
34
.testcontainers-tmp*
45

56
vault-java-driver.iml

.idea/codeStyles/Project.xml

Lines changed: 125 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/codeStyles/codeStyleConfig.xml

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.travis.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
language: java
2+
3+
dist: xenial
4+
5+
services:
6+
- docker
7+
8+
before_cache:
9+
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
10+
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
11+
12+
cache:
13+
directories:
14+
- $HOME/.gradle/caches/
15+
- $HOME/.gradle/wrapper/
16+
17+
matrix:
18+
include:
19+
- jdk: openjdk12
20+
- jdk: openjdk11
21+
- jdk: openjdk9
22+
23+
script:
24+
- ./gradlew build integrationTest -s --info
25+
26+
notifications:
27+
email: false

build.gradle

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
apply plugin: 'java'
22
apply plugin: 'maven'
33
apply plugin: 'signing'
4+
apply plugin: 'checkstyle'
45

56
group 'com.bettercloud'
67
archivesBaseName = 'vault-java-driver'
@@ -18,7 +19,7 @@ repositories {
1819
dependencies {
1920
testCompile('junit:junit:4.12')
2021
testCompile('org.mockito:mockito-core:2.28.2')
21-
testCompile('org.testcontainers:testcontainers:1.11.3')
22+
testCompile('org.testcontainers:testcontainers:1.12.0')
2223
testCompile('org.eclipse.jetty:jetty-server:9.4.19.v20190610')
2324
testCompile('org.slf4j:slf4j-api:1.7.26')
2425
testCompile('org.bouncycastle:bcprov-jdk15on:1.62')
@@ -46,10 +47,14 @@ compileJava {
4647
options.compilerArgs = ['--release', '8']
4748
}
4849

50+
compileJava.options.encoding = 'UTF-8'
51+
compileTestJava.options.encoding = 'UTF-8'
52+
4953
task compileModuleInfoJava(type: JavaCompile) {
5054
classpath = files()
5155
source = 'src/main/java/module-info.java'
5256
destinationDir = compileJava.destinationDir
57+
options.encoding = compileJava.options.encoding
5358

5459
doFirst {
5560
options.compilerArgs = [
@@ -207,4 +212,3 @@ uploadArchives {
207212
}
208213
}
209214
}
210-

config/checkstyle/checkstyle.xml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.2//EN"
3+
"http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
4+
<module name="Checker">
5+
<module name="BeforeExecutionExclusionFileFilter">
6+
<property name="fileNamePattern" value="module\-info\.java$"/>
7+
</module>
8+
<module name="FileTabCharacter"/>
9+
<module name="NewlineAtEndOfFile">
10+
<property name="lineSeparator" value="lf"/>
11+
</module>
12+
<module name="RegexpSingleline">
13+
<property name="format" value="\s+$"/>
14+
<property name="message" value="Trailing spaces are not allowed."/>
15+
</module>
16+
<module name="TreeWalker">
17+
<module name="ImportOrder">
18+
<property name="separatedStaticGroups" value="true"/>
19+
<property name="option" value="bottom"/>
20+
</module>
21+
<module name="UnusedImports"/>
22+
<module name="AvoidStarImport"/>
23+
</module>
24+
</module>

src/main/java/com/bettercloud/vault/SslConfig.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
package com.bettercloud.vault;
22

33
import com.bettercloud.vault.api.Auth;
4-
5-
import javax.net.ssl.KeyManager;
6-
import javax.net.ssl.KeyManagerFactory;
7-
import javax.net.ssl.SSLContext;
8-
import javax.net.ssl.TrustManager;
9-
import javax.net.ssl.TrustManagerFactory;
104
import java.io.BufferedReader;
115
import java.io.ByteArrayInputStream;
126
import java.io.File;
@@ -31,6 +25,11 @@
3125
import java.security.spec.InvalidKeySpecException;
3226
import java.security.spec.PKCS8EncodedKeySpec;
3327
import java.util.Base64;
28+
import javax.net.ssl.KeyManager;
29+
import javax.net.ssl.KeyManagerFactory;
30+
import javax.net.ssl.SSLContext;
31+
import javax.net.ssl.TrustManager;
32+
import javax.net.ssl.TrustManagerFactory;
3433

3534
/**
3635
* <p>A container for SSL-related configuration options, meant to be stored within a {@link VaultConfig} instance.</p>
@@ -444,13 +443,13 @@ public SslConfig build() throws VaultException {
444443
this.environmentLoader = new EnvironmentLoader();
445444
}
446445
if (this.verifyObject == null && environmentLoader.loadVariable(VAULT_SSL_VERIFY) != null) {
447-
this.verify = Boolean.valueOf(environmentLoader.loadVariable(VAULT_SSL_VERIFY));
446+
this.verify = Boolean.parseBoolean(environmentLoader.loadVariable(VAULT_SSL_VERIFY));
448447
} else if (this.verifyObject != null) {
449448
this.verify = verifyObject;
450449
} else {
451450
this.verify = true;
452451
}
453-
if (this.verify == true && this.pemUTF8 == null && environmentLoader.loadVariable(VAULT_SSL_CERT) != null) {
452+
if (this.verify && this.pemUTF8 == null && environmentLoader.loadVariable(VAULT_SSL_CERT) != null) {
454453
final File pemFile = new File(environmentLoader.loadVariable(VAULT_SSL_CERT));
455454
try (final InputStream input = new FileInputStream(pemFile)) {
456455
this.pemUTF8 = inputStreamToUTF8(input);
@@ -487,7 +486,7 @@ protected String getPemUTF8() {
487486
* @throws VaultException
488487
*/
489488
private void buildSsl() throws VaultException {
490-
if (verify == true) {
489+
if (verify) {
491490
if (keyStore != null || trustStore != null) {
492491
this.sslContext = buildSslContextFromJks();
493492
} else if (pemUTF8 != null || clientPemUTF8 != null || clientKeyPemUTF8 != null) {
@@ -625,7 +624,7 @@ private KeyStore inputStreamToKeyStore(final InputStream inputStream, final Stri
625624
*/
626625
private static String inputStreamToUTF8(final InputStream input) throws IOException {
627626
final BufferedReader in = new BufferedReader(new InputStreamReader(input, StandardCharsets.UTF_8));
628-
final StringBuilder utf8 = new StringBuilder("");
627+
final StringBuilder utf8 = new StringBuilder();
629628
String str;
630629
while ((str = in.readLine()) != null) {
631630
// String concatenation is less efficient, but for some reason the line-breaks (which are necessary

src/main/java/com/bettercloud/vault/Vault.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import com.bettercloud.vault.rest.Rest;
1515
import com.bettercloud.vault.rest.RestException;
1616
import com.bettercloud.vault.rest.RestResponse;
17-
1817
import java.nio.charset.StandardCharsets;
1918
import java.util.HashMap;
2019
import java.util.Map;

0 commit comments

Comments
 (0)