Skip to content

Commit

Permalink
Remove trailing whitespace
Browse files Browse the repository at this point in the history
- Let Checkstyle check for trailing whitespace
- Use final
  • Loading branch information
garydgregory committed Feb 18, 2024
1 parent 1f3ca45 commit bbbd007
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 16 deletions.
7 changes: 6 additions & 1 deletion src/conf/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,16 @@ limitations under the License.
<property name="separated" value="true" />
</module>
</module>
<!-- @author tags are deprecated -->
<module name="RegexpSingleline">
<!-- @author tags are deprecated -->
<property name="format" value="^\s+\*\s+@author\s" />
<property name="message" value="Deprecated @author tag" />
<property name="fileExtensions" value="java" />
<property name="severity" value="warning" />
</module>
<module name="RegexpSingleline">
<!-- \s matches whitespace character, $ matches end of line. -->
<property name="format" value="\s+$" />
<property name="message" value="Line has trailing spaces." />
</module>
</module>
10 changes: 5 additions & 5 deletions src/main/java/org/apache/commons/crypto/Crypto.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ private static Properties getComponentProperties() {
public static final String JNA_LIBRARY_NAME_DEFAULT = "crypto";
/**
* Name for loading SSL crypto library using dlopen on macOS
* JNA automatically adds prefix and suffix; dlopen does not
* JNA automatically adds prefix and suffix; dlopen does not
*/
public static final String MACOS_LIBRARY_NAME_DEFAULT = "libcrypto.dylib";

Expand Down Expand Up @@ -201,7 +201,7 @@ public static void main(final String[] args) throws Exception {
info("DLL path: %s", OpenSslInfoNative.DLLPath());
info("Additional OpenSSL_version(n) details:");
for (int j = 1; j < Utils.OPENSSL_VERSION_MAX_INDEX; j++) { // entry 0 is shown above
String data = OpenSslInfoNative.OpenSSLVersion(j);
final String data = OpenSslInfoNative.OpenSSLVersion(j);
if (!"not available".equals(data)) {
info("OpenSSLVersion(%d): %s", j, data);
}
Expand All @@ -212,7 +212,7 @@ public static void main(final String[] args) throws Exception {
try (CryptoRandom cryptoRandom = CryptoRandomFactory.getCryptoRandom(props)) {
info("Random instance created OK: %s", cryptoRandom);
}
} catch (Exception e) {
} catch (final Exception e) {
info("Failed: %s", e);
}
try { // CryptoCipher
Expand All @@ -221,11 +221,11 @@ public static void main(final String[] args) throws Exception {
try (CryptoCipher cryptoCipher = CryptoCipherFactory.getCryptoCipher(AES.CTR_NO_PADDING, props)) {
info("Cipher %s instance created OK: %s", AES.CTR_NO_PADDING, cryptoCipher);
}
} catch (Exception e) {
} catch (final Exception e) {
info("Failed: %s", e);
}
} else {
Throwable error = getLoadingError();
final Throwable error = getLoadingError();
String msg = "";
if (error != null) {
msg = error.getMessage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public static void main(final String[] args) throws Throwable {
}
info("OpenSSL library loaded OK, version: 0x%s", Long.toHexString(OpenSslNativeJna.OpenSSL_version_num()));
for (int i = 0; i <= Utils.OPENSSL_VERSION_MAX_INDEX; i++) {
String data = OpenSslNativeJna.OpenSSLVersion(i);
final String data = OpenSslNativeJna.OpenSSLVersion(i);
if (!"not available".equals(data)) {
info("OpenSSLVersion(%d): %s", i, data);
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/apache/commons/crypto/jna/OpenSslMacOS.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ class OpenSslMacOS {
* @param path
* @return null if OK, else error message
*/
public static String checkLibrary(String path) {
boolean loadedOK = dlopen_preflight(path) != 0;
String dlerror = dlerror(); // fetch error, and clear for next call
public static String checkLibrary(final String path) {
final boolean loadedOK = dlopen_preflight(path) != 0;
final String dlerror = dlerror(); // fetch error, and clear for next call
return loadedOK ? null : dlerror;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ final class OpenSslNativeJna {
&& System.getProperty(Crypto.JNA_LIBRARY_NAME_PROPERTY, "").isEmpty()
&& System.getProperty(Crypto.JNA_LIBRARY_PATH_PROPERTY, "").isEmpty()
) {
String ret = OpenSslMacOS.checkLibrary(Crypto.MACOS_LIBRARY_NAME_DEFAULT);
final String ret = OpenSslMacOS.checkLibrary(Crypto.MACOS_LIBRARY_NAME_DEFAULT);
if (ret != null) {
throw new UnsatisfiedLinkError(
String.format("Cannot load default library '%s'; please define %s! (%s)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ private void cleanCipherStatePool() {
while ((cs = cipherStatePool.poll()) != null) {
try {
cs.getCryptoCipher().close();
} catch (IOException ignored) {
} catch (final IOException ignored) {
// ignore
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/apache/commons/crypto/utils/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public static Properties getProperties(final Properties newProp) {
* However on Windows, all the DLL versions seem to be stored in the same directory.
* This means that Windows code needs to be given the versioned name (e.g. libcrypto-1_1-x64)
* This is done by defining Crypto.JNI_LIBRARY_NAME.
*
*
* Do not change the method name or its signature!
*/
static String libraryPath(final String name) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public abstract class AbstractCipherTest {
private Properties props;

protected String cipherClass;
protected String[] transformations = new String[] {
protected String[] transformations = {
AES.CBC_NO_PADDING,
AES.CBC_PKCS5_PADDING,
AES.CTR_NO_PADDING,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public void testEmpty() throws Exception {
@Test
public void testExceptionInInitializerErrorRandom() throws GeneralSecurityException, IOException {
final Properties properties = new Properties();
String classes = ExceptionInInitializerErrorRandom.class.getName().concat(",")
final String classes = ExceptionInInitializerErrorRandom.class.getName().concat(",")
.concat(CryptoRandomFactory.RandomProvider.JAVA.getClassName());
properties.setProperty(CryptoRandomFactory.CLASSES_KEY, classes);
// Invoke 3 times to test the reentrancy of the method in the scenario of class initialization failure.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void close() throws IOException {
}

@Override
public void nextBytes(byte[] bytes) {
public void nextBytes(final byte[] bytes) {
// empty
}
}

0 comments on commit bbbd007

Please sign in to comment.