Skip to content

Commit 6b5a916

Browse files
committed
Update to 3.21.12
Replace log4j2 to 2.17.0
1 parent 0f0c60d commit 6b5a916

39 files changed

+709
-739
lines changed

README-Android.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
1+
Version 3.21.12
2+
Third-party dependence:
3+
1. Replace log4j2 2.16.0 with log4j2 2.17.0
4+
-----------------------------------------------------------------------------------
5+
16
Version 3.21.11
27
New features:
38
1. Allowed you to add any custom header field in a request.
49
Third-party dependence:
5-
1. Replace jackson-core 2.12.5 with jackson-core 2.11.1
6-
2. Replace jackson-databind 2.12.5 with jackson-databind 2.11.1
7-
3. Replace jackson-annotations 2.12.5 with jackson-annotations 2.11.1
8-
4. Replace okhttp 4.9.1 with okhttp 4.8.0
10+
1. Replace jackson-core 2.11.1 with jackson-core 2.12.5
11+
2. Replace jackson-databind 2.11.1 with jackson-databind 2.12.5
12+
3. Replace jackson-annotations 2.11.1 with jackson-annotations 2.12.5
13+
4. Replace okhttp 4.8.0 with okhttp 4.9.1
914
5. Replace log4j2 2.14.1 with log4j2 2.16.0
1015
-----------------------------------------------------------------------------------
16+
1117
Version 3.21.8
1218

1319
1. Replace okhttp 3.14.9 with okhttp 4.8.0.

README-Java.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
1+
Version 3.21.12
2+
Third-party dependence:
3+
1. Replace log4j2 2.16.0 with log4j2 2.17.0
4+
-----------------------------------------------------------------------------------
5+
16
Version 3.21.11
27
New features:
38
1. Allowed you to add any custom header field in a request.
49
Third-party dependence:
5-
1. Replace jackson-core 2.12.5 with jackson-core 2.11.1
6-
2. Replace jackson-databind 2.12.5 with jackson-databind 2.11.1
7-
3. Replace jackson-annotations 2.12.5 with jackson-annotations 2.11.1
8-
4. Replace okhttp 4.9.1 with okhttp 4.8.0
9-
5. Replace log4j2 2.16.0 with log4j2 2.14.1
10+
1. Replace jackson-core 2.11.1 with jackson-core 2.12.5
11+
2. Replace jackson-databind 2.11.1 with jackson-databind 2.12.5
12+
3. Replace jackson-annotations 2.11.1 with jackson-annotations 2.12.5
13+
4. Replace okhttp 4.8.0 with okhttp 4.9.1
14+
5. Replace log4j2 2.14.1 with log4j2 2.16.0
1015
-----------------------------------------------------------------------------------
1116
Version 3.21.8
1217

README.MD

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
1+
Version 3.21.12
2+
Third-party dependence:
3+
1. Replace log4j2 2.16.0 with log4j2 2.17.0
4+
-----------------------------------------------------------------------------------
5+
16
Version 3.21.11
27
New features:
38
1. Allowed you to add any custom header field in a request.
49
Third-party dependence:
5-
1. Replace jackson-core 2.12.5 with jackson-core 2.11.1
6-
2. Replace jackson-databind 2.12.5 with jackson-databind 2.11.1
7-
3. Replace jackson-annotations 2.12.5 with jackson-annotations 2.11.1
8-
4. Replace okhttp 4.9.1 with okhttp 4.8.0
9-
5. Replace log4j2 2.16.0 with log4j2 2.14.1
10+
1. Replace jackson-core 2.11.1 with jackson-core 2.12.5
11+
2. Replace jackson-databind 2.11.1 with jackson-databind 2.12.5
12+
3. Replace jackson-annotations 2.11.1 with jackson-annotations 2.12.5
13+
4. Replace okhttp 4.8.0 with okhttp 4.9.1
14+
5. Replace log4j2 2.14.1 with log4j2 2.16.0
1015
-----------------------------------------------------------------------------------
1116
Version 3.21.8
1217

README_CN.MD

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
Version 3.21.12
2+
三方依赖:
3+
1. 使用 log4j2 2.17.0 替代 log4j2 2.16.0
4+
-----------------------------------------------------------------------------------
5+
16
Version 3.21.11
27
新特性:
38
1. 用户可以在发送请求时添加任意自定义头域

app/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>com.huaweicloud</groupId>
66
<artifactId>esdk-obs-java-android</artifactId>
7-
<version>3.21.11</version>
7+
<version>3.21.12</version>
88

99
<name>OBS SDK for Java/Android</name>
1010
<description>The OBS SDK for Android used for accessing Object Storage Service</description>
@@ -58,12 +58,12 @@
5858
<dependency>
5959
<groupId>org.apache.logging.log4j</groupId>
6060
<artifactId>log4j-core</artifactId>
61-
<version>2.16.0</version>
61+
<version>2.17.0</version>
6262
</dependency>
6363
<dependency>
6464
<groupId>org.apache.logging.log4j</groupId>
6565
<artifactId>log4j-api</artifactId>
66-
<version>2.16.0</version>
66+
<version>2.17.0</version>
6767
</dependency>
6868
</dependencies>
6969

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

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,10 @@ public ObsBucket action() throws ServiceException {
115115
} catch (ServiceException e) {
116116
if (AbstractBucketClient.this.isAuthTypeNegotiation() && e.getResponseCode() == 400
117117
&& "Unsupported Authorization Type".equals(e.getErrorMessage())
118-
&& AbstractBucketClient.this.getProviderCredentials().getAuthType()
119-
== AuthTypeEnum.OBS) {
120-
AbstractBucketClient.this.getProviderCredentials().setThreadLocalAuthType(
121-
AuthTypeEnum.V2);
118+
&& AbstractBucketClient.this.getProviderCredentials()
119+
.getLocalAuthType(request.getBucketName()) == AuthTypeEnum.OBS) {
120+
AbstractBucketClient.this.getProviderCredentials()
121+
.setLocalAuthType(request.getBucketName(), AuthTypeEnum.V2);
122122
return AbstractBucketClient.this.createBucketImpl(request);
123123
} else {
124124
throw e;
@@ -128,12 +128,13 @@ public ObsBucket action() throws ServiceException {
128128

129129
@Override
130130
void authTypeNegotiate(String bucketName) throws ServiceException {
131-
AuthTypeEnum authTypeEnum = AbstractBucketClient.this.getApiVersionCache()
132-
.getApiVersionInCache(bucketName);
131+
AuthTypeEnum authTypeEnum = AbstractBucketClient.this.getProviderCredentials()
132+
.getLocalAuthType().get(bucketName);
133133
if (authTypeEnum == null) {
134134
authTypeEnum = AbstractBucketClient.this.getApiVersion("");
135+
AbstractBucketClient.this.getProviderCredentials()
136+
.setLocalAuthType(bucketName, authTypeEnum);
135137
}
136-
AbstractBucketClient.this.getProviderCredentials().setThreadLocalAuthType(authTypeEnum);
137138
}
138139
});
139140
}
@@ -168,8 +169,12 @@ public ListBucketsResult action() throws ServiceException {
168169

169170
@Override
170171
void authTypeNegotiate(String bucketName) throws ServiceException {
171-
AuthTypeEnum authTypeEnum = AbstractBucketClient.this.getApiVersion("");
172-
AbstractBucketClient.this.getProviderCredentials().setThreadLocalAuthType(authTypeEnum);
172+
AuthTypeEnum authTypeEnum = AbstractBucketClient.this.getProviderCredentials()
173+
.getLocalAuthType().get(bucketName);
174+
if (authTypeEnum == null) {
175+
authTypeEnum = AbstractBucketClient.this.getApiVersion("");
176+
AbstractBucketClient.this.getProviderCredentials().setLocalAuthType(bucketName, authTypeEnum);
177+
}
173178
}
174179
});
175180
}
@@ -203,8 +208,12 @@ public Boolean action() throws ServiceException {
203208
@Override
204209
void authTypeNegotiate(String bucketName) throws ServiceException {
205210
try {
206-
AuthTypeEnum authTypeEnum = AbstractBucketClient.this.getApiVersion(bucketName);
207-
AbstractBucketClient.this.getProviderCredentials().setThreadLocalAuthType(authTypeEnum);
211+
AuthTypeEnum authTypeEnum = AbstractBucketClient.this.getProviderCredentials()
212+
.getLocalAuthType().get(bucketName);
213+
if (authTypeEnum == null) {
214+
authTypeEnum = AbstractBucketClient.this.getApiVersion(bucketName);
215+
AbstractBucketClient.this.getProviderCredentials().setLocalAuthType(bucketName, authTypeEnum);
216+
}
208217
} catch (ServiceException e) {
209218
if (e.getResponseCode() != 404) {
210219
throw e;

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

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@
3333
import com.obs.services.internal.ObsProperties;
3434
import com.obs.services.internal.ObsService;
3535
import com.obs.services.internal.ServiceException;
36-
import com.obs.services.internal.consensus.CacheManager;
37-
import com.obs.services.internal.consensus.SegmentLock;
3836
import com.obs.services.internal.security.ProviderCredentials;
3937
import com.obs.services.internal.utils.AccessLoggerUtils;
4038
import com.obs.services.internal.utils.ServiceUtils;
@@ -66,15 +64,13 @@ protected void init(String accessKey, String secretKey, String securityToken, Ob
6664
ProviderCredentials credentials = new ProviderCredentials(accessKey, secretKey, securityToken);
6765
ObsProperties obsProperties = ServiceUtils.changeFromObsConfiguration(config);
6866
credentials.setAuthType(config.getAuthType());
67+
credentials.setLocalAuthTypeCacheCapacity(config.getLocalAuthTypeCacheCapacity());
6968
this.obsProperties = obsProperties;
7069
this.credentials = credentials;
7170
this.keyManagerFactory = config.getKeyManagerFactory();
7271
this.trustManagerFactory = config.getTrustManagerFactory();
7372
if (this.isAuthTypeNegotiation()) {
74-
this.apiVersionCache = new CacheManager();
7573
this.getProviderCredentials().setIsAuthTypeNegotiation(true);
76-
this.getProviderCredentials().initThreadLocalAuthType();
77-
this.segmentLock = new SegmentLock();
7874
}
7975
this.initHttpClient(config.getHttpDispatcher());
8076
OBSXMLBuilder.setXmlDocumentBuilderFactoryClass(config.getXmlDocumentBuilderFactoryClass());
@@ -228,7 +224,7 @@ public TemporarySignatureResponse createTemporarySignature(TemporarySignatureReq
228224
ServiceUtils.asserParameterNotNull(request, "TemporarySignatureRequest is null");
229225
InterfaceLogBean reqBean = new InterfaceLogBean("createTemporarySignature", this.getEndpoint(), "");
230226
try {
231-
return this.getProviderCredentials().getAuthType() == AuthTypeEnum.V4
227+
return this.getProviderCredentials().getLocalAuthType(request.getBucketName()) == AuthTypeEnum.V4
232228
? this.createV4TemporarySignature(request) : this.createTemporarySignatureResponse(request);
233229
} catch (Exception e) {
234230
reqBean.setRespTime(new Date());
@@ -327,8 +323,8 @@ public PostSignatureResponse createPostSignature(String acl, String contentType,
327323
String objectKey) throws ObsException {
328324
PostSignatureRequest request = new PostSignatureRequest(expires, new Date(), bucketName, objectKey);
329325
request.getFormParams().put(
330-
this.getProviderCredentials().getAuthType() == AuthTypeEnum.V4 ? "acl" : this.getIHeaders().aclHeader(),
331-
acl);
326+
this.getProviderCredentials().getLocalAuthType(bucketName)
327+
== AuthTypeEnum.V4 ? "acl" : this.getIHeaders(bucketName).aclHeader(), acl);
332328
request.getFormParams().put(com.obs.services.internal.Constants.CommonHeaders.CONTENT_TYPE, contentType);
333329
return this.createPostSignature(request);
334330
}
@@ -364,16 +360,21 @@ public PostSignatureResponse createPostSignature(long expires, String bucketName
364360
public PostSignatureResponse createPostSignature(PostSignatureRequest request) throws ObsException {
365361
ServiceUtils.asserParameterNotNull(request, "PostSignatureRequest is null");
366362
InterfaceLogBean reqBean = new InterfaceLogBean("createPostSignature", this.getEndpoint(), "");
367-
return createPostSignature(request, reqBean, this.getProviderCredentials().getAuthType() == AuthTypeEnum.V4);
363+
return createPostSignature(request, reqBean, this.getProviderCredentials()
364+
.getLocalAuthType(request.getBucketName()) == AuthTypeEnum.V4);
368365
}
369366

370367
protected abstract class ActionCallbackWithResult<T> {
371368

372369
public abstract T action() throws ServiceException;
373370

374371
void authTypeNegotiate(String bucketName) throws ServiceException {
375-
AuthTypeEnum authTypeEnum = AbstractClient.this.getApiVersion(bucketName);
376-
AbstractClient.this.getProviderCredentials().setThreadLocalAuthType(authTypeEnum);
372+
AuthTypeEnum authTypeEnum = AbstractClient.this.getProviderCredentials()
373+
.getLocalAuthType().get(bucketName);
374+
if (authTypeEnum == null) {
375+
authTypeEnum = AbstractClient.this.getApiVersion(bucketName);
376+
AbstractClient.this.getProviderCredentials().setLocalAuthType(bucketName, authTypeEnum);
377+
}
377378
}
378379
}
379380

@@ -412,9 +413,6 @@ protected <T> T doActionWithResult(String action, String bucketName, ActionCallb
412413
}
413414
throw ex;
414415
} finally {
415-
if (this.isAuthTypeNegotiation()) {
416-
this.getProviderCredentials().removeThreadLocalAuthType();
417-
}
418416
AccessLoggerUtils.printLog();
419417
}
420418
}
@@ -430,6 +428,7 @@ public void refresh(String accessKey, String secretKey, String securityToken) {
430428
ProviderCredentials credentials = new ProviderCredentials(accessKey, secretKey, securityToken);
431429
credentials.setIsAuthTypeNegotiation(this.credentials.getIsAuthTypeNegotiation());
432430
credentials.setAuthType(this.credentials.getAuthType());
431+
credentials.setLocalAuthType(this.credentials.getLocalAuthType());
433432
this.setProviderCredentials(credentials);
434433
}
435434

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,10 @@ public Boolean action() throws ServiceException {
6969
} catch (ServiceException e) {
7070
if (AbstractObjectClient.this.isAuthTypeNegotiation() && e.getResponseCode() == 400
7171
&& "Unsupported Authorization Type".equals(e.getErrorMessage())
72-
&& AbstractObjectClient.this.getProviderCredentials().getAuthType() == AuthTypeEnum.OBS) {
73-
AbstractObjectClient.this.getProviderCredentials().setThreadLocalAuthType(AuthTypeEnum.V2);
72+
&& AbstractObjectClient.this.getProviderCredentials()
73+
.getLocalAuthType(request.getBucketName()) == AuthTypeEnum.OBS) {
74+
AbstractObjectClient.this.getProviderCredentials()
75+
.setLocalAuthType(request.getBucketName(), AuthTypeEnum.V2);
7476
return AbstractObjectClient.this.doesObjectExistImpl(request);
7577
} else {
7678
throw e;

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ public class ObsConfiguration implements Cloneable {
7070

7171
private AuthTypeEnum authType;
7272

73+
private int localAuthTypeCacheCapacity;
74+
7375
private String signatString;
7476
private String defaultBucketLocation;
7577
private int bufferSize;
@@ -125,6 +127,7 @@ public ObsConfiguration() {
125127
this.delimiter = "/";
126128
this.httpProtocolType = HttpProtocolTypeEnum.HTTP1_1;
127129
this.xmlDocumentBuilderFactoryClass = ObsConstraint.OBS_XML_DOC_BUILDER_FACTORY_CLASS;
130+
this.localAuthTypeCacheCapacity = ObsConstraint.DEFAULT_LOCAL_AUTH_TYPE_CACHE_CAPACITY;
128131
}
129132

130133
public String getDelimiter() {
@@ -877,4 +880,13 @@ public String getXmlDocumentBuilderFactoryClass() {
877880
public void setXmlDocumentBuilderFactoryClass(String xmlDocumentBuilderFactoryClass) {
878881
this.xmlDocumentBuilderFactoryClass = xmlDocumentBuilderFactoryClass;
879882
}
883+
884+
885+
public int getLocalAuthTypeCacheCapacity() {
886+
return localAuthTypeCacheCapacity;
887+
}
888+
889+
public void setLocalAuthTypeCacheCapacity(int localAuthTypeCacheCapacity) {
890+
this.localAuthTypeCacheCapacity = localAuthTypeCacheCapacity;
891+
}
880892
}

0 commit comments

Comments
 (0)