Skip to content

Commit ed47fe2

Browse files
liyanzhang505huiguangjun
authored andcommitted
update jdom from 1.x to 2.x.
1 parent 05c05a6 commit ed47fe2

File tree

7 files changed

+33
-15
lines changed

7 files changed

+33
-15
lines changed

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
</dependency>
2626
<dependency>
2727
<groupId>org.jdom</groupId>
28-
<artifactId>jdom</artifactId>
29-
<version>1.1</version>
28+
<artifactId>jdom2</artifactId>
29+
<version>2.0.6</version>
3030
</dependency>
3131
<dependency>
3232
<groupId>org.codehaus.jettison</groupId>

src/main/java/com/aliyun/oss/common/parser/JAXBResponseParser.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,13 @@
3232
import javax.xml.parsers.SAXParserFactory;
3333
import javax.xml.transform.sax.SAXSource;
3434

35+
import com.aliyun.oss.ClientException;
3536
import org.xml.sax.InputSource;
3637
import org.xml.sax.SAXException;
3738

3839
import com.aliyun.oss.common.comm.ResponseMessage;
40+
import org.xml.sax.SAXNotRecognizedException;
41+
import org.xml.sax.SAXNotSupportedException;
3942

4043
/**
4144
* Implementation of <code>ResponseParser<code> with JAXB.
@@ -56,6 +59,13 @@ public class JAXBResponseParser implements ResponseParser<Object> {
5659
static {
5760
saxParserFactory.setNamespaceAware(true);
5861
saxParserFactory.setValidating(false);
62+
try {
63+
saxParserFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
64+
saxParserFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
65+
saxParserFactory.setFeature("http://xml.org/sax/features/external-general-entities", false);
66+
saxParserFactory.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
67+
} catch (Exception e) {
68+
}
5969
}
6070

6171
public JAXBResponseParser(Class<?> modelClass) {

src/main/java/com/aliyun/oss/internal/ResponseParsers.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@
4646
import com.aliyun.oss.model.InventorySchedule;
4747
import com.aliyun.oss.model.InventoryServerSideEncryptionKMS;
4848
import com.aliyun.oss.model.ListObjectsV2Result;
49-
import org.jdom.Document;
50-
import org.jdom.Element;
51-
import org.jdom.input.JDOMParseException;
52-
import org.jdom.input.SAXBuilder;
49+
import org.jdom2.Document;
50+
import org.jdom2.Element;
51+
import org.jdom2.input.JDOMParseException;
52+
import org.jdom2.input.SAXBuilder;
5353

5454
import com.aliyun.oss.common.comm.ResponseMessage;
5555
import com.aliyun.oss.common.parser.ResponseParseException;
@@ -1157,6 +1157,10 @@ public static <ResultType extends GenericResult> void setServerCRC(ResultType re
11571157

11581158
private static Element getXmlRootElement(InputStream responseBody) throws Exception {
11591159
SAXBuilder builder = new SAXBuilder();
1160+
builder.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
1161+
builder.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
1162+
builder.setFeature("http://xml.org/sax/features/external-general-entities", false);
1163+
builder.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
11601164
Document doc = builder.build(responseBody);
11611165
return doc.getRootElement();
11621166
}

src/test/java/com/aliyun/oss/common/parser/RequestMarshallersTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
import com.aliyun.oss.common.comm.io.FixedLengthInputStream;
88
import com.aliyun.oss.model.*;
99
import junit.framework.Assert;
10-
import org.jdom.Document;
11-
import org.jdom.Element;
12-
import org.jdom.JDOMException;
13-
import org.jdom.input.SAXBuilder;
10+
import org.jdom2.Document;
11+
import org.jdom2.Element;
12+
import org.jdom2.JDOMException;
13+
import org.jdom2.input.SAXBuilder;
1414
import org.junit.Test;
1515

1616
import java.io.ByteArrayInputStream;

src/test/java/com/aliyun/oss/common/parser/ResponseParsersTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@
33
import com.aliyun.oss.common.comm.ResponseMessage;
44
import com.aliyun.oss.common.utils.DateUtil;
55
import com.aliyun.oss.internal.ResponseParsers;
6+
import com.aliyun.oss.internal.model.OSSErrorResult;
67
import com.aliyun.oss.model.*;
78
import junit.framework.Assert;
9+
import org.jdom2.Document;
10+
import org.jdom2.Element;
11+
import org.jdom2.input.SAXBuilder;
812
import org.junit.Test;
913

1014
import java.io.ByteArrayInputStream;

src/test/java/com/aliyun/oss/integrationtests/ObjectEncryptionTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public void setUp() throws Exception {
4545
super.setUp();
4646

4747
bucketName = super.bucketName + "-object-encryption";
48-
endpoint = "http://oss-ap-southeast-5.aliyuncs.com";
48+
endpoint = "http://oss-cn-hongkong.aliyuncs.com";
4949

5050
//create client
5151
ClientConfiguration conf = new ClientConfiguration().setSupportCname(false);

src/test/java/com/aliyun/oss/perftests/PerftestRunner.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@
3939
import org.apache.commons.logging.Log;
4040
import org.apache.commons.logging.LogFactory;
4141

42-
import org.jdom.Document;
43-
import org.jdom.Element;
44-
import org.jdom.JDOMException;
45-
import org.jdom.input.SAXBuilder;
42+
import org.jdom2.Document;
43+
import org.jdom2.Element;
44+
import org.jdom2.JDOMException;
45+
import org.jdom2.input.SAXBuilder;
4646

4747
import com.aliyun.oss.ClientException;
4848
import com.aliyun.oss.OSS;

0 commit comments

Comments
 (0)