Skip to content

Commit 32e5b6b

Browse files
author
Sunny Raj Rathod
authored
Merge pull request AuthorizeNet#104 from sunnyrajrathod/master
Fix for multithreading issue
2 parents ec6e156 + a6dc573 commit 32e5b6b

File tree

2 files changed

+35
-30
lines changed

2 files changed

+35
-30
lines changed

src/main/java/net/authorize/util/Constants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,5 @@ public final class Constants {
3333
public static final String HTTP_READ_TIME_OUT = "http.ReadTimeout";
3434
public static final int HTTP_READ_TIME_OUT_DEFAULT_VALUE = 30000;
3535

36-
public static final String CLIENT_ID = "sdk-java-1.9.0";
36+
public static final String CLIENT_ID = "sdk-java-1.9.1";
3737
}

src/main/java/net/authorize/util/XmlUtility.java

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public final class XmlUtility {
3434
*/
3535
private XmlUtility() {
3636
}
37-
37+
3838
/**
3939
* Helper method to serialize an object to XML. Requires object to be Serializable
4040
* @param entity Object to serialize
@@ -49,7 +49,6 @@ public static synchronized <T extends Serializable> String getXml(T entity) thro
4949

5050
if ( null != entity)
5151
{
52-
5352
if(!jaxbContext.containsKey(entity.getClass().toString()))
5453
{
5554
request_ctx = JAXBContext.newInstance(entity.getClass());
@@ -59,11 +58,14 @@ public static synchronized <T extends Serializable> String getXml(T entity) thro
5958
{
6059
request_ctx = jaxbContext.get(entity.getClass().toString());
6160
}
62-
63-
Marshaller m = request_ctx.createMarshaller();
64-
m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
6561

66-
m.marshal(entity, sw);
62+
if(request_ctx != null)
63+
{
64+
Marshaller m = request_ctx.createMarshaller();
65+
m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
66+
67+
m.marshal(entity, sw);
68+
}
6769
}
6870
sw.flush();
6971
sw.close();
@@ -95,29 +97,32 @@ public static synchronized <T extends Serializable> T create(String xml, Class<T
9597
{
9698
response_ctx = jaxbContext.get(classType.toString());
9799
}
98-
99-
Unmarshaller um = response_ctx.createUnmarshaller();
100-
try {
101-
Object unmarshaled = um.unmarshal(new StringReader(xml));
102-
if ( null != unmarshaled)
103-
{
104-
try {
105-
entity = classType.cast(unmarshaled);
106-
} catch (ClassCastException cce) {
107-
if (unmarshaled instanceof JAXBElement) {
108-
@SuppressWarnings("rawtypes")
109-
JAXBElement element = (JAXBElement) unmarshaled;
110-
if ( null != element.getValue() && element.getValue().getClass()==classType) {
111-
entity = (T) element.getValue();
112-
}
113-
}
114-
}
115-
}
116-
} catch (JAXBException jaxbe) {
117-
LogHelper.info(logger, "Exception - while deserializing text:'%s' ", xml);
118-
LogHelper.warn(logger, "Exception Details-> Code:'%s', Message:'%s'", jaxbe.getErrorCode(), jaxbe.getMessage());
119-
throw jaxbe;
120-
}
100+
101+
if(response_ctx != null)
102+
{
103+
Unmarshaller um = response_ctx.createUnmarshaller();
104+
try {
105+
Object unmarshaled = um.unmarshal(new StringReader(xml));
106+
if ( null != unmarshaled)
107+
{
108+
try {
109+
entity = classType.cast(unmarshaled);
110+
} catch (ClassCastException cce) {
111+
if (unmarshaled instanceof JAXBElement) {
112+
@SuppressWarnings("rawtypes")
113+
JAXBElement element = (JAXBElement) unmarshaled;
114+
if ( null != element.getValue() && element.getValue().getClass()==classType) {
115+
entity = (T) element.getValue();
116+
}
117+
}
118+
}
119+
}
120+
} catch (JAXBException jaxbe) {
121+
LogHelper.info(logger, "Exception - while deserializing text:'%s' ", xml);
122+
LogHelper.warn(logger, "Exception Details-> Code:'%s', Message:'%s'", jaxbe.getErrorCode(), jaxbe.getMessage());
123+
throw jaxbe;
124+
}
125+
}
121126
}
122127

123128
return entity;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy