Skip to content

Commit

Permalink
Merge pull request #105 from aliyun/fix-req-id
Browse files Browse the repository at this point in the history
Fix request id
  • Loading branch information
baiyubin2020 authored Nov 27, 2017
2 parents 4bb72aa + 49f4515 commit 80f53f7
Show file tree
Hide file tree
Showing 54 changed files with 286 additions and 58 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
language: java
jdk:
- openjdk6
- openjdk7
- oraclejdk7
- oraclejdk8
- oraclejdk9
script:
- mvn install -DskipTests=true
env:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ The recommended way to use the Aliyun OSS SDK for Java in your project is to con
<dependency>
<groupId>com.aliyun.oss</groupId>
<artifactId>aliyun-sdk-oss</artifactId>
<version>2.8.1</version>
<version>2.8.2</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<groupId>com.aliyun.oss</groupId>
<artifactId>aliyun-sdk-oss</artifactId>
<version>2.8.1</version>
<version>2.8.2</version>
<packaging>jar</packaging>
<name>Aliyun OSS SDK for Java</name>
<description>The Aliyun OSS SDK for Java used for accessing Aliyun Object Storage Service</description>
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/com/aliyun/oss/internal/OSSBucketOperation.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
import com.aliyun.oss.OSSException;
import com.aliyun.oss.common.auth.CredentialsProvider;
import com.aliyun.oss.common.comm.RequestMessage;
import com.aliyun.oss.common.comm.ResponseMessage;
import com.aliyun.oss.common.comm.ServiceClient;
import com.aliyun.oss.common.utils.BinaryUtil;
import com.aliyun.oss.common.utils.HttpHeaders;
Expand Down Expand Up @@ -161,9 +162,9 @@ public Bucket createBucket(CreateBucketRequest createBucketRequest)
.setInputStreamWithLength(createBucketRequestMarshaller.marshall(createBucketRequest))
.setOriginalRequest(createBucketRequest)
.build();

doOperation(request, emptyResponseParser, bucketName, null);
return new Bucket(bucketName);
ResponseMessage result = doOperation(request, emptyResponseParser, bucketName, null);
return new Bucket(bucketName , result.getRequestId());
}

/**
Expand Down
84 changes: 63 additions & 21 deletions src/main/java/com/aliyun/oss/internal/ResponseParsers.java
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,9 @@ public static final class ListBucketResponseParser implements ResponseParser<Buc
public BucketList parse(ResponseMessage response)
throws ResponseParseException {
try {
return parseListBucket(response.getContent());
BucketList result = parseListBucket(response.getContent());
result.setRequestId(response.getRequestId());
return result;
} finally {
safeCloseResponse(response);
}
Expand All @@ -213,7 +215,9 @@ public static final class GetBucketRefererResponseParser implements ResponsePars
public BucketReferer parse(ResponseMessage response)
throws ResponseParseException {
try {
return parseGetBucketReferer(response.getContent());
BucketReferer result = parseGetBucketReferer(response.getContent());
result.setRequestId(response.getRequestId());
return result;
} finally {
safeCloseResponse(response);
}
Expand All @@ -227,7 +231,9 @@ public static final class GetBucketAclResponseParser implements ResponseParser<A
public AccessControlList parse(ResponseMessage response)
throws ResponseParseException {
try {
return parseGetBucketAcl(response.getContent());
AccessControlList result = parseGetBucketAcl(response.getContent());
result.setRequestId(response.getRequestId());
return result;
} finally {
safeCloseResponse(response);
}
Expand Down Expand Up @@ -255,7 +261,9 @@ public static final class GetBucketLoggingResponseParser implements ResponsePars
public BucketLoggingResult parse(ResponseMessage response)
throws ResponseParseException {
try {
return parseBucketLogging(response.getContent());
BucketLoggingResult result = parseBucketLogging(response.getContent());
result.setRequestId(response.getRequestId());
return result;
} finally {
safeCloseResponse(response);
}
Expand Down Expand Up @@ -293,7 +301,9 @@ public static final class GetBucketImageProcessConfResponseParser implements Res
public BucketProcess parse(ResponseMessage response)
throws ResponseParseException {
try {
return parseGetBucketImageProcessConf(response.getContent());
BucketProcess result = parseGetBucketImageProcessConf(response.getContent());
result.setRequestId(response.getRequestId());
return result;
} finally {
safeCloseResponse(response);
}
Expand All @@ -307,7 +317,9 @@ public static final class GetBucketWebsiteResponseParser implements ResponsePars
public BucketWebsiteResult parse(ResponseMessage response)
throws ResponseParseException {
try {
return parseBucketWebsite(response.getContent());
BucketWebsiteResult result = parseBucketWebsite(response.getContent());
result.setRequestId(response.getRequestId());
return result;
} finally {
safeCloseResponse(response);
}
Expand Down Expand Up @@ -349,7 +361,9 @@ public static final class GetBucketInfoResponseParser implements ResponseParser<
public BucketInfo parse(ResponseMessage response)
throws ResponseParseException {
try {
return parseGetBucketInfo(response.getContent());
BucketInfo result = parseGetBucketInfo(response.getContent());
result.setRequestId(response.getRequestId());
return result;
} finally {
safeCloseResponse(response);
}
Expand All @@ -363,7 +377,9 @@ public static final class GetBucketStatResponseParser implements ResponseParser<
public BucketStat parse(ResponseMessage response)
throws ResponseParseException {
try {
return parseGetBucketStat(response.getContent());
BucketStat result = parseGetBucketStat(response.getContent());
result.setRequestId(response.getRequestId());
return result;
} finally {
safeCloseResponse(response);
}
Expand All @@ -377,7 +393,9 @@ public static final class GetBucketQosResponseParser implements ResponseParser<U
public UserQos parse(ResponseMessage response)
throws ResponseParseException {
try {
return parseGetUserQos(response.getContent());
UserQos result = parseGetUserQos(response.getContent());
result.setRequestId(response.getRequestId());
return result;
} finally {
safeCloseResponse(response);
}
Expand All @@ -391,7 +409,9 @@ public static final class CreateLiveChannelResponseParser implements ResponsePar
public CreateLiveChannelResult parse(ResponseMessage response)
throws ResponseParseException {
try {
return parseCreateLiveChannel(response.getContent());
CreateLiveChannelResult result = parseCreateLiveChannel(response.getContent());
result.setRequestId(response.getRequestId());
return result;
} finally {
safeCloseResponse(response);
}
Expand All @@ -405,7 +425,9 @@ public static final class GetLiveChannelInfoResponseParser implements ResponsePa
public LiveChannelInfo parse(ResponseMessage response)
throws ResponseParseException {
try {
return parseGetLiveChannelInfo(response.getContent());
LiveChannelInfo result = parseGetLiveChannelInfo(response.getContent());
result.setRequestId(response.getRequestId());
return result;
} finally {
safeCloseResponse(response);
}
Expand All @@ -419,7 +441,9 @@ public static final class GetLiveChannelStatResponseParser implements ResponsePa
public LiveChannelStat parse(ResponseMessage response)
throws ResponseParseException {
try {
return parseGetLiveChannelStat(response.getContent());
LiveChannelStat result = parseGetLiveChannelStat(response.getContent());
result.setRequestId(response.getRequestId());
return result;
} finally {
safeCloseResponse(response);
}
Expand Down Expand Up @@ -475,7 +499,9 @@ public static final class GetBucketTaggingResponseParser implements ResponsePars
public TagSet parse(ResponseMessage response)
throws ResponseParseException {
try {
return parseGetBucketTagging(response.getContent());
TagSet result = parseGetBucketTagging(response.getContent());
result.setRequestId(response.getRequestId());
return result;
} finally {
safeCloseResponse(response);
}
Expand Down Expand Up @@ -503,7 +529,9 @@ public static final class GetBucketReplicationProgressResponseParser implements
public BucketReplicationProgress parse(ResponseMessage response)
throws ResponseParseException {
try {
return parseGetBucketReplicationProgress(response.getContent());
BucketReplicationProgress result = parseGetBucketReplicationProgress(response.getContent());
result.setRequestId(response.getRequestId());
return result;
} finally {
safeCloseResponse(response);
}
Expand Down Expand Up @@ -531,7 +559,9 @@ public static final class ListObjectsReponseParser implements ResponseParser<Obj
public ObjectListing parse(ResponseMessage response)
throws ResponseParseException {
try {
return parseListObjects(response.getContent());
ObjectListing result = parseListObjects(response.getContent());
result.setRequestId(response.getRequestId());
return result;
} finally {
safeCloseResponse(response);
}
Expand Down Expand Up @@ -656,7 +686,9 @@ public static final class GetObjectAclResponseParser implements ResponseParser<O
public ObjectAcl parse(ResponseMessage response)
throws ResponseParseException {
try {
return parseGetObjectAcl(response.getContent());
ObjectAcl result = parseGetObjectAcl(response.getContent());
result.setRequestId(response.getRequestId());
return result;
} finally {
safeCloseResponse(response);
}
Expand Down Expand Up @@ -814,7 +846,9 @@ public static final class ListMultipartUploadsResponseParser implements Response
public MultipartUploadListing parse(ResponseMessage response)
throws ResponseParseException {
try {
return parseListMultipartUploads(response.getContent());
MultipartUploadListing result = parseListMultipartUploads(response.getContent());
result.setRequestId(response.getRequestId());
return result;
} finally {
safeCloseResponse(response);
}
Expand All @@ -828,7 +862,9 @@ public static final class ListPartsResponseParser implements ResponseParser<Part
public PartListing parse(ResponseMessage response)
throws ResponseParseException {
try {
return parseListParts(response.getContent());
PartListing result = parseListParts(response.getContent());
result.setRequestId(response.getRequestId());
return result;
} finally {
safeCloseResponse(response);
}
Expand Down Expand Up @@ -866,7 +902,9 @@ public static final class GetSymbolicLinkResponseParser implements ResponseParse
public OSSSymlink parse(ResponseMessage response)
throws ResponseParseException {
try {
return parseSymbolicLink(response);
OSSSymlink result = parseSymbolicLink(response);
result.setRequestId(response.getRequestId());
return result;
} finally {
OSSUtils.mandatoryCloseResponse(response);
}
Expand All @@ -880,7 +918,9 @@ public static final class GetUdfInfoResponseParser implements ResponseParser<Udf
public UdfInfo parse(ResponseMessage response)
throws ResponseParseException {
try {
return parseGetUdfInfo(response.getContent());
UdfInfo result = parseGetUdfInfo(response.getContent());
result.setRequestId(response.getRequestId());
return result;
} finally {
OSSUtils.mandatoryCloseResponse(response);
}
Expand Down Expand Up @@ -922,7 +962,9 @@ public static final class GetUdfApplicationInfoResponseParser implements Respons
public UdfApplicationInfo parse(ResponseMessage response)
throws ResponseParseException {
try {
return parseGetUdfApplicationInfo(response.getContent());
UdfApplicationInfo result = parseGetUdfApplicationInfo(response.getContent());
result.setRequestId(response.getRequestId());
return result;
} finally {
safeCloseResponse(response);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/aliyun/oss/model/AccessControlList.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* The class encapsulates the access control list (ACL) information of OSS.
* It includes an owner and a group of <{@link Grantee},{@link Permission}> pair.
* */
public class AccessControlList implements Serializable {
public class AccessControlList extends GenericResult implements Serializable {

private static final long serialVersionUID = 211267925081748283L;

Expand Down
7 changes: 6 additions & 1 deletion src/main/java/com/aliyun/oss/model/Bucket.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* </ul>
* </p>
*/
public class Bucket {
public class Bucket extends GenericResult {

// Bucket name
private String name;
Expand Down Expand Up @@ -73,6 +73,11 @@ public Bucket() { }
public Bucket(String name) {
this.name = name;
}

public Bucket(String name, String requestId){
setName(name);
setRequestId(requestId);
}

/**
* The override of toString(). Returns the bucket name, creation date, owner and location, with optional storage class.
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/aliyun/oss/model/BucketInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
/**
* Bucket info
*/
public class BucketInfo {
public class BucketInfo extends GenericResult {
public Bucket getBucket() {
return this.bucket;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/aliyun/oss/model/BucketList.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import java.util.ArrayList;
import java.util.List;

public class BucketList {
public class BucketList extends GenericResult {

private List<Bucket> buckets = new ArrayList<Bucket>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

package com.aliyun.oss.model;

public class BucketLoggingResult {
public class BucketLoggingResult extends GenericResult {
private String targetBucket;
private String targetPrefix;

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/aliyun/oss/model/BucketProcess.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

package com.aliyun.oss.model;

public class BucketProcess {
public class BucketProcess extends GenericResult {

public BucketProcess(ImageProcess imageProcess) {
this.imageProcess = imageProcess;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/aliyun/oss/model/BucketReferer.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
* </p>
*
*/
public class BucketReferer {
public class BucketReferer extends GenericResult {
private boolean allowEmptyReferer = true;
private List<String> refererList = new ArrayList<String>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
* before that timestamp have been replicated to the target bucket.
* </p>
*/
public class BucketReplicationProgress {
public class BucketReplicationProgress extends GenericResult {
public String getReplicationRuleID() {
return replicationRuleID;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/aliyun/oss/model/BucketStat.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* Bucket Stat
* It contains the current bucket's occupant size and file count.
*/
public class BucketStat {
public class BucketStat extends GenericResult {

public BucketStat(Long storageSize, Long objectCount, Long multipartUploadCount) {
this.storageSize = storageSize;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import java.util.ArrayList;
import java.util.List;

public class BucketWebsiteResult {
public class BucketWebsiteResult extends GenericResult {
private String indexDocument;
private String errorDocument;
private List<RoutingRule> routingRules;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import java.util.List;

public class CreateLiveChannelResult {
public class CreateLiveChannelResult extends GenericResult {

public List<String> getPublishUrls() {
return publishUrls;
Expand Down
Loading

0 comments on commit 80f53f7

Please sign in to comment.