Java 17 features (A-G) (#15516)

- add missing @override
- Java style array syntax
- remove redundant modifiers
- always move String constants to left side in comparisons
- simplify lambda expressions and return statements
- use replace instead of replaceAll w/o regex
- instanceof matching and multiline strings

Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
This commit is contained in:
Holger Friedrich
2023-09-05 22:30:16 +02:00
committed by GitHub
parent a0dc5c05f2
commit cf10b3e9c7
486 changed files with 2053 additions and 1955 deletions

View File

@@ -124,7 +124,7 @@ public class S3Actions {
nameNodesList = doc.getElementsByTagName("IsTruncated");
if (nameNodesList.getLength() > 0) {
if (nameNodesList.item(0).getFirstChild().getTextContent().equals("true")) {
if ("true".equals(nameNodesList.item(0).getFirstChild().getTextContent())) {
nameNodesList = doc.getElementsByTagName("NextContinuationToken");
if (nameNodesList.getLength() > 0) {
String continueToken = nameNodesList.item(0).getFirstChild().getTextContent();

View File

@@ -101,9 +101,8 @@ public abstract class AWS4SignerBase {
protected static String getCanonicalRequest(URL endpoint, String httpMethod, String queryParameters,
String canonicalizedHeaderNames, String canonicalizedHeaders, String bodyHash) {
String canonicalRequest = httpMethod + "\n" + getCanonicalizedResourcePath(endpoint) + "\n" + queryParameters
+ "\n" + canonicalizedHeaders + "\n" + canonicalizedHeaderNames + "\n" + bodyHash;
return canonicalRequest;
return httpMethod + "\n" + getCanonicalizedResourcePath(endpoint) + "\n" + queryParameters + "\n"
+ canonicalizedHeaders + "\n" + canonicalizedHeaderNames + "\n" + bodyHash;
}
protected static String getCanonicalizedResourcePath(URL endpoint) {
@@ -154,9 +153,8 @@ public abstract class AWS4SignerBase {
protected static String getStringToSign(String scheme, String algorithm, String dateTime, String scope,
String canonicalRequest) {
String stringToSign = scheme + "-" + algorithm + "\n" + dateTime + "\n" + scope + "\n"
return scheme + "-" + algorithm + "\n" + dateTime + "\n" + scope + "\n"
+ BinaryUtils.toHex(hash(canonicalRequest));
return stringToSign;
}
public static byte[] hash(String text) {

View File

@@ -63,8 +63,7 @@ public class AWS4SignerForAuthorizationHeader extends AWS4SignerBase {
String credentialsAuthorizationHeader = "Credential=" + awsAccessKey + "/" + scope;
String signedHeadersAuthorizationHeader = "SignedHeaders=" + canonicalizedHeaderNames;
String signatureAuthorizationHeader = "Signature=" + BinaryUtils.toHex(signature);
String authorizationHeader = SCHEME + "-" + ALGORITHM + " " + credentialsAuthorizationHeader + ", "
+ signedHeadersAuthorizationHeader + ", " + signatureAuthorizationHeader;
return authorizationHeader;
return SCHEME + "-" + ALGORITHM + " " + credentialsAuthorizationHeader + ", " + signedHeadersAuthorizationHeader
+ ", " + signatureAuthorizationHeader;
}
}

View File

@@ -129,7 +129,7 @@ public class FtpFolderWatcherHandler extends BaseThingHandler {
Instant dateNow = Instant.now();
for (FTPFile file : ftpClient.listFiles(dirPath)) {
String currentFileName = file.getName();
if (currentFileName.equals(".") || currentFileName.equals("..")) {
if (".".equals(currentFileName) || "..".equals(currentFileName)) {
continue;
}
String filePath = dirPath + "/" + currentFileName;