Skip to content

Commit eaeb54d

Browse files
committed
Version 3.24.9
Resolved issues: 1. Fixed the issue that can't auto add ContentType webp 2. Optimized logic of building xml when using CompleteMultiPart 3. Optimized logic of parsing xml 4. Added auto retry logic when request failed with wrong date 5. Added Element ExpiredObjectDeleteMarker in LifeCycleConfiguration
1 parent 9ff77dd commit eaeb54d

27 files changed

+378
-92
lines changed

README-Android.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
Version 3.24.9
2+
Resolved issues:
3+
1. Fixed the issue that can't auto add ContentType webp
4+
2. Optimized logic of building xml when using CompleteMultiPart
5+
3. Optimized logic of parsing xml
6+
4. Added auto retry logic when request failed with wrong date
7+
5. Added Element ExpiredObjectDeleteMarker in LifeCycleConfiguration
8+
-----------------------------------------------------------------------------------
19
Version 3.24.8
210
Resolved issues:
311
1. PutObject、Getobject、GetObjectMetadata、UploadPart、AppendObject、CopyObject、CopyPart、CompeleMultiUploadPart now supports crc64 checksum.

README-Java.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
Version 3.24.9
2+
Resolved issues:
3+
1. Fixed the issue that can't auto add ContentType webp
4+
2. Optimized logic of building xml when using CompleteMultiPart
5+
3. Optimized logic of parsing xml
6+
4. Added auto retry logic when request failed with wrong date
7+
5. Added Element ExpiredObjectDeleteMarker in LifeCycleConfiguration
8+
-----------------------------------------------------------------------------------
19
Version 3.24.8
210
Resolved issues:
311
1. PutObject、Getobject、GetObjectMetadata、UploadPart、AppendObject、CopyObject、CopyPart、CompeleMultiUploadPart now supports crc64 checksum.

README.MD

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
Version 3.24.9
2+
Resolved issues:
3+
1. Fixed the issue that can't auto add ContentType webp
4+
2. Optimized logic of building xml when using CompleteMultiPart
5+
3. Optimized logic of parsing xml
6+
4. Added auto retry logic when request failed with wrong date
7+
5. Added Element ExpiredObjectDeleteMarker in LifeCycleConfiguration
8+
-----------------------------------------------------------------------------------
19
Version 3.24.8
210
Resolved issues:
311
1. PutObject、Getobject、GetObjectMetadata、UploadPart、AppendObject、CopyObject、CopyPart、CompeleMultiUploadPart now supports crc64 checksum.

README_CN.MD

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
Version 3.24.9
2+
Resolved issues:
3+
1. 修复无法自动添加webp格式的ContentType的问题
4+
2. 优化合并段的xml构建逻辑
5+
3. 优化xml解析逻辑
6+
4. 增加时间不正确导致请求失败时的自动重试
7+
5. 生命周期规则新增ExpiredObjectDeleteMarker属性
8+
-----------------------------------------------------------------------------------
19
Version 3.24.8
210
Resolved issues:
311
1. PutObject、Getobject、GetObjectMetadata、UploadPart、AppendObject、CopyObject、CopyPart、CompeleMultiUploadPart支持crc64校验

app/src/main/java/com/obs/services/AbstractClient.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ protected void init(String accessKey, String secretKey, String securityToken, Ob
6565
this.credentials = credentials;
6666
this.keyManagerFactory = config.getKeyManagerFactory();
6767
this.trustManagerFactory = config.getTrustManagerFactory();
68+
this.localTimeUtil = config.getLocalTimeUtil();
6869
if (this.isAuthTypeNegotiation()) {
6970
this.getProviderCredentials().setIsAuthTypeNegotiation(true);
7071
}
@@ -183,6 +184,8 @@ public V4TemporarySignatureResponse createV4TemporarySignature(V4TemporarySignat
183184
ILOG.error(reqBean);
184185
}
185186
throw new ObsException(e.getMessage(), e);
187+
} finally {
188+
AccessLoggerUtils.printLog();
186189
}
187190
}
188191

@@ -229,6 +232,8 @@ public TemporarySignatureResponse createTemporarySignature(TemporarySignatureReq
229232
ILOG.error(reqBean);
230233
}
231234
throw new ObsException(e.getMessage(), e);
235+
} finally {
236+
AccessLoggerUtils.printLog();
232237
}
233238
}
234239

@@ -262,6 +267,8 @@ public TemporarySignatureResponse createGetTemporarySignature(String bucketName,
262267
return this.createTemporarySignatureResponse(request);
263268
} catch (Exception e) {
264269
throw new ObsException(e.getMessage(), e);
270+
} finally {
271+
AccessLoggerUtils.printLog();
265272
}
266273
}
267274

@@ -295,6 +302,8 @@ public TemporarySignatureResponse createGetTemporarySignature(String bucketName,
295302
return this.createTemporarySignatureResponse(request);
296303
} catch (Exception e) {
297304
throw new ObsException(e.getMessage(), e);
305+
} finally {
306+
AccessLoggerUtils.printLog();
298307
}
299308
}
300309

app/src/main/java/com/obs/services/BasicObsCredentialsProvider.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
package com.obs.services;
1616

17+
import com.obs.services.exception.ObsException;
1718
import com.obs.services.internal.security.BasicSecurityKey;
1819
import com.obs.services.model.ISecurityKey;
1920

@@ -37,11 +38,11 @@ public BasicObsCredentialsProvider(String accessKey, String secretKey, String se
3738

3839
private static void checkSecurityKey(String accessKey, String secretKey) {
3940
if (accessKey == null) {
40-
throw new IllegalArgumentException("accessKey should not be null.");
41+
throw new ObsException("accessKey should not be null.");
4142
}
4243

4344
if (secretKey == null) {
44-
throw new IllegalArgumentException("secretKey should not be null.");
45+
throw new ObsException("secretKey should not be null.");
4546
}
4647
}
4748

app/src/main/java/com/obs/services/ObsConfiguration.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import javax.net.ssl.TrustManagerFactory;
2020

2121
import com.obs.services.internal.ObsConstraint;
22+
import com.obs.services.internal.utils.LocalTimeUtil;
2223
import com.obs.services.model.AuthTypeEnum;
2324
import com.obs.services.model.HttpProtocolTypeEnum;
2425

@@ -106,6 +107,7 @@ public class ObsConfiguration implements Cloneable {
106107

107108
private String xmlDocumentBuilderFactoryClass;
108109
private EventListener.Factory eventListenerFactory;
110+
private LocalTimeUtil localTimeUtil;
109111

110112
/**
111113
* Constructor
@@ -141,6 +143,7 @@ public ObsConfiguration() {
141143
this.xmlDocumentBuilderFactoryClass = ObsConstraint.OBS_XML_DOC_BUILDER_FACTORY_CLASS;
142144
this.localAuthTypeCacheCapacity = ObsConstraint.DEFAULT_LOCAL_AUTH_TYPE_CACHE_CAPACITY;
143145
this.secureRandom = new SecureRandom();
146+
this.localTimeUtil = new LocalTimeUtil();
144147
}
145148

146149
public String getDelimiter() {
@@ -942,14 +945,21 @@ public void setSecureRandom(SecureRandom secureRandom) {
942945
this.secureRandom = secureRandom;
943946
}
944947

945-
public EventListener.Factory getEventListenerFactory()
946-
{
948+
public EventListener.Factory getEventListenerFactory() {
947949
return eventListenerFactory;
948950
}
949951

950-
public void setEventListenerFactory(EventListener.Factory eventListenerFactory)
951-
{
952+
public void setEventListenerFactory(EventListener.Factory eventListenerFactory) {
952953
this.eventListenerFactory = eventListenerFactory;
953954
}
954955

956+
public LocalTimeUtil getLocalTimeUtil() {
957+
return localTimeUtil;
958+
}
959+
960+
public void setLocalTimeUtil(LocalTimeUtil localTimeUtil) {
961+
this.localTimeUtil = localTimeUtil;
962+
}
963+
964+
955965
}

app/src/main/java/com/obs/services/exception/ObsException.java

Lines changed: 40 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
package com.obs.services.exception;
1616

17-
import java.util.Locale;
1817
import java.util.Map;
1918
import java.util.regex.Matcher;
2019
import java.util.regex.Pattern;
@@ -44,6 +43,10 @@ public class ObsException extends RuntimeException {
4443

4544
private String errorIndicator = null;
4645

46+
private String obsExceptionString = null;
47+
48+
private boolean calledToSting = false;
49+
4750
public ObsException(String message) {
4851
this(message, null, null);
4952
}
@@ -65,32 +68,46 @@ public ObsException(String message, String xmlMessage, Throwable cause) {
6568

6669
@Override
6770
public String toString() {
68-
StringBuilder myString = new StringBuilder(super.toString());
69-
70-
if (responseCode != -1) {
71-
myString.append(" -- ResponseCode: ")
72-
.append(responseCode)
73-
.append(", ResponseStatus: ")
74-
.append(responseStatus);
71+
if (obsExceptionString != null) {
72+
return obsExceptionString;
7573
}
76-
if (isParsedFromXmlMessage()) {
77-
myString.append(", XML Error Message: ").append(xmlMessage);
78-
} else if (errorRequestId != null) {
79-
myString.append(", RequestId: ").append(errorRequestId).append(", HostId: ").append(errorHostId);
80-
}
81-
// 遍历Map的entry,打印所有报错相关头域
82-
Map<String, String> headers = getResponseHeaders();
83-
if (headers != null) {
84-
for (Map.Entry<String, String> header : headers.entrySet()) {
85-
if (header.getKey().toLowerCase(Locale.ROOT).contains("error")) {
86-
myString.append(", ErrorHeaderKey: ")
87-
.append(header.getKey())
88-
.append(", ErrorHeaderValue: ")
89-
.append(header.getValue());
74+
try {
75+
calledToSting = true;
76+
StringBuilder myString = new StringBuilder(super.toString());
77+
78+
if (responseCode != -1) {
79+
myString.append(" -- ResponseCode: ")
80+
.append(responseCode)
81+
.append(", ResponseStatus: ")
82+
.append(responseStatus);
83+
}
84+
if (isParsedFromXmlMessage()) {
85+
myString.append(", XML Error Message: ").append(xmlMessage);
86+
} else if (errorRequestId != null) {
87+
myString.append(", RequestId: ").append(errorRequestId).append(", HostId: ").append(errorHostId);
88+
}
89+
// 遍历Map的entry,打印所有报错相关头域
90+
Map<String, String> headers = getResponseHeaders();
91+
if (headers != null) {
92+
myString.append("headers{");
93+
for (Map.Entry<String, String> header : headers.entrySet()) {
94+
myString.append(header.getKey())
95+
.append(":")
96+
.append(header.getValue())
97+
.append(",");
9098
}
99+
myString.append("}");
91100
}
101+
obsExceptionString = myString.toString();
102+
return obsExceptionString;
103+
} finally {
104+
calledToSting = false;
92105
}
93-
return myString.toString();
106+
}
107+
108+
@Override
109+
public String getMessage() {
110+
return calledToSting ? super.getMessage() : this.toString();
94111
}
95112

96113
private boolean isParsedFromXmlMessage() {

app/src/main/java/com/obs/services/internal/Constants.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ public static class ObsRequestParams {
215215

216216
public static final TimeZone GMT_TIMEZONE = TimeZone.getTimeZone("GMT");
217217

218-
public static final String OBS_SDK_VERSION = "3.24.8";
218+
public static final String OBS_SDK_VERSION = "3.24.9";
219219

220220
public static final String USER_AGENT_VALUE = "obs-sdk-java/" + Constants.OBS_SDK_VERSION;
221221

@@ -269,6 +269,9 @@ public static class ObsRequestParams {
269269
public static final long MAX_PART_SIZE = 5 * 1024 * 1024 * 1024L;
270270

271271
public static final long MIN_PART_SIZE = 100 * 1024L;
272+
public static final String REQUEST_TIME_TOO_SKEWED_CODE = "RequestTimeTooSkewed";
273+
public static final String ERROR_CODE_HEADER_OBS = "x-obs-error-code";
274+
public static final String ERROR_CODE_HEADER_AMZ = "x-amz-error-code";
272275

273276
public static final List<String> ALLOWED_RESPONSE_HTTP_HEADER_METADATA_NAMES = Collections.unmodifiableList(
274277
Arrays.asList("content-type", "content-md5", "content-length", "content-language", "expires", "origin",

app/src/main/java/com/obs/services/internal/IConvertor.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414

1515
package com.obs.services.internal;
1616

17-
import java.util.List;
18-
1917
import com.obs.services.model.AccessControlList;
2018
import com.obs.services.model.BucketCors;
2119
import com.obs.services.model.BucketDirectColdAccess;
@@ -29,7 +27,6 @@
2927
import com.obs.services.model.GroupGranteeEnum;
3028
import com.obs.services.model.KeyAndVersion;
3129
import com.obs.services.model.LifecycleConfiguration;
32-
import com.obs.services.model.PartEtag;
3330
import com.obs.services.model.ReplicationConfiguration;
3431
import com.obs.services.model.RestoreObjectRequest;
3532
import com.obs.services.model.StorageClassEnum;
@@ -40,8 +37,6 @@
4037

4138
public interface IConvertor {
4239

43-
String transCompleteMultipartUpload(List<PartEtag> parts) throws ServiceException;
44-
4540
String transBucketLoction(String location) throws ServiceException;
4641

4742
String transVersioningConfiguration(String bucketName, String status) throws ServiceException;

0 commit comments

Comments
 (0)