You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Andy <an...@hotmail.com> on 2010/12/04 22:08:22 UTC
Thread-safety question
Hi, I have a method below that unmarshals an input stream and since I will have many concurrent invocations of this method, I was wondering if there would be any Thread-safety issues? I'm not a threading expert but just wanted to make sure the XmlObject.Factory.parse() method wouldn't cause any issues.
protected final Object unmarshalInputStream(InputStream inputStream) throws XmlMappingException, IOException {
try {
XmlObject object = XmlObject.Factory.parse(inputStream, getXmlOptions());
validate(object);
return object;
}
catch (XmlException ex) {
throw convertXmlBeansException(ex, false);
}
}
Thanks-
RE: Thread-safety question
Posted by Andy <an...@hotmail.com>.
Dang. I was hoping XmlObject.Factory.parse() was thread-safe. Maybe a future enhancement? Thanks-
From: Pim.Tjeertes@xs4all.nl
To: user@xmlbeans.apache.org
Subject: RE: Thread-safety question
Date: Sun, 5 Dec 2010 22:53:47 +0100
Hi Andy, The method is only thread safe in case you make the either the method or the entire class synchronized.Otherwise it’s not thread safe. Well working with just one thread would not get you in trouble either of course. ;-) PimFrom: Andy [mailto:andrhahn@hotmail.com]
Sent: zondag 5 december 2010 18:14
To: user@xmlbeans.apache.org
Subject: RE: Thread-safety question Hi Pim, I I were to leave the method as is, would the method not be thread-safe? I ask because this method is part of a library I am using. Thanks-From: Pim.Tjeertes@xs4all.nl
To: user@xmlbeans.apache.org
Subject: RE: Thread-safety question
Date: Sun, 5 Dec 2010 15:06:31 +0100Hi Andy, Making your method synchronized should take care of thread safety issues. Kind regards,Pim From: Andy [mailto:andrhahn@hotmail.com]
Sent: zaterdag 4 december 2010 22:08
To: user@xmlbeans.apache.org
Subject: Thread-safety question Hi, I have a method below that unmarshals an input stream and since I will have many concurrent invocations of this method, I was wondering if there would be any Thread-safety issues? I'm not a threading expert but just wanted to make sure the XmlObject.Factory.parse() method wouldn't cause any issues. protected final Object unmarshalInputStream(InputStream inputStream) throws XmlMappingException, IOException { try { XmlObject object = XmlObject.Factory.parse(inputStream, getXmlOptions()); validate(object); return object; } catch (XmlException ex) { throw convertXmlBeansException(ex, false); } } Thanks-
RE: Thread-safety question
Posted by Pim Tjeertes <Pi...@xs4all.nl>.
Hi Andy,
The method is only thread safe in case you make the either the method or the
entire class synchronized.
Otherwise it's not thread safe.
Well working with just one thread would not get you in trouble either of
course. ;-)
Pim
From: Andy [mailto:andrhahn@hotmail.com]
Sent: zondag 5 december 2010 18:14
To: user@xmlbeans.apache.org
Subject: RE: Thread-safety question
Hi Pim,
I I were to leave the method as is, would the method not be thread-safe?
I ask because this method is part of a library I am using.
Thanks-
_____
From: Pim.Tjeertes@xs4all.nl
To: user@xmlbeans.apache.org
Subject: RE: Thread-safety question
Date: Sun, 5 Dec 2010 15:06:31 +0100
Hi Andy,
Making your method synchronized should take care of thread safety issues.
Kind regards,
Pim
From: Andy [mailto:andrhahn@hotmail.com]
Sent: zaterdag 4 december 2010 22:08
To: user@xmlbeans.apache.org
Subject: Thread-safety question
Hi, I have a method below that unmarshals an input stream and since I will
have many concurrent invocations of this method, I was wondering if there
would be any Thread-safety issues? I'm not a threading expert but just
wanted to make sure the XmlObject.Factory.parse() method wouldn't cause any
issues.
protected final Object unmarshalInputStream(InputStream inputStream)
throws XmlMappingException, IOException {
try {
XmlObject object = XmlObject.Factory.parse(inputStream,
getXmlOptions());
validate(object);
return object;
}
catch (XmlException ex) {
throw convertXmlBeansException(ex, false);
}
}
Thanks-
RE: Thread-safety question
Posted by Andy <an...@hotmail.com>.
Hi Pim,
I I were to leave the method as is, would the method not be thread-safe?
I ask because this method is part of a library I am using.
Thanks-
From: Pim.Tjeertes@xs4all.nl
To: user@xmlbeans.apache.org
Subject: RE: Thread-safety question
Date: Sun, 5 Dec 2010 15:06:31 +0100
Hi Andy, Making your method synchronized should take care of thread safety issues. Kind regards,Pim From: Andy [mailto:andrhahn@hotmail.com]
Sent: zaterdag 4 december 2010 22:08
To: user@xmlbeans.apache.org
Subject: Thread-safety question Hi, I have a method below that unmarshals an input stream and since I will have many concurrent invocations of this method, I was wondering if there would be any Thread-safety issues? I'm not a threading expert but just wanted to make sure the XmlObject.Factory.parse() method wouldn't cause any issues. protected final Object unmarshalInputStream(InputStream inputStream) throws XmlMappingException, IOException { try { XmlObject object = XmlObject.Factory.parse(inputStream, getXmlOptions()); validate(object); return object; } catch (XmlException ex) { throw convertXmlBeansException(ex, false); } } Thanks-
RE: Thread-safety question
Posted by Pim Tjeertes <Pi...@xs4all.nl>.
Hi Andy,
Making your method synchronized should take care of thread safety issues.
Kind regards,
Pim
From: Andy [mailto:andrhahn@hotmail.com]
Sent: zaterdag 4 december 2010 22:08
To: user@xmlbeans.apache.org
Subject: Thread-safety question
Hi, I have a method below that unmarshals an input stream and since I will
have many concurrent invocations of this method, I was wondering if there
would be any Thread-safety issues? I'm not a threading expert but just
wanted to make sure the XmlObject.Factory.parse() method wouldn't cause any
issues.
protected final Object unmarshalInputStream(InputStream inputStream)
throws XmlMappingException, IOException {
try {
XmlObject object = XmlObject.Factory.parse(inputStream,
getXmlOptions());
validate(object);
return object;
}
catch (XmlException ex) {
throw convertXmlBeansException(ex, false);
}
}
Thanks-