Skip to content

Commit 75fc8c2

Browse files
JacksonTianyndu13
authored andcommitted
improve coding styles
1 parent 3360475 commit 75fc8c2

31 files changed

+54
-72
lines changed

aliyun-java-sdk-core/src/main/java/com/aliyuncs/AcsRequest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public abstract class AcsRequest<T extends AcsResponse> extends HttpRequest {
2424
private UserAgentConfig userAgentConfig;
2525
protected ISignatureComposer composer = null;
2626
private String version = null;
27-
private String product = null;
27+
private String product;
2828
private String actionName = null;
2929
private String regionId = null;
3030
private String securityToken = null;
@@ -76,7 +76,7 @@ public static String concatQueryString(Map<String, String> parameters) throws Un
7676
return null;
7777
}
7878

79-
StringBuilder urlBuilder = new StringBuilder("");
79+
StringBuilder urlBuilder = new StringBuilder();
8080
for (Entry<String, String> entry : parameters.entrySet()) {
8181
String key = entry.getKey();
8282
String val = entry.getValue();

aliyun-java-sdk-core/src/main/java/com/aliyuncs/RoaAcsRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ protected void putPathParameter(String name, String value) {
114114
@Override
115115
public String composeUrl(String endpoint, Map<String, String> queries) throws UnsupportedEncodingException {
116116
Map<String, String> mapQueries = (queries == null) ? this.getSysQueryParameters() : queries;
117-
StringBuilder urlBuilder = new StringBuilder("");
117+
StringBuilder urlBuilder = new StringBuilder();
118118
urlBuilder.append(this.getSysProtocol().toString());
119119
urlBuilder.append("://").append(endpoint);
120120
if (null != this.uriPattern) {

aliyun-java-sdk-core/src/main/java/com/aliyuncs/RpcAcsRequest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public void setSysSecurityToken(String securityToken) {
131131
@Override
132132
public String composeUrl(String endpoint, Map<String, String> queries) throws UnsupportedEncodingException {
133133
Map<String, String> mapQueries = (queries == null) ? this.getSysQueryParameters() : queries;
134-
StringBuilder urlBuilder = new StringBuilder("");
134+
StringBuilder urlBuilder = new StringBuilder();
135135
urlBuilder.append(this.getSysProtocol().toString());
136136
urlBuilder.append("://").append(endpoint);
137137
if (-1 == urlBuilder.indexOf("?")) {
@@ -166,7 +166,7 @@ public HttpRequest signRequest(Signer signer, AlibabaCloudCredentials credential
166166
format);
167167
headerMap.putAll(this.getSysHeaders());
168168
headerMap = this.composer.refreshSignParameters(headerMap, signer, null, null);
169-
if (imutableMap.get("RegionId") == null && this.getSysRegionId() != null && !this.getSysRegionId().equals("")) {
169+
if (imutableMap.get("RegionId") == null && this.getSysRegionId() != null && !this.getSysRegionId().isEmpty()) {
170170
if ((bodyParams == null || bodyParams.get("RegionId") == null)) {
171171
imutableMap.put("RegionId", getSysRegionId());
172172
}

aliyun-java-sdk-core/src/main/java/com/aliyuncs/auth/DefaultCredentialsProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public DefaultCredentialsProvider() throws ClientException {
2727
defaultProviders.add(new ProfileCredentialsProvider());
2828
String roleName = AuthUtils.getEnvironmentECSMetaData();
2929
if (roleName != null) {
30-
if (roleName.length() == 0) {
30+
if (roleName.isEmpty()) {
3131
throw new ClientException("Environment variable roleName('ALIBABA_CLOUD_ECS_METADATA') cannot be empty");
3232
}
3333
defaultProviders.add(new InstanceProfileCredentialsProvider(roleName));

aliyun-java-sdk-core/src/main/java/com/aliyuncs/auth/LegacyCredentials.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ public class LegacyCredentials implements AlibabaCloudCredentials {
55

66
private final Credential legacyCredential;
77

8-
public LegacyCredentials(Credential legacyCrendential) {
9-
this.legacyCredential = legacyCrendential;
8+
public LegacyCredentials(Credential legacyCredential) {
9+
this.legacyCredential = legacyCredential;
1010
}
1111

1212
@Override

aliyun-java-sdk-core/src/main/java/com/aliyuncs/auth/ProfileCredentialsProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public AlibabaCloudCredentials getCredentials() throws ClientException {
3131
if (filePath == null) {
3232
filePath = AuthConstant.DEFAULT_CREDENTIALS_FILE_PATH;
3333
}
34-
if (filePath.length() == 0) {
34+
if (filePath.isEmpty()) {
3535
throw new ClientException("The specified credentials file is empty");
3636
}
3737
Wini ini;

aliyun-java-sdk-core/src/main/java/com/aliyuncs/auth/SHA256withRSASigner.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ public String signString(String stringToSign, String accessKeySecret) {
4141
rsaSign.initSign(privateKey);
4242
rsaSign.update(stringToSign.getBytes(ENCODING));
4343
byte[] sign = rsaSign.sign();
44-
String signature = DatatypeConverter.printBase64Binary(sign);
45-
return signature;
44+
return DatatypeConverter.printBase64Binary(sign);
4645
} catch (NoSuchAlgorithmException e) {
4746
throw new IllegalArgumentException(e.toString());
4847
} catch (InvalidKeySpecException e) {

aliyun-java-sdk-core/src/main/java/com/aliyuncs/auth/STSGetSessionAccessKeyCredentialsProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ private BasicSessionCredentials getNewSessionCredentials() throws ClientExceptio
6565

6666
return new BasicSessionCredentials(
6767
response.getSessionAccessKey().getSessionAccessKeyId(),
68-
response.getSessionAccessKey().getSessionAccessKeySecert(),
68+
response.getSessionAccessKey().getSessionAccessKeySecret(),
6969
null,
7070
sessionDurationSeconds
7171
);

aliyun-java-sdk-core/src/main/java/com/aliyuncs/auth/V3SignatureComposer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ private Map<String, String> getCanonicalizedHeadersMap(Map<String, String> heade
8484
}
8585

8686
private String getCanonicalizedResource(Map<String, String> query) {
87-
if (query == null || query.size() == 0) {
87+
if (query == null || query.isEmpty()) {
8888
return "";
8989
}
9090
String[] keys = query.keySet().toArray(new String[query.size()]);

aliyun-java-sdk-core/src/main/java/com/aliyuncs/auth/sts/AssumeRoleRequest.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,9 @@
1919

2020
package com.aliyuncs.auth.sts;
2121

22-
/**
23-
* Created by haowei.yao on 2017/9/14.
24-
*/
25-
2622
import com.aliyuncs.RpcAcsRequest;
2723
import com.aliyuncs.http.ProtocolType;
2824

29-
/**
30-
* @author auto create
31-
*/
3225
public class AssumeRoleRequest extends RpcAcsRequest<AssumeRoleResponse> {
3326

3427
private Long durationSeconds;

0 commit comments

Comments
 (0)